I have a working code - with Geekcreit board - to use 2-wire thermometer in my project, but I need wifi shield to complete this. I have Wemos D1 and few Minis for this, but they do not have AREF pin marked, which I need. Or do I? Have not find answer for this one, that makes me think solution is easier than I think....
How to change code below to make it work with Wemos D1 (& mini)?
Thanks.
-Jari-
// thermistor-2.ino Intermediate test program for a thermistor. Adafruit Learning System Tutorial
// https://learn.adafruit.com/thermistor/using-a-thermistor by Limor Fried, Adafruit Industries
// MIT License - please keep attribution and please consider buying parts from Adafruit
// which analog pin to connect
#define THERMISTORPIN A0
// how many samples to take and average, more takes longer
// but is more 'smooth'
#define NUMSAMPLES 5
// the value of the 'other' resistor
#define SERIESRESISTOR 10000
int samples[NUMSAMPLES];
void setup(void) {
Serial.begin(9600);
// connect AREF to 3.3V and use that as VCC, less noisy!
analogReference(EXTERNAL);
}
void loop(void) {
uint8_t i;
float average;
// take N samples in a row, with a slight delay
for (i=0; i< NUMSAMPLES; i++) {
samples[i] = analogRead(THERMISTORPIN);
delay(10);
}
// average all the samples out
average = 0;
for (i=0; i< NUMSAMPLES; i++) {
average += samples[i];
}
average /= NUMSAMPLES;
Serial.print("Average analog reading ");
Serial.println(average);
// convert the value to resistance
average = 1023 / average - 1;
average = SERIESRESISTOR / average;
Serial.print("Thermistor resistance ");
Serial.println(average);
delay(1000);
}
The ESP8266 has 1 analog input and it will measure 0 to 1V only. There is no Aref pin and there is no way, that I know of, to use an external reference. You may need to use an external ADC connected through I2C or SPI.
I maybe could live without less accuracy by this code, but not working, while it works with Geekcreit.
Could you please explain why or what to do to make this work?
Gives constat readin, 1023 on Wemos, works with Geekcreit???
// thermistor-1.ino Simple test program for a thermistor for Adafruit Learning System
// https://learn.adafruit.com/thermistor/using-a-thermistor by Limor Fried, Adafruit Industries
// MIT License - please keep attribution and consider buying parts from Adafruit
// the value of the 'other' resistor
#define SERIESRESISTOR 10000
// What pin to connect the sensor to
#define THERMISTORPIN A0
void setup(void) {
Serial.begin(9600);
}
void loop(void) {
float reading;
reading = analogRead(THERMISTORPIN);
Serial.print("Analog reading ");
Serial.println(reading);
// convert the value to resistance
reading = (1023 / reading) - 1; // (1023/ADC - 1)
reading = SERIESRESISTOR / reading; // 10K / (1023/ADC - 1)
Serial.print("Thermistor resistance ");
Serial.println(reading);
delay(1000);
}
Do you need to use a thermistor? There are plenty of cheaply available digital temp sensors that are a bit more "this century", and don't need an AREF pin or even an analog input.
PaulRB:
Do you need to use a thermistor? There are plenty of cheaply available digital temp sensors that are a bit more "this century", and don't need an AREF pin or even an analog input.
Well, yes I do. I'm planning to use 2-wire thermistor from the other unit I own. This has sharp "stick sensor" which has heat resistance wire, 3.5mm 2-pole audio plug in other end. It's the cooking alarm clock (sorry my english, hope you understand :). I would like to use it with wemos to get notification to my phone when meat in oven is ready.
I do have some DHT-11 and -22 units, if you meant them. Obviously can't use them within this project.
If you have some kind of solution for this project, I'm happy to hear it.
That page shows an Uno, not a Wemos. Even the Wemos D1 is not quite the same as an Uno, the D1 mini is very different. Plus there are several wiring suggestions on that page: 5V, 3.3V, AREF etc. So that link does not help us understand how you wired your Wemos, do you see?
I'll take a guess. You are using the 5V pin on the Wemos to connect the thermistor/10K. Try the 3.3V pin.