Go Down

Topic: Temperature Web Panel doesn't run for me (Read 12318 times) previous topic - next topic

federicofissore

We did and do our best, but we are humans: allowing you to easily make complex things is not easy. Suggestions are more than welcome.

avenue33

#31
Apr 13, 2015, 12:55 pm Last Edit: Apr 13, 2015, 01:00 pm by avenue33
Thank you for the hints and tips. :)

They've helped me getting this sketch working!

More information on the index.html file is provided by the Arduino Scuola and available at Sensor Values to HTML Page.

Code: [Select]
<!DOCTYPE html>
<head>
    <script type="text/javascript" src="zepto.min.js"></script>
    <script type="text/javascript">
        function refresh() {
            $('#content').load('/arduino/temperature');
        }
    </script>
</head>
<body onload="setInterval(refresh, 1000);">
    <span id="content">Waiting for Arduino...</span>
</body>

choepie

Dears,

I have it working but the reading is wrong...
I have the tmp36 A0-A1-A2 like the script asks, A0 = high, A1 analog read and A2 low.
It tells me it is -14 degrees celcius... (it must be around 25 now)

This is my output (I added some debug) :

Code: [Select]
debug info (voltage) : 351.56
debug info (sensorValue) : 72
Current time on the Yún: Fri Jul 24 17:42:46 CEST 2015
Current temperature: -14.84 °C
This sketch has been running since Fri Jul 24 17:40:09 CEST 2015


I swapped sensors already thinking it might be failing sensor.
I also used a breadboard linking directly to Ground & 5v.
This gave a small difference :

Code: [Select]
debug info (voltage) : 263.67
debug info (sensorvalue) : 54
Current time on the Yún: Fri Jul 24 17:54:33 CEST 2015
Current temperature: -23.63 °C
This sketch has been running since Fri Jul 24 16:57:18 CEST 2015


Any idea ?
I couldn't measure the voltages, but maybe the powersupply isn't stable ?



sonnyyu

#33
Jul 25, 2015, 01:58 am Last Edit: Jul 25, 2015, 01:58 am by sonnyyu
The Yun has hardware bug 5.0V is not stable (~4.5V)
For correct results, using the 3.3v reference voltage as ARef instead of the messy 5V will be more precise and less noisy

ATmega32u4  code:

Code: [Select]
int sensorPin = 0;
void setup()
{
  Serial.begin(9600);
   // If you want to set the aref to something other than 5v
  analogReference(EXTERNAL);                      
}
void loop()                     // run over and over again
{
 int reading = analogRead(sensorPin);  
 float voltage = reading * 3.3;
 voltage /= 1024.0;
 Serial.print(voltage); Serial.println(" volts");  // print out the voltage
 delay(1000);                                     //waiting a second
}


the resolution is 10 mV / degree centigrade with a 500 mV offset to allow for negative temperatures




choepie

#34
Jul 27, 2015, 10:06 am Last Edit: Jul 27, 2015, 11:31 am by choepie
Hello Sonnyyu,
This gives indeed a lot more stable reading.
But still off..

Code: [Select]

debug info (sensorvalue) : 78
debug info (voltage) : 0.25

Current time on the Yún: Mon Jul 27 09:59:17 CEST 2015
Current temperature: -49.97 °C
This sketch has been running since Mon Jul 27 09:54:51 CEST 2015


Do I convert this correct ?
"the resolution is 10 mV / degree centigrade with a 500 mV offset to allow for negative temperatures"
--> float temperature = (voltage - 500.0f) / 10.0f;

Just to avoid confusion : I swapped tmp36 several times (Have 4 of them around) and I also changed the Analog readout from 1 to 0, it makes no difference. I still says around -49,97 while it should be around 23 ~ 25-isch Celcius.

choepie

it works !

it's an LM35 instead of TMP36 :

float temperature = voltage * 100;

Sorry for the trouble i should have double checked.

Go Up