I am using a simple 0-25V DC voltage sensor (it's just a 30k and 7.5k resistor) and no matter what I try I'm getting a voltage reading that is about 8-9V less than what it should be.
This is the sensor:
I have tried using an external reference voltage but the result was the same.
Device is a LoRa32u4. I am using nearly every pin. Details on what else is attached at the bottom of the email. There is one other analog (water level) sensor connected but I've tried disconnecting it and the result was the same.
Power source (currently a 19v DC adapter but will be a LiPo battery in final project - the reason I need a sensor) is wired to the GND/VCC pins. The power is also attached to a pair of step down converters (one is converting to 12V the other to 5V) which are powering sensors and motors.
The sensor is connected to the LoRa32_u4:
signal pin on sensor to an analog pin
ground to Arduino ground pin
Multimeter reads:
19.2v on the sensors GND/VCC pins
0.17v on the signal / - pins
Arduino reads:
IN: 10.84
OUT: 2.17
Pin Value: 444
I'm not sure what else to try / check so any advice on would be greatly appreciated.
Here is the code I'm currently using. I'd post all the code but I'm a professional programmer and this project was a little too complicated to put all my code in one sketch so I've got about a dozen classes I created for this project I'd have to post too. I'm happy to do that if need be.
3 H-bridge motor drivers, using 3 analog pins and 6 digital pins - attached to external 5V power for board power and (external) 12V for the motors (which are not yet attached)
Relay - using an analog pin because I was out of digital pins
XY5300 Audio player (uses TX/RX pins 0/1) - powered off 5V external
Amplifier - powered off 5V external
Addressable LED strip (WS2812B) - using one digital pin, powered of 5V external
Servo controller - using SDL/SDA pins, powered off 5V external
Water level sensor - using 1 analog pin, powered off 5V external - tried disconnecting this - no change
Ok, I've got to lay this out nicely on a table to take a good picture that will be useful. There are a lot of wires. I will do that ASAP.
I'm assuming that by "be very, very, very concerned about common ground" you mean that everything should share a common ground. I will double check everything but that should be the case.
Can you please elaborate about applying a negative voltage? I'm not new to electronics but I'm not an expert either and I am not following how negative voltage would come in to play here.
I suspected the likely culprit might be a grounding issue. I'll recheck everything. Thank you for your help! I'll report back. If I still have trouble I'll post a good pic of all of the wiring.
Hi,
Have you got code that JUST reads the sensor, nothing else?
If so then please post this code and tell us what it reads.
Did you write your code in stages?
If so you should have some code already that JUST reads the sensor?
Have you got just the sensor connected and nothing else to prove your circuit?
Can you post a circuit diagram showing how you have the sensor connected to the Lora Controller?
The seller gives a test sketch - try it - just the uC and the sensor without anything else connected.
Too often we can get lost in the bigger project and stumble with the simple stuff.
If that sensor is just a voltage divider , why are you measuring voltage with it , then using the same value resistors to DIVIDE it down again in software ??? Doh !
To get the original voltage multiply by (R1+R2)/R1
Or better still use the “map” function and calibrate your input .