Go Down

Topic: Reading 5v analogue sensor (Read 949 times) previous topic - next topic

Jimster

I have a sensor which outputs  0-5v analogue output.
I've noticed that when the sensor has an output of 4v, and I do a analogRead(A3) it returns 1023.

I was expecting to see a figure of 800.

This is the code I used to test the sensor:
Code: [Select]
void setup() {
  Serial.begin(57600);
}
void loop() {
  Serial.println(analogRead(A3));
  delay(50);
}


Would you expect to get a value over 1000 or around 800 back?

Thanks

Jim

CrossRoads

What is your system? Standard Uno running from 5V?
Nothing connected to Aref pin?
Do you have all grounds connected?

I would expect a reading of ~Vin/.00488.
So 4V = ~819
Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

Jimster

I'm just using an atmega 328 on a breadboard, there is nothing connected to pin21 Aref, is this where I've gone wrong?

retrolefty


I'm just using an atmega 328 on a breadboard, there is nothing connected to pin21 Aref, is this where I've gone wrong?


No, nothing should wire to the pin unless you are using a analogReference(EXTERNAL) command in your sketch. Some recommend wiring a .1 ufd cap from Aref pin to ground for added noise filtering.

Check all your wiring between sensor and arduino board. A link to your sensor might be useful.
Also check your breadboard wiring and be sure you are using proper bypass capacitors on the AVR Vcc and Avcc pins.
Lefty

Jimster

The sensor is a load cell, I've also replicated the problem using a diode between 5v and analogue input 3. When tested with a digital multi meter it shows around 4.2v but stil 1023 on the serial monitor. There is nothing else in my code, the complete code is above.

Go Up