MEGA 2560 R3
I have a temp probe (non-arduino) that shows the temp 78F on an old weather station LCD display, and it works fine. I want to also show the temp on a large LCD of my own.
I exposed the data and ground wires from the probe bundle. I connected data to A6 and ground to arduino grd. I also hooked my digital VM to the same two wires. It shows a very consistent 0.832v at 78F.
95F 0.62v
90F 0.68v
78F 0.83v
60F 1.09v
34F 1.56v
34 to 95 is all the range I need.
Being that A6 uses a 5v ref voltage, I would expect to see something on the order of 170 when I Serial.println(analogRead(A6); .83/5v * 1024. But instead I get values around 300.
My large LCD works fine and shows a temperature, just not the right one. My room temp is 78F, shown on two independent thermometers, so i know that is right. The large LCD shows 87F.
As nearly as I can tell, there are two issues. One, why am I not reading the correct analogin value, and two; how can i map something like this. The voltages drop as temp increases.
at an earlier time i had used the INTERNAL2v56 command or statement in an effort to help with mapping, but it did not. Although I removed it and now include analogReference(DEFAULT); in the setup, I am wondering if i used the previous command wrong and set a fuse or something.
For now I am setting the mapping issue aside and concentrating on why I am not getting the correct voltages from analogRead.
Any thoughts or suggestions ? attached is an image of a portion of the Serial print.
#include <Adafruit_GFX.h> // Core graphics library
#include <MCUFRIEND_kbv.h> // Hardware-specific library
MCUFRIEND_kbv tft;
#include <FreeDefaultFonts.h>
#define BLACK 0x0000 // U16 definition
#define RED 0xF800
#define GREEN 0x07E0
#define DARKGREEN 0x0408
#define WHITE 0xFFFF
#define GREY 0x8410
#define YELLOW 0xFFE0
#define BLUE 0x001F
#define ORANGE 0xFBE0
#define LIGHTCYAN 0x87FF
#define PINK 0xF81F
int temp;
void setup(void)
{
analogReference(DEFAULT);
pinMode(A6,INPUT);
Serial.begin(9600);
tft.begin(0x9486);
tft.setRotation(1);
tft.fillScreen(BLACK);
}
void loop(void)
{
int i =0;
float subSensor = 0;
for(int i = 1; i<10; i=i+1){
delay(1000);
float sensorValue = analogRead(A6);
Serial.println(i);
Serial.println(sensorValue);
Serial.println("");
subSensor = subSensor + sensorValue;
}
float Atemp;
Serial.println(subSensor);
Atemp=subSensor/9;
Serial.println(Atemp);
temp = map(Atemp,150, 578, 90, 62); //
Serial.print("Temp = ");
Serial.println(temp);
Serial.println("");
i=1;
}



