Skip to content

11. Input device

A1324LLHLT-T & ATmega328 TQFP

This week I’ve made a Satsha-micro adding the analog sensor Hall Effect on the A0 pin of the ATmega328P-AU.

Allegro Microsystems A1324LLHLT-T is a Linear Hall Effect Sensor, 5V, 3-Pin SOT-23

Tip

Using Eagle, you can find the component scheme searching for SOT-23 in the libraries.

After cloned SatshaKit-micro repo from GitHub, I’ve modded it as follow: and adding a Solder Jumper near the A1324 to free the A0 for future uses.

Milling the board

After exporting traces and cutOut, I’ve milled the board.

and after soldering all components …

Program with Arduino as ISP

const int ledPin = 5;
const int readPin = A0;
void setup() {
Serial.begin(9600); // Open the serial
pinMode(ledPin, OUTPUT); // If the board will start I'll try simply a digital pin LED on pin 5
pinMode(readPin, INPUT); //Set A0 as pin to read from A1324
}

void loop() {
digitalWrite(ledPin, HIGH);
int value = analogRead(readPin);
Serial.println(value); // Write the sensor data on the serial
delay(500);
digitalWrite(ledPin, LOW);
delay(500);
}

Read data Sensor

Arduino Serial Monitor

The 1st attempt is to read data directly from Arduino serial Monitor.

Python

Assuming that you have installed Python, you can install PySerial.

pip install pyserial
and copy the code below in a .py file, but remember to change the serial Port connected to the board trought by 5v ftdi adapter.

import serial
import time
ser = serial.Serial('COM30', 9600, timeout=0) #Change the Serial port

while 1:
 try:
  print ser.readline()
  time.sleep(0.5)
 except ser.SerialTimeoutException:
  print('Data could not be read')
  time.sleep(0.5)

Node-RED

If you want use the interface to read Analog sensor on the Node-RED ui, you can copy the code below and paste it on the import/flow area of Node-RED.

[{"id":"b4b6afcb.4a095","type":"tab","label":"A1324-read","disabled":false,"info":""},{"id":"c546109.28202f","type":"serial-port","z":"b4b6afcb.4a095","serialport":"COM7","serialbaud":"57600","databits":"8","parity":"none","stopbits":"1","newline":"\\n","bin":"false","out":"char","addchar":false,"responsetimeout":""},{"id":"3d9ddd30.1b9872","type":"ui_group","z":"b4b6afcb.4a095","name":"A1324 on ATMega328 Board","tab":"aff94d3c.b1da9","disp":true,"width":"9","collapse":false},{"id":"aff94d3c.b1da9","type":"ui_tab","z":"b4b6afcb.4a095","name":"Home","icon":"dashboard"},{"id":"2f3b2708.565038","type":"ui_base","theme":{"name":"theme-dark","lightTheme":{"default":"#0094CE","baseColor":"#0094CE","baseFont":"-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen-Sans,Ubuntu,Cantarell,Helvetica Neue,sans-serif","edited":true,"reset":false},"darkTheme":{"default":"#097479","baseColor":"#097479","baseFont":"-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen-Sans,Ubuntu,Cantarell,Helvetica Neue,sans-serif","edited":true,"reset":false},"customTheme":{"name":"Untitled Theme 1","default":"#4B7930","baseColor":"#4B7930","baseFont":"-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen-Sans,Ubuntu,Cantarell,Helvetica Neue,sans-serif"},"themeState":{"base-color":{"default":"#097479","value":"#097479","edited":false},"page-titlebar-backgroundColor":{"value":"#097479","edited":false},"page-backgroundColor":{"value":"#111111","edited":false},"page-sidebar-backgroundColor":{"value":"#000000","edited":false},"group-textColor":{"value":"#0eb8c0","edited":false},"group-borderColor":{"value":"#555555","edited":false},"group-backgroundColor":{"value":"#333333","edited":false},"widget-textColor":{"value":"#eeeeee","edited":false},"widget-backgroundColor":{"value":"#097479","edited":false},"widget-borderColor":{"value":"#333333","edited":false},"base-font":{"value":"-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen-Sans,Ubuntu,Cantarell,Helvetica Neue,sans-serif"}},"angularTheme":{"primary":"indigo","accents":"blue","warn":"red","background":"grey"}},"site":{"name":"Node-RED Dashboard","hideToolbar":"true","allowSwipe":"false","lockMenu":"false","allowTempTheme":"false","dateFormat":"DD/MM/YYYY","sizes":{"sx":48,"sy":48,"gx":6,"gy":6,"cx":6,"cy":6,"px":0,"py":0}}},{"id":"1a391ce6.02abb3","type":"serial-port","z":"","serialport":"COM27","serialbaud":"9600","databits":"8","parity":"none","stopbits":"1","newline":"100","bin":"false","out":"interbyte","addchar":false,"responsetimeout":"100"},{"id":"ffca00db.5de9a","type":"serial in","z":"b4b6afcb.4a095","name":"","serial":"1a391ce6.02abb3","x":370,"y":300,"wires":[["821fa5a4.d76118","d5c9a991.b14de8"]]},{"id":"821fa5a4.d76118","type":"debug","z":"b4b6afcb.4a095","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":570,"y":420,"wires":[]},{"id":"d5c9a991.b14de8","type":"ui_gauge","z":"b4b6afcb.4a095","name":"","group":"3d9ddd30.1b9872","order":1,"width":0,"height":0,"gtype":"compass","title":"","label":"units","format":"{{value}}","min":0,"max":"1023","colors":["#00b500","#e6e600","#ca3838"],"seg1":"","seg2":"","x":760,"y":300,"wires":[]}]