This is code for IoT fridge, I am inexperienced and would appreciate some help. this has been copid directly from the website but keeps bringing up the above error. I am using a Node MCU Amica ESP8266
thank you in anticipation.
// temperature range of the DS18b20
// Temperature Range: -55°C to +125°C.
/* ESP & Blynk */
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include <SimpleTimer.h>
#include <OneWire.h>
#include <DallasTemperature.h>
#define BLYNK_PRINT Serial // Comment this out to disable prints and save space
char auth[] = "1-k0JQKmFbYR5dBidgi8iRKq8XRtGMyZ";
/* WiFi credentials */
char ssid[] = "ZONG MBB-E8231-6E63";
char pass[] = "electroniclinic";
SimpleTimer timer;
#define ONE_WIRE_BUS 2 // DS18B20 on arduino pin2 corresponds to D4 on physical board "D4 pin on the ndoemcu Module"
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature DS18B20(&oneWire);
float temp;
float Fahrenheit=0;
int Dsensor = D0; // Refrigerator door sensor
// Tracks the time since last event fired
unsigned long previousMillis=0;
unsigned long int previoussecs = 0;
unsigned long int currentsecs = 0;
unsigned long currentMillis = 0;
int interval= 1; // 1 second interval
int secs = 0; // current seconds
int mints = 0; // current minutes
int pmints = 3; // predefined minutes for the refrigerator Door
int tempf = 0; // temperature flag
int tvr = A0; // temperature variable resistor, variable resistor to set the temperature
int Ptemp; // preset temperature.
void setup()
{
Serial.begin(115200);
Blynk.begin(auth, ssid, pass);
DS18B20.begin();
pinMode(Dsensor, INPUT_PULLUP);
pinMode(tvr, INPUT);
timer.setInterval(1000L, getSendData);
timer.setInterval(1000L, DoorSensor);
}
void loop()
{
timer.run(); // Initiates SimpleTimer
Blynk.run();
}
/***************************************************
* Send Sensor data to Blynk
**************************************************/
void getSendData()
{
Ptemp = analogRead(tvr);
Ptemp = map(Ptemp, 0, 1023, -40,40);
DS18B20.requestTemperatures();
temp = DS18B20.getTempCByIndex(0); // Celcius
Fahrenheit = DS18B20.toFahrenheit(temp); // Fahrenheit
Serial.println(temp);
Serial.println(Fahrenheit);
Blynk.virtualWrite(V6,Ptemp);
Blynk.virtualWrite(V2, temp); //virtual pin V3
if ( (temp >= Ptemp) && (tempf == 0))
{
Blynk.notify("Check temperature");
tempf = 1;
}
if ( (temp < Ptemp) && (tempf == 1))
{
Blynk.notify("looks good");
tempf = 0;
}
}
void DoorSensor()
{
if(digitalRead(Dsensor) == LOW)
{
Blynk.virtualWrite(V4,0);
Blynk.virtualWrite(V5,255);
secs = 0;
mints = 0;
}
if(digitalRead(Dsensor) == HIGH)
{
Blynk.virtualWrite(V4,255);
Blynk.virtualWrite(V5,0);
currentMillis = millis();
currentsecs = currentMillis / 1000;
if ((unsigned long)(currentsecs - previoussecs) >= interval) {
secs = secs + 1;
if (secs >59 )
{
secs = 0;
mints = mints + 1;
if(mints >= pmints )
{
secs = 0;
mints = 0;
Blynk.notify("Door is opened for the last 3 mints");
}
}
previoussecs = currentsecs;
}
}
Blynk.virtualWrite(V3, "Seconds");
Blynk.virtualWrite(V3, secs);
Blynk.virtualWrite(V3, "Mints");
Blynk.virtualWrite(V3, mints);
Blynk.virtualWrite(V3,"*********");
}