Hi everyone,
I am working on my master's thesis using an Arduino Uno, but I am experiencing some difficulties as I am not very experienced with it. Specifically, I have four Hall sensors connected to a TLA2518 converter (SPI), which is in turn connected to the Arduino Uno using the following pins:
- SCL pin 13
- SDI pin 12
- SDO pin 11
- CS pin 10
I have also connected VD to V5 and GND to GND.
I am facing an issue where the readings on the serial monitor are always displaying as zeros when i use a magnet.
I am not sure if my code is correct, or if there is somethong wrong.
#include <SPI.h>
#define CS 10
void setup() {
// Initialize SPI communication
SPI.begin();
// Set the CS pin as an output
pinMode(CS, OUTPUT);
// Start serial communication
Serial.begin(9600);
}
void loop() {
// Select the first sensor
digitalWrite(CS, LOW);
// Send a command to read from the TLA2518
SPI.transfer(0b00001111);
// Read the data from the TLA2518
int msb = SPI.transfer(0x00);
int lsb = SPI.transfer(0x00);
int data = (msb << 8) | lsb;
// Deselect the TLA2518 converter
digitalWrite(CS, HIGH);
// Print the data to the serial monitor
Serial.println("Sensor 1: " + String(data));
// Select the second sensor
digitalWrite(CS, LOW);
// Send a command to read from the TLA2518
SPI.transfer(0b00011111);
// Read the data from the TLA2518
msb = SPI.transfer(0x00);
lsb = SPI.transfer(0x00);
data = (msb << 8) | lsb;
// Deselect the TLA2518 converter
digitalWrite(CS, HIGH);
// Print the data to the serial monitor
Serial.println("Sensor 2: " + String(data));
// Select the third sensor
digitalWrite(CS, LOW);
// Send a command to read from the TLA2518
SPI.transfer(0b00101111);
// Read the data from the TLA2518
msb = SPI.transfer(0x00);
lsb = SPI.transfer(0x00);
data = (msb << 8) | lsb;
// Deselect the TLA2518 converter
digitalWrite(CS, HIGH);
// Print the data to the serial monitor
Serial.println("Sensor 3: " + String(data));
// Select the fourth sensor
digitalWrite(CS, LOW);
// Send a command to read from the TLA2518
SPI.transfer(0b00111111);
// Read the data from the TLA2518
msb = SPI.transfer(0x00);
lsb = SPI.transfer(0x00);
data = (msb << 8) | lsb;
// Deselect the TLA2518 converter
digitalWrite(CS, HIGH);
// Print the data to the serial monitor
Serial.println("Sensor 4: " + String(data));
// Wait for a moment before sending another command
delay(1000);
}
there are link for Converter and hallsensor :
Converter TLA2518 :
Hallsensor:
https://www.mouser.de/datasheet/2/187/HWSC_S_A0012826248_1-3073340.pdf
The question is: why am I not getting any reaction from my sensor at serialmonitor ?