Skip to content

Analog/Digital Hall Sensor Wireling Tutorial

TinyCircuits Hall-Effect Sensor Wirelings

This Wireling lets you measure the intensity of magnetic fields via the A1454 Linear Hall Effect Sensor or the TCS40DLR Discrete Hall Switch. This particular version of the A1454 is intended to be used with ferrite type magnets.

Read more about the differences in common magnets..

Technical Details

Allegro A1454 Hall Sensor Specs (Analog)

  • 2 factory programmed sensitivity options: 2 LSB/G (for fields up to ±1000 G) and 4 LSB/G (±500 G)
  • Temperature-stable sensitivity for NdFeB and ferrite magnets
  • I²C interface for easy integration with support for up to 127 unique addresses
  • EEPROM stores factory-programmed settings and up to 16 bytes of user information (programmable through the I²C interface)
  • Micro-power sleep mode through I²C command for minimizing power in battery-operated applications
  • Precise recoverability after temperature cycling
  • Wide ambient temperature range: –40°C to 125°C
  • 12-bit ADC with 10-bit ENOB (Effective Number of Bits)
  • Operating Voltage: 2.65V - 3.5V
  • Operating Current: 5mA (max)

Toshiba TCS40 Hall Switch Specs (Digital)

  • Omnipolar (dual detection) 
  • Open-Drain 
  • ßON = 3.4mT
  • ßOFF = 2.0mT
  • Operating Voltage: 2.3V - 5.5V
  • Operating Current: 1.0mA

TinyDuino Power Requirements

  • Voltage: 3.0V - 5.5V 

Pins Used

  • A5/SCL - I²C Serial Clock line
  • A4/SDA - I²C Serial Data line


  • 10mm x 10mm (.394 inches x .394 inches)
  • Max Height (from the lower bottom of Wireling to upper top Wireling Connector): 4.60mm (0.18 inches)
  • Weight: 1 gram (.04 ounces)


  • The A1454 will be able to pick up readings from magnets or metals containing Ferrite or Neodymium. The Wikipedia articles may sound confusing, but basically any magnet that goes on your fridge or other things made of neodymium, like headphones or DC electric motors will give a reading.
  • Hall Sensors are commonly used in projects needing switches, like a home security system that has attachments on doors and windows that detects when a magnet is moved away (like when a door opens).
  • A Hall effect sensor can operate as an electronic switch, which can be cheaper and more reliable than a mechanical switch.
  • Linear Hall Effect Sensors, like the A1454 in this tutorial, can measure a wide range of magnetic fields rather than a digital hall sensor like the TCS40DLR Discrete Hall Switch that solely measures whether there is a magnet or not (You may notice that the A1454 gives readings from a range of 0-4096)


To interface with any TinyCircuits Arduino board, you will need the Arduino IDE and a Micro USB Cable

There are multiple processor/adapter combinations that can be used with Wirelings. Use the following table to find the combination that works for you.

Processor Adapter
*TinyDuino and USB TinyShield Wireling Adapter TinyShield
*TinyZero Wireling Adapter TinyShield
*TinyScreen+ Wireling Adapter TinyShield
WirelingZero N/A
*RobotZero N/A
Arduino Wireling Arduino Shield
Raspberry Pi Wireling Pi Hat

* These processors have a 32-pin connector and can have multiple Wireling Adapter TinyShields stacked to increase the number of Wireling ports up to a maximum of 32 total Wireling ports.

In order to interface with Wirelings, you'll need the appropriate number of Wireling Cables and the Wireling.h Library (You can download this from GitHub as linked, or from the Library Manager in the Arduino IDE).

You will also need the Hall-Effect Sensor Wireling of choice and the included example Arduino sketch.

Wireling Code
Analog Hall Sensor (A) Example Sketch
Digital Hall Sensor (D) Example Sketch

Hardware Assembly

Depending on the development system you choose, you will need to put together a TinyDuino stack using the 32-pin tan connectors, or you will just need to plug in your Wireling to Port 0 using a Wireling Cable. (You can change this port in the included Arduino Sketch by editing the Analog pin used as noted in the program (for the Digital Hall), or by editing the Wireling.selectPort() (for the Analog Hall) function to match your setup.)

NOTE: Be mindful when inserting Wireling Cables - the connector pins inside the 5-pin connectors on Wirelings can be bent when cables are inserted at an angle.

Assembly gif alternating between analog and digital board option with WirelingZero and cables

Software Setup

If you have not already done so, download the example sketch for the Digital or Analog Hall Sensor (found above under Materials) and open it in the Arduino IDE. All the necessary files for the programs are included in the zipped folder.

Make the correct Tools selections for your development board. If unsure, you can double check the Help page that mentions the Tools selections needed for any TinyCircuits processor.

Analog Hall Effect Sensor

After uploading the program, you should see output in the Serial Monitor displaying the readings for level of magnetism (measured in millitesla), and the temperature in both degrees Celsius and Fahrenheit:

This image is the output of having no magnet in the proximity of the A1454 Sensor, and then moving a magnet near it.

Analog Sensor Code
 * A1454 Hall Effect Wireling Test Code - 
 * This program will show the basic method of interfacing with the sensor 
 * by printing out the Analog values (readings from 0 to 4096 (12-bit)) on
 * the Serial Monitor.
 * Hardware by: TinyCircuits
 * Written by: Laveréna Wienclaw for TinyCircuits
 * Initiated: June 2019
 * Updated: Jan 2020

#include <Wire.h>               // For I2C communication
#include <Wireling.h>           // For Interfacing with Wirelings
#include "TinyCircuits_A1454.h" // For the sensor

// A sensor object, the methods will be used to interface with the A1454
TinyCircuits_A1454 hall = TinyCircuits_A1454();

// Make Serial Monitor compatible for all TinyCircuits processors
#if defined(ARDUINO_ARCH_AVR)
  #define SerialMonitorInterface Serial
#elif defined(ARDUINO_ARCH_SAMD)
  #define SerialMonitorInterface SerialUSB

void setup() {
  // Begin communication 
  SerialMonitorInterface.println("HALL LIBRARY TEST CODE");

  // Enable & Power Wireling
  Wireling.selectPort(0); // This must match the port the Wireling is connected to 
                          // on the Adapter board

//  hall.wake(); 

void loop() {
  long mag = hall.readMag();
  long temp = hall.readTemp();
  long mode = hall.readMode();

//  if (mode == 0) SerialMonitorInterface.print("AWAKE\t\t");
//  else if (mode == 1) SerialMonitorInterface.print("SLEEPING\t\t");

  SerialMonitorInterface.print("Mag: ");
  SerialMonitorInterface.print((float)mag / 4.0/ 10.0); // convert to ENOB, and Gauss to millitesla
  SerialMonitorInterface.print("mT"); // millitesla

  SerialMonitorInterface.print("TempF: ");
  int tempF = ((temp * 1.8) + 32);

  SerialMonitorInterface.print("TempC: ");


Digital Hall Switch

Upload the Digital Hall Sensor program in order to detect binarily whether there is a magnet close to the sensor or not. If there is a magnet near the sensor, a 1 will be printed to the Serial monitor, and a 0 will be printed if there is not magnet detectable.

Digital Hall Switch Sensor Code
 * TCS40 Hall Switch Sensor Wireling Tutorial:
 * This program prints the status of a magnet detected or not using a 
 * TCS40 Digital Hall Switch Wireling.
 * Hardware by: TinyCircuits
 * Code by: Laverena Wienclaw for TinyCircuits
 * Initiated: 09/27/2019
 * Updated: 12/04/2019

#include <Wireling.h> // For interfacing with Wirelings

// Hall Sensor variables
#define magPin A0        // Corresponds to PORT# of Wireling used (Do not use A0)
bool hallOutput = 0;     // What is directly output from Wireling
bool magnetDetected = 0; // Make sense of output 

// Make Serial Monitor compatible for all TinyCircuits processors
#if defined(ARDUINO_ARCH_AVR)
  #define SerialMonitorInterface Serial
#elif defined(ARDUINO_ARCH_SAMD)
  #define SerialMonitorInterface SerialUSB

void setup() {

  // Enable & power Wireling

  // Set Hall Switch Pin to input
  pinMode(magPin, INPUT);

void loop() {
  hallOutput = digitalRead(magPin); // If no magnet, hallOutput == 1
  magnetDetected = !hallOutput; // Flip the hallOutput so magnetDetected == 1 when there is a magnet


This Wireling does not use I²C communication, so a pin is used to interface with it, rather than the usual selectPort() I²C function.

You can use this inexpensive Wireling to make a speedometer, like it's used in the RGB LED Scooter project!


Analog Hall-Effect Wireling

Digital Hall-Effect Wireling

Contact Us

If you have any questions or feedback, feel free to email us or make a post on our forum. Show us what you make by tagging @TinyCircuits on Instagram, Twitter, or Facebook so we can feature it.

Thanks for making with us!