/START
// Display on I2C - initialize
#include <Wire.h>;
#include <LiquidCrystal_PCF8574.h>
LiquidCrystal_PCF8574 led(0x3F); // set the LCD address to 0x3F for a 16 chars and 2 line display
//Variables section
//a) Senzor Variables
int sensorPin; // declare int the PIN to which the sensor is conected
int SensVal; //declare int the variable to store the values from senzor
float Voltage; // declare float the voltage between the sensor sends
float tempC; //declare float the temperature
// TMP36 temp sensor output connected to analogue input A0, 3.3volt and ground
unsigned int total; // A/D readings
void setup()
{
//Initialize LCD display
Wire.begin();
led.begin(16, 2); // initialize the lcd
led.clear();
led.setBacklight(1); //apparentely, my display can be only on for >0 or of =0
led.setCursor(0,0);
led.print("Start measuruing");
delay (5000);
//End LCD display initialization
//Start serial
Serial.begin(9600); // open the serial communication
//End serial
//Set sensors
sensorPin=A0; //state the PIN to which the sensor is connected
analogReference(INTERNAL); // use the internal ~1.1volt Aref | change to (INTERNAL1V1) for a Mega
//End set sensor
}
void loop(){
/// MODULE 1: Read and serial monitor sensor's values
total = 0; // reset total
for (int x = 0; x < 64; x++) { // 64(max) analogue readings for averaging
total += analogRead(A0); // add each value
}
tempC = total * 0.0013600 - 50.0; // Calibrate temp by changing the last digit(s) of 0.001632
Serial.print("The temperature is ");
Serial.print(tempC, 1); // one decimal place
Serial.print(" Celsius ");
delay(1000); // use a non-blocking delay when combined with other code
/// END MODULE 1: Read and serial monitor sensor's value
/// MODULE 3: Display the temperature on LCD
{
led.clear();
led.setCursor (0,0);
led.print ("temperature:");
led.setCursor (0,1);
led.print (tempC);
led.print (" Deg Celsius");
}
/// END MODULE 3
}
//END
====
This code returned a non-movable 56.8 value when sensor is connected to 3.3 V and a highly variable value (some 4 Degrees+-, which also decrease in a matter of minutes) when connected to 5 V. When I removed the jumper of the LCD thus putting backlight off, the temperature decreased by some 2 degrees - as the serial told me.
When I put my finger on the sensor, the temperature rises by some 3-4 degrees.
Eventually, after some 5 minutes and repeated modifications, the temperature value got stability and the reading appears to be correct. But, a big "but" when I pick the display in my hand the temperature rises by 3 degrees. I took the jumper off and the temperature decreases suddenly by 5 degrees.
The board is connected to 5 V USB from a PC desktop.
===
Question:
Did I mistakenly modify something in the code?
Or perhaps a conventional ground is needed (e.g. to the third wire of the network or to earth)?
I may also think that it just impossible to really measure the temperature by this type of sensor.
Thank you!