Hello,
I am implementing a wireless sensor using ESP8266 combined by MLX90614. programming is done by Arduino using the following code. I am trying to safe power by entering the sensor into sleep mode but it does not work. I wish someone can help me with this issue.
#include<ESP8266WiFi.h>
#include<Wire.h>
#include<SparkFunMLX90614.h>
#include<ThingSpeak.h>
unsigned long myChannelNumber = 1094646;
const char* myWriteAPIKey = "J75HUNJBTZ8TPGCH";
const char* ssid = "NETGEAR10";
const char* password = "samhassan2018";
IRTherm therm;
int fieldStart = 2;
int updatePeriod = 120;
WiFiClient client;
int objTemp;
int ambTemp;
void setup()
{
Serial.begin(9600);
delay(500);
Serial.println("Connecting to ");
Serial.println(ssid);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED)
{
delay(500);
Serial.print(".");
}
Serial.println("");
Serial.println("WiFi connected, IP address: ");
Serial.println(WiFi.localIP());
ThingSpeak.begin(client);
therm.begin();
therm.setUnit(TEMP_C);
}
void loop()
{
therm.wake();
Serial.println("Awake");
if (therm.read())
{
objTemp = therm.object();
ThingSpeak.setField(fieldStart, objTemp);
Serial.println("Temperature: ");
Serial.println(objTemp);
ThingSpeak.writeFields(myChannelNumber, myWriteAPIKey);
Serial.println("Data sent to ThingSpeak");
Serial.print("Ambient = ");
Serial.print(therm.ambient());
Serial.println("*C");
Serial.print("Object = ");
Serial.print(therm.object());
Serial.println("*C");
}
therm.sleep();
delay(1000);
ESP.deepSleep(120e6);
}