Hall sensors / Arduino Nano PCB problems

Hi there!

I am having some issues with a circuit I made to display the gear of my transmission in my car onto an 8x8 max 7219 matrix. To detect the position of the gearstick I am using 4 hall sensor modules connnected to an arduino nano. The sensors recieve 5V and pull a signal pin to ground whenever a magnetic field is detected. I have also wired up everything onto a PCB:
Wiring diagram:

The PCB from the top and bottom

I made the PCB just for securing the arduino and having tidy wiring. It was easier to make large GND and 5V connections (/ "rails") than soldering a bunch of wires together. I also checked for shorts in the PCB multiple times. If there are flaw in my desing please comment, this is the firs time Im doing this.

Now I am having multiple issues:

  1. Sensor 1 is beeing activated randomly.
  2. If i activate Sensor 3, the lights of seonsors 2 and 4 are also dimmly glowing (--> they activate).
  3. These problems seem to happen, even with the sonsors disconnected, so it has to be the PCB assembly.

I have also switched the seonsors around many times, so they shouldn't be the problem.
Since the sensors activate when pulled to GND, I had the idea that there is not enough power beeing supplied to the sensors. Since Sensor 4 is the las one on the 5V rail, maybe it doesn't recieve enough current and if sensor 2 is beeing activated it "steals" the power from the other ones ... ??

I have noticed these issues before, but thought I dealt with them by adding the pullup resistor on the signal pins for the hall sensors into the code. Then it worked for a while, but the problems are back now.
This is my code:

#include <LedControl.h> 

int DIN_PIN = 10; 
int CS_PIN = 9;
int CLK_PIN = 8;

LedControl lc = LedControl(DIN_PIN, CLK_PIN, CS_PIN, 1);

void setup() {
  // Initialize the MAX7219 module
  lc.shutdown(0, false); // Turn on the display
  lc.setIntensity(0, 15); // Set the brightness to 15 (0-15)
  lc.clearDisplay(0); // Clear the display

 /*  Serial.begin(9600); */
  pinMode(2, INPUT_PULLUP); /* Sensor left */
  pinMode(3, INPUT_PULLUP); /* Sensor top */
  pinMode(4, INPUT_PULLUP); /* Sensor right */
  pinMode(5, INPUT_PULLUP); /* Sensor bottom */
  
}

/* byte ersterGang[8] = {
  B00001000,
  B00011000,
  B00001000,
  B00001000,
  B00001000,
  B00001000,
  B00001000,
  B00011100
};

byte zweiterGang[8] = {
  B00111100,
  B01000010,
  B00000010,
  B00000010,
  B00011100,
  B00100000,
  B01000000,
  B01111110
};

byte dritterGang[8] = {
  B00111100,
  B01000010,
  B00000010,
  B00011100,
  B00000010,
  B00000010,
  B01000010,
  B00111100
};

byte vierterGang[8] = {
  B00000100,
  B00001100,
  B00010100,
  B00100100,
  B01000100,
  B01111110,
  B00000100,
  B00000100
};

byte fuenfterGang[8] = {
  B01111110,
  B01000000,
  B01000000,
  B01111100,
  B00000010,
  B00000010,
  B01000010,
  B00111100
};

byte hintenGang[8] = {
  B01111100,
  B01000010,
  B01000010,
  B01111100,
  B01010000,
  B01001000,
  B01000100,
  B01000010
};

byte neutralGang[8] = {
  B01000010,
  B01100010,
  B01010010,
  B01010010,
  B01001010,
  B01001010,
  B01000110,
  B01000010
}; */

byte firstGear[8] = {
  B00000000,
  B00000000,
  B00000000,
  B10000010,
  B11111111,
  B10000000,
  B00000000,
  B00000000
};

byte secondGear[8] = {
  B00000000,
  B11000010,
  B10100001,
  B10010001,
  B10010001,
  B10010001,
  B10001110,
  B00000000
};

byte thirdGear[8] = {
  B00000000,
  B01000010,
  B10000001,
  B10001001,
  B10001001,
  B10001001,
  B01110110,
  B00000000
};

byte fourthGear[8] = {
  B00000000,
  B00110000,
  B00101000,
  B00100100,
  B00100010,
  B11111111,
  B00100000,
  B00000000
};

byte fithGear[8] = {
  B00000000,
  B01001111,
  B10001001,
  B10001001,
  B10001001,
  B10001001,
  B01110001,
  B00000000
};

byte reverseGear[8] = {
  B00000000,
  B11111111,
  B00001001,
  B00011001,
  B00101001,
  B01001001,
  B10000110,
  B00000000
};

byte neutralGear[8] = {
  B00000000,
  B11111111,
  B00000010,
  B00001100,
  B00110000,
  B01000000,
  B11111111,
  B00000000
}; 
 
void loop() {
  // Display the character on the LED matrix
  if(digitalRead(2) == 0 && digitalRead(3) == 0){
    for (int i = 0; i < 8; i++) {
    lc.setRow(0, i, firstGear[i]);
    }
  }else if(digitalRead(2) == 0 && digitalRead(5) == 0){
    for (int i = 0; i < 8; i++) {
    lc.setRow(0, i, secondGear[i]);
    }
  }else if(digitalRead(2) == 1 && digitalRead(4) == 1 && digitalRead(3) == 0){
    for (int i = 0; i < 8; i++) {
    lc.setRow(0, i, thirdGear[i]);
    }
  }else if(digitalRead(2) == 1 && digitalRead(4) == 1 && digitalRead(5) == 0){
    for (int i = 0; i < 8; i++) {
    lc.setRow(0, i, fourthGear[i]);
    }
  }else if(digitalRead(4) == 0 && digitalRead(3) == 0){
    for (int i = 0; i < 8; i++) {
    lc.setRow(0, i, fithGear[i]);
    }
  }else if(digitalRead(4) == 0 && digitalRead(5) == 0){
    for (int i = 0; i < 8; i++) {
    lc.setRow(0, i, reverseGear[i]);
    }
  }else{
    for (int i = 0; i < 8; i++) {
    lc.setRow(0, i, neutralGear[i]);
    }
  }

  // Clear the display
  lc.clearDisplay(0);
}

I would really apreciate any help here, since I am out of ideas. Feel free to ask questions if they help the troubbleshooting process.

I dont see the hall sensors in the image, I am assuming they are else where and the wires coming into your general purpose board are from each sensor. Looks like you have twisted all these long wires and they are coupling into each other, we call this capacitive coupling (in your words "stealing power"), long wires do that when current flows through them.

Try connecting 5V and GND of all sensors together close to where the sensors are placed and bring out only one lengthy wire per signal, So on the board you'd have 5V, GND, Signal_Sensor_1, Signal_Sensor_2, Signal_Sensor_3, Signal_Sensor_4. Do not twist these wires. Depending on the amount of current flowing through them you might need to use shielded cables instead (unlikely cause I predict the current wont amount to much)

I have twisted the wires going to the matrix together, but the wires of the sensors were untwisted. Here is a picutre showing the full assembly:


Since the sensors and the matrix have to go into opposite directions (the matrix to the dasboard and the seonsors to the gearlever) I cant combine their power wires and because the sensors have to be placed around the gearstick seperately I cant really combine their power wires either. This is what im trying to make:

The problems are very random and have increased in the bit of testing I did since you posted your awnser. If I activate any one of the sensors, all of them lose power / activate. I think I figured out why some sensors would activate randomly (it was the soldering on the pcb creating mini-shorts) but the power problem remains (if it actually is just a power problem). Are there any other ways my circuit could be improved? I am using solid 22 awg wire - should I be using something else? Or is an external power source nesecarry? Since I am building this for a car I could try to find and use an onboard 5V output.

Have you tried just running the four sensors, sending status to Serial Monitor? Your Arduino is not likely to power the 7219 display for long(you intend to use the Car's 12V as source, correct?), the regulator will overheat and shutdown or die.

Also, be aware you may want to protect your Arduino, as auto system voltages are normally subject to significant noise, and I don't believe the regulator of an Arduino has been designed with that environment in mind.

I have not used serial monitor yet, because the hall sensor modules have an integrated led which already indicate their output. But I could try diconnecting the matrix and just use the sensors next. Maybe the matrix draws too much power?
I have already encountered the issues with the onboard regulator and am now supplying power via the usb port via an external voltage regulator. This thing:
image
But this is irellevant for now because I can't even get to the stage of implementing it into a car because I am having these troubles with normal usb power...

Copper will work harden and break when vibrated. That means the movement of the solid wire will flex and eventually crack open. Always use stranded wire in automotive wiring. Stranded is twisted and vibration does not bother it.

1 Like

USB will likely mean you'll get away with it, until such time as you don't. But I'd de-emphasize that angle for now. Something's wrong with your wiring for sure, if a simple sensor state change causes other sensors to change in any way.

What is the source of 5 volts? How much current can it supply? In a noisy automotive environment, you may need stronger pullups for the HESs (10k), maybe a little lower but not less than 5k.

More solder on those connections.

Another possible problem with Nano powered with USB is the built in reverse polarity protection diode which will drop USB 5V to about 4.6 ~ 4.7V and can only pass about 600mA (on the cheap clones).

Thanks for the replies!
I think I am going to rebuild this on a breadboard with the cables I used and try to recreate the issues. Then I can single out the problems - switch out components and cables etc and get more information on what could be the problem. Any other advice on the topic will be appreciated.

Ok so it's been a while, but I have finally come around to try and complete this project.
I have made a short video showing the basic issue which I believe is causing all of this.

In the video you can see a hall sensor wired up to power of an arduino nano on a breadboard. Firstly I have the signal pin disconected, and the hall sensor is working, just like it should. But after conecting the Signal Pin of the Hall sensor, it starts to activate slightly (red led starts to glow). I have tried diffrent pins and sensors so far. I have also tried an INPUT_PULLUP in software. Nothing differed. It seems like a simple issue jet I am absolutely clueless to what it could be. Any help is appreciated.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.