Arduino Nano - A1332 Hall Effect Sensor Tutorial

by Dcube Tech Ventures in Circuits > Electronics

35 Views, 0 Favorites, 0 Comments

Arduino Nano - A1332 Hall Effect Sensor Tutorial

Arduino Nano - A1332 Hall Effect Sensor Tutorial

A1332 is a 360° contactless high resolution programmable magnetic angle position sensor. It is designed for digital systems using an I2C interface. It is built on Circular Vertical Hall (CVH) technology and a programmable microprocessor based signal processing is also incorporated in this sensor. Here is the demonstration with arduino nano.

What You Need..!!

A1332_I2CS_A_1.png
nano.png

Connections :

A1332_I2CS_A_1.png
nano.png
sensor.jpg
arduino_connect.JPG

Take an I2C shield for Arduino Nano and gently push it over the pins of Nano.

Then connect the one end of I2C cable to A1332 sensor and the other end to the I2C shield.

Connections are shown in the picture above.

Code :

arduino_connect.JPG

The arduino code for A1332 can be downloaded from our GitHub repository- Dcube Store.

Here is the link for the same :

https://github.com/DcubeTechVentures/A1332

We include library Wire.h to facilitate the I2c communication of the sensor with the Arduino board.

You can also copy the code from here, it is given as follows:

// Distributed with a free-will license.

// Use it any way you want, profit or free, provided it fits in the licenses of its associated works.

// A1332

// This code is designed to work with the A1332_I2CS I2C Mini Module available in Dcube Store.

#include

// A1332 I2C address is 0x0C(12)

#define Addr 0x0C

void setup()

{

// Initialise I2C communication as Master

Wire.begin();

// Initialise serial communication, set baud rate = 9600

Serial.begin(9600);

delay(300);

}

void loop()

{

unsigned int data[2];

// Start I2C Transmission

Wire.beginTransmission(Addr);

// Stop I2C Transmission

Wire.endTransmission();

// Request 2 byte of data

Wire.requestFrom(Addr, 2);

// Read 2 bytes of data

// raw_adc msb, raw_adc lsb

if(Wire.available() == 2)

{

data[0] = Wire.read();

data[1] = Wire.read();

}

// Checking valid data

while((data[0] == 0) && (data[1] == 0))

{

// Request 2 byte of data

Wire.requestFrom(Addr, 2);

// Read 2 bytes of data

// raw_adc msb, raw_adc lsb

if(Wire.available() == 2)

{

data[0] = Wire.read();

data[1] = Wire.read();

}

}

// Convert the data to 12-bits

int raw_adc = ((data[0] & 0x0F) * 256) + (data[1] & 0xFF);

float angle = (raw_adc * 360.0) / 4096.0;

// Output data to serial monitor

Serial.print("Magnetic Angle : ");

Serial.println(angle);

delay(500);

}

Applications :

A1332 is ideal for automotive applications requiring high speed 360° angle measurements, such as: electronic power steering (EPS), transmission, torsion bar, and other systems that require accurate measurement of angles. This sensor is designed for fulfilling the requirements of the systems which incorporate measurement of angle and exact position with high precision.