The Allegro A3214 Hall-Effect Switch

As I mentioned yesterday, I’m currently testing a new sensor: the Allegro A3214 Hall-Effect switch. This very small sensor looks like a very good candidate for my own Door & Window sensors. A sample of this sensor was given to me by Jean-Claude Wippler a few weeks ago, and now that I’m waiting for some Mantis parts I ordered and have no more time to spend on the Arduino Workshop, it was time for something new.

Some characteristics of the A3214:

  • 2.4 to 5.5V battery operation
  • minimal power requirements
  • pole independent switching
  • small size

How small is small??

This is small!

Allegro A3214

The magnet (upper left) measures 3x3x3 mm, the sensor dimensions are 4 x 3 x 1.5 mm. Yep, that’s really small 🙂

First thing I did yesterday, was putting this sensor on a breadboard and connecting it to a JeeNode. I wrote a small sketch that used LED2 of the Bridge Board to visually show the status of the sensor output:

#include <Ports.h>
#include <RF12.h>

Port one (1);
Port four (4);

void setup() {
  one.mode(OUTPUT); // LED2 of Bridge Board is connected to Port 1 Digital.

  four.mode(INPUT); // the sensor is connected to Port 4.
  four.digiWrite(HIGH);  // enable pullup

void loop() {


It worked, wow! Moving the magnet towards the sensor made the LED go off (the output is high when the magnetic field isn’t strong enough), moving the magnet away made the LED go on again. The distance between sensor and magnet when the output value changes is approx. 10 mm.

Today I wanted to do some power usage measurements, so I changed the sketch a bit:

#include <Ports.h>
#include <RF12.h> // needed to avoid a linker error :(
#include <Sleep.h>

#define DEBUG 0

int INTpin = 3;
Port one (1);

volatile boolean wdt_expired=0;

// Interrupt Serive Routine that will be executed when the Watchdog Timer expired.
ISR(WDT_vect) {

// 0=16ms, 1=32ms,2=64ms,3=128ms,4=250ms,5=500ms
// 6=1 sec,7=2 sec, 8=4 sec, 9= 8sec
void setup_watchdog(int ii) {

  byte bb;
  int ww;
  if (ii > 9 ) ii=9;
  bb=ii & 7;
  if (ii > 7) bb|= (1<<5);
  bb|= (1<<WDCE);

  MCUSR &= ~(1<<WDRF);
  // start timed sequence
  WDTCSR |= (1<<WDCE) | (1<<WDE);
  // set new watchdog timeout value
  WDTCSR = bb;

void setup(void)
  pinMode(INTpin, INPUT);
  digitalWrite(INTpin, HIGH);

  one.mode(OUTPUT); // LED2 of Bridge Board is connected to Port 1 Digital.

  #if DEBUG

void loop(void)
  #if DEBUG
  Serial.print(millis(), DEC);
  Serial.print(" I'm awake, caused by ");

  if (wdt_expired==1){
    #if DEBUG
      Serial.println("the WDT");

    // Do something, like sending a heatbeat
    // sometimes

    // External interrupt triggered!
    byte val = digitalRead(INTpin);

    // disable LED during power measurements

    #if DEBUG
    Serial.print(val, DEC);
    Serial.println(" INT0");
    Serial.print("Doing some serious stuff now...");

    // measure awake

    #if DEBUG

  #if DEBUG
  Serial.print(millis(), DEC);
  Serial.println(" Sleeping...");
  delay(100);     // wait for serial to finish

  // go to sleep and wake up
  // on watchdog or IRQ pin change
  Sleep.powerDownAndWakeupExternalEvent(1, CHANGE);     // sleep function called here
The A3214 output was moved to an external interrupt pin, I disabled LED2 and wrote down the power usages with the JeeNode, Bridge Board and A3214 connected to a 3 x AA battery pack producing 4.1 V:
  • JeeNode awake: 7 mA;
  • JeeNode asleep, magnet in range of sensor: 38 μA;
  • JeeNode asleep, magnet out of range: 14 μA.

That’s very good… I’m sure this power usage will be good enough to live on 1 set of AA batteries for a long time. 🙂

Of course, Door & Window sensors is the most obvious application for these sensors. But the small size makes me wonder if I can come up with more useful ideas…

On to the next step!

Tagged , . Bookmark the permalink.

6 Responses to The Allegro A3214 Hall-Effect Switch

  1. EriSan500 says:

    I ordered this sensor through the Jeenode shop, and that is how JCW got pointed to it. I use this sensor to measure my gas consumption. I placed it where the factory sensor should be placed. It works flawless, even better then the optical CNY70 that i was using before. I have also installed one on my garage door to check if it’s open or close. Greetings

  2. Jean-Claude Wippler says:

    Neat. My hunch is that the extra 24 µA is due to the internal ATmega pull-up. You could get it even lower by using an external pull-up resistor instead of the built-in one, probably – I’d try 1 MΩ. Maybe that’s too high, and you’ll pick up noise on the line, but I doubt it.

  3. Pingback: MCU-less experiments

  4. Pingback: Half-way there?

Leave a Reply

Your email address will not be published. Required fields are marked *