Hi all,
I have a Sparkfun ESP8266 Thing Dev board and a TMP36 sensor from the Arduino Starter Kit. I have made the project Love-O-Meter project 3 from the Projects Book with the Genuino Uno board, and now i want to do the same with the Sparkfun board. I have connected the TMP36 sensor and hooked up 2 LEDs. But i’m getting some weird readings on the Sparkfun board. On the Uno board i am reading the correct values, but the ESP8266 board is reading some really high values.
I have hooked the sensor to the 5V pin and GND, and the middle pin to the ADC/A0 analog pin.
My code is and this works on the Uno.
const int sensorPin = A0;
const int LEDRedPin = 12;
const int LEDGreenPin = 14;
const int baseTemp = 25;
void setup() {
pinMode(LEDRedPin, OUTPUT);
pinMode(LEDGreenPin, OUTPUT);
Serial.begin(9600);
}
void loop() {
int sensorVal = analogRead(sensorPin);
Serial.print("Sensor Val: ");
Serial.print(sensorVal);
float voltage = (sensorVal/1024.0) * 5.0;
Serial.print(", voltage: ");
Serial.print(voltage);
float temperature = (voltage - .5) * 100;
Serial.print(", temperature: ");
Serial.println(temperature);
if (temperature > baseTemp) {
digitalWrite(LEDRedPin, HIGH);
digitalWrite(LEDGreenPin, LOW);
} else {
digitalWrite(LEDRedPin, LOW);
digitalWrite(LEDGreenPin, HIGH);
}
delay(1000);
}
Is there something speciel about the ESP8266 board and the analog input?
Kind regards
Steffen