Hello,
I am working on a thermoelectric module. The hot and cold sides of the device have a thermistor, which then have analog pickoffs to read their voltage with analogRead. Using manufacturer formulas I can then get temperatures and display them on a screen. This part works, and I am receiving reasonable values.
I also want to display output voltage of the thermoelectric unit on the screen, but the analogRead function seems to be faulty here. The values are random and nowhere near the actual value. I have copied the code to show what I did.
//Include library
#include <Arduino.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
//Define OLED dimensions
#define SCREEN_WIDTH 128
#define SCREEN_HEIGHT 64
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, -1);
//Define constants
int R = 2200.; //Nominal resistance of fixed resistor
int Vs = 5.; //Supply voltage
//Assigning analog pins
int Analog0 = A0;
int Analog1 = A1;
int Analog2 = A2;
//Thermistor properties
int amphenolPropsBeta = 3435.;
int amphenolPropsR0H = 10000.; //Nominal resistance of hot side thermistor
int amphenolPropsR0C = 11350.; //Nominal resistance of cold side thermistor
float amphenolPropsT0 = 298.15; //Room temperature in Kelvin
void setup() {
//Declare inputs
pinMode(Analog0,INPUT);
pinMode(Analog1,INPUT);
pinMode(Analog2,INPUT);
Serial.begin(15200);
if(!display.begin(SSD1306_SWITCHCAPVCC,0x3C)){
Serial.println(F("SSD1306 allocation failed"));
for(;;);
}
delay(2000);
display.clearDisplay();
display.setTextSize(1);
display.setTextColor(WHITE);
}
void loop() {
//Hot side temperature readings
int readValue0 = analogRead(Analog0);
float VT0 = (5./1023.)*readValue0;
float I0 = (Vs-VT0)/R;
float Rth0 = VT0/I0;
float TT0 = 1./((1./amphenolPropsT0)+(log(Rth0/amphenolPropsR0H)/amphenolPropsBeta));
float TC0 = TT0-273.15;
float TF0 = TC0*9./5.+32.;
//Cold side temperature readings
int readValue1 = analogRead(Analog1);
float VT1 = (5./1023.)*readValue1;
float I1 = (Vs-VT1)/R;
float Rth1 = VT1/I1;
float TT1 = 1./((1./amphenolPropsT0)+(log(Rth1/amphenolPropsR0C)/amphenolPropsBeta));
float TC1 = TT1-273.15;
float TF1 = TC1*9./5.+32.;
//Peltier output voltage readings
int readValue2 = analogRead(Analog2);
float VP = (5./1023.)*readValue2;
display.clearDisplay();
//Display hot side temprature
display.setCursor(0,10);
display.println((String)"Hot side: "+TF0+" F");
display.display();
//Display cold side temperature
display.setCursor(0,20);
display.println((String)"Cold side: "+TF1+" F");
display.display();
//Display peltier device output voltage
display.setCursor(0,30);
display.println((String)"Peltier: "+VP+" V");
display.display();
delay(500);
}
A handheld DMM measures the output voltage of the module to steadily sit at a value between 0.1 and 0.5V (depending on the temperature difference across the module), however the Arduino outputs randomly move around between 0 to 5V.
I will also provide schematic of how the voltage is read.
Can somebody explain why the values are like this?