0
votes

What is going on is that no matter what type of sensor I put onto my Arduino Elegoo R3 board, my values are read wrong.

What's happening:

Analog Temperature Sensor - Reads 400+ Celsius

Flame Detection Sensor - Reads either 0, 1023 (dig) or 0, 1 (analog) no in between based on distance of flame.

Details: Board - Elegoo Uno R3

Breadboard

Sensors are from the Elegoo 37-sensor kit - https://github.com/josejuansanchez/37-in-1-arduino-sensor-kit

Basic Code:

void setup() {
  // put your setup code here, to run once:
  Serial.begin(9600);
  pinMode(A0, INPUT);
}

void loop() {
  int reading = analogRead(A0);  

 // converting that reading to voltage, for 3.3v arduino use 3.3
 float voltage = reading * 5.0;
 voltage /= 1024.0; 

 // print out the voltage
 Serial.print(voltage); Serial.println(" volts");

 // now print out the temperature
 float temperatureC = (voltage - 0.5) * 100 ;  //converting from 10 mv per degree wit 500 mV offset
                                               //to degrees ((voltage - 500mV) times 100)
 Serial.print(temperatureC); Serial.println(" degrees C");

 // now convert to Fahrenheit
 float temperatureF = (temperatureC * 9.0 / 5.0) + 32.0;
 Serial.print(temperatureF); Serial.println(" degrees F");

 delay(1000);     
}

I've tried other sensors and have a similar issue.

This leads me to believe that I am doing something wrong with wiring. However, there is a photo available showing pin connections and I am wired exactly as shown in the photo using a breadboard

A tutorial I found here is exactly how I setup my board for the Flame Detection: http://www.instructables.com/id/Arduino-Modules-Flame-Sensor/

What am I or this tutorial missing that would cause sensor readings to be wrong?

3
For your ADC - dont you need start conversion signal for the ADC? can you give code for analogRead(A0); Also what is exact controller in your starter kit?Sudhee

3 Answers

2
votes

One thing to try is a "reality check": Connect a known positive voltage to A0 with the other side to ground. A known-good 1.5V battery should be fine... it should return a reading of about 1024 * 1.5 / 5 = 307. If so, you know your Uno and code are OK; if not, check your sensor and wiring again.

Another simple test is to use a multimeter (one of those Harbor Freight jobs that they often give away for free is fine), and measure the sensor output voltage with and without the flame.

1
votes

Assuming Elegoo Uno R3 uses atmega328, here is one example code for ADC. Usually reading sensors involves conecting the sensor to one of the analog channel on the controller (if the controller has built in ADC). Then you need to configure the ADC in the controller. Once configuration done, then for reading the channel, you need to give signal to start the conversion (basically at that instant what is the analog value and convert into digital value) and wait for the conversion to complete. Then you can read the digital value from the ADC register of the controller. A example for atmega328 in following link

Example code

In flame sensor that you mentioned, A0 analog signal that you need to connect any analog channel of the Adreno board. D0 is a digital channel that will only give you 0 or 1 depending on whether temperature is reaches certain threshold or not.

0
votes

I took your exact code, and downloaded it to an Arduino.

By plugging in a jumper from A0 to GND, 3.3V and 5V, it seems your code is working correctly, because the correct values appear for voltage.

BTW, you don't need the 'pinMode(A0, INPUT)' line in your setup() routine.

If this setup doesn't work, then it could mean channel A0 is messed up. The reality check suggested by Boggyman is what you need, and the Arduino board can supply three of those values easily. By the way, these are analog inputs, not outputs; the title of your post is technically incorrect.

0.00 volts
-50.00 degrees C
-58.00 degrees F
3.33 volts
282.52 degrees C
540.54 degrees F
5.00 volts
449.51 degrees C
841.12 degrees F
5.00 volts