I'm new to this forum.
I just got a NodeMCU (ESP-12E) and am programming it with the Arduino IDE.
The module reads analogue data and sends it to thingspeak without problem. However when I try and add a DS18B20 onewire sensor to a digital pin I get an error at compile that I don't understand.
The error is:
In file included from C:\Users\Al\OneDrive\Arduino\ESP8266_DS18B20_temperature_sensor_REST\ESP8266_DS18B20_temperature_sensor_REST.ino:16:0:
C:\Program Files (x86)\Arduino\libraries\OneWire/OneWire.h:108:2: error: #error "Please define I/O register types here"
#error "Please define I/O register types here"
I got this code from the web and have stripped out all the wireless lines to try and isolate the problem. My code should now only print to screen. I use these onewire sensors a lot and the NodeMCU is great for small projects.
Can anyone help please.
Thanks
#include <ESP8266WiFi.h>
#include <OneWire.h>
#include <DallasTemperature.h>
#define ONE_WIRE_BUS 2 // DS18B20 pin
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature DS18B20(&oneWire);
float oldTemp;
void setup() {
Serial.begin(115200);
oldTemp = -1;
}
void loop() {
float temp;
do {
DS18B20.requestTemperatures();
temp = DS18B20.getTempCByIndex(0);
Serial.print("Temperature: ");
Serial.println(temp);
} while (temp == 85.0 || temp == (-127.0));
if (temp != oldTemp)
{
oldTemp = temp;
}
delay(1000);
}