I need the following help using an ADC 1015.
I want to read the Thermistor with the ADC, but for some reason I can't seem to get it right.
If i connect it directly without the ADC I can read nearly identical temperature with the TMP36 component, but if I connect it through the ADC I get different results.
I use the TMP36 as a reference so I can compare how it is, if I'm reading correctly.
Even though when I tried reading it with a Digital Multimeter the voltage was 2.223 V
Also why do I get something on the other pins of the ADC, shouldn't they be 0, as nothing is connected to them?
Code: Select all
TMP36
0.78 volts
28.12 degrees C
82.62 degrees F
ADC 12bit Thermistor
755 ADC
1843.71 R
0.92 V
Temperature 68.62 *C
Get ADC Analog Lines
AIN0: 753
AIN1: 331
AIN2: 306
AIN3: 286
Code: Select all
#include <Wire.h>
#include <Adafruit_ADS1015.h>
Adafruit_ADS1015 ads;
// resistance at 25 degrees C
#define THERMISTORNOMINAL 10000
// temp. for nominal resistance (almost always 25 C)
#define TEMPERATURENOMINAL 25
// The beta coefficient of the thermistor (usually 3000-4000)
#define BCOEFFICIENT 3950
// the value of the 'other' resistor
#define SERIESRESISTOR 10000
const double refVoltag = 5.0;
const double adcMax = 4096.0;
void setup() {
Serial.begin(57600);
Serial.println();
ads.begin();
}
void loop() {
Serial.println();
Serial.println("TMP36");
uint16_t 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");
Serial.println();
Serial.println("ADC 12bit Thermistor");
uint16_t adcValue = ads.readADC_SingleEnded(0);
Serial.print(adcValue);
Serial.println(" ADC");
double R = adcValue;
R = (adcMax - 1) / R;
R = 10000.0 / R;
Serial.print(R);
Serial.println(" R");
double V = adcValue * 5 / (adcMax - 1) ;
Serial.print(V);
Serial.println(" V");
float steinhart;
steinhart = R / THERMISTORNOMINAL; // (R/Ro)
steinhart = log(steinhart); // ln(R/Ro)
steinhart /= BCOEFFICIENT; // 1/B * ln(R/Ro)
steinhart += 1.0 / (TEMPERATURENOMINAL + 273.15); // + (1/To)
steinhart = 1.0 / steinhart; // Invert
steinhart -= 273.15; // convert to C
Serial.print("Temperature ");
Serial.print(steinhart);
Serial.println(" *C");
Serial.println();
Serial.println();
Serial.println("Get ADC Analog Lines");
int16_t adc0, adc1, adc2, adc3;
adc0 = ads.readADC_SingleEnded(0);
adc1 = ads.readADC_SingleEnded(1);
adc2 = ads.readADC_SingleEnded(2);
adc3 = ads.readADC_SingleEnded(3);
Serial.print("AIN0: "); Serial.println(adc0);
Serial.print("AIN1: "); Serial.println(adc1);
Serial.print("AIN2: "); Serial.println(adc2);
Serial.print("AIN3: "); Serial.println(adc3);
Serial.println(" ");
delay(5000);
}