I’m working on Smart Energy Meter which can display real time values of Current, Load, Electricity Bill and Carbon Footprint on an LCD and also display them in real-time on my Blynk App. I have added a feature to send a web request to generate an email with the electricity bill when a button is pressed on the Blynk App.
A few points to be noted:
- I am not getting any errors when I am displaying just one value in Real Time on the Blynk App.
- I have checked for shorting in my circuit and there aren’t any short circuits.
- I have not used the GPIOs 0,2,15.
- I have also tested with a button to send a web request and display just one value in Blynk App and it works fine.
Problem : ets Jan 8 2013,rst cause:4, boot mode:(1,6)
When I’m firing a web request by pressing the button while displaying 4 real-time values, I’m getting the above error. Note that when I’m sending just one value, the above error is not occurring.
Source Code:
#define BLYNK_PRINT Serial
//#define BLYNK_DEBUG
#include <BlynkSimpleEsp8266.h> // library for connecting to Blynk
#include <Wire.h>
#include <LCD.h>
#include <LiquidCrystal_I2C.h>
#include <ESP8266WiFi.h> // library for setting up the board to connect to Wifi
#include <ESP8266HTTPClient.h> // library for making a HTTP web request from the board
#include <NTPtimeESP.h>
int mVperAmp = 100; // use 100 for 20A Module and 66 for 30A Module
double Voltage = 0;
double VRMS = 0;
double AmpsRMS = 0;
double kwh = 0;
double rupees = 0;
double Power = 0;
double Energy = 0;
double cfp = 0;
uint32_t start_time;
byte actualHour = 0;
byte actualMinute = 0;
byte actualsecond = 0;
NTPtime NTPch("in.pool.ntp.org"); // Choose server pool as required
LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7); // 0x27 is the I2C bus address for an unmodified module
BlynkTimer timer; // creating an instance for BlynkTimer to keep sending data to our Blynk project whenever the timer is running
char auth[] = "4b56bb551dc743ad8163c3f5e7b8d1f4";
char ssid[] = "iBrain_FF";
char pass[] = "lemons@iB";
strDateTime dateTime;
void myTimerEvent()
{
start_time = millis();
Voltage = getVPP();
VRMS = (Voltage / 2.0) * 0.707; //root 2 is 0.707
AmpsRMS = ((VRMS * 1000) / mVperAmp) - 0.15;
Power = AmpsRMS * 220;
kwh = ((Power * start_time) / (3600000));
rupees = 3 * kwh;
cfp = ((kwh) * (0.85) / (24 * 365)) * 100000;
dateTime = NTPch.getNTPtime(4.5, 1);
if (dateTime.valid)
{
actualHour = dateTime.hour;
actualMinute = dateTime.minute;
actualsecond = dateTime.second;
}
Blynk.virtualWrite(V1, rupees);
Blynk.virtualWrite(V2, AmpsRMS);
Blynk.virtualWrite(V3, Power);
Blynk.virtualWrite(V4, cfp);
//Serial.print(AmpsRMS);
//Serial.println(" Amps RMS");
if ( Power < 0 )
{
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("No Power Supply");
}
else
{
lcd.clear();
lcd.setCursor(0, 0);
lcd.print(String(AmpsRMS) + String("A"));
lcd.setCursor(0, 1);
lcd.print(String("Rs") + String(rupees));
lcd.setCursor(8, 0);
lcd.print(String(Power) + String("W"));
lcd.setCursor(8, 1);
lcd.print(String(actualHour) + String(":") + String(actualMinute) + String(":") + String(actualsecond));
}
}
BLYNK_WRITE(V0)
{
int p;
p = param[0].asInt(); // the input which we get from the button in the Blynk Project
if ( p == 1 )
{
String s = "https://maker.ifttt.com/trigger/Get_Electricity_Bill/with/key/n37nidc1OYT5j0cijZVH6H5ZumUpZSUkD9_eLULIjzg?value1=" + String(rupees);
//we convert "rupees" value to string to concatenate with our URL to make a web request
if ((WiFi.status() == WL_CONNECTED)) {
HTTPClient http;//creating instance for HTTP
Serial.print("[HTTP] begin...\n");
http.begin(s, "c05d085ee13ee066f379271aca1ffc0924116162"); //in http.begin(A,B), A = URL, B(for https) = Certification Thumbprint of the website you're making a request to
Serial.print("[HTTP] GET...\n");
int httpCode = http.GET(); // to get a code which tells us the status of transmission
if (httpCode > 0) {
Serial.printf("[HTTP] GET... code: %d\n", httpCode);
if (httpCode == HTTP_CODE_OK) {
String payload = http.getString();
Serial.println(payload);
}
} else {
Serial.printf("[HTTP] GET... failed, error: %s\n", http.errorToString(httpCode).c_str());
}
http.end();
}
Serial.println("Button Pressed");
Serial.println(s);
delay(100);
}
}
float getVPP()
{
float result;
int readValue; //value read from the sensor
int maxValue = 0; // store max value here
int minValue = 1024; // store min value here
uint32_t start_time1 = millis();
while ((millis() - start_time1) < 1000) //sample for 1 Sec
{
readValue = analogRead(A0);
// see if you have a new maxValue
if (readValue > maxValue)
{
/*record the maximum sensor value*/
maxValue = readValue;
}
if (readValue < minValue)
{
/*record the minimum sensor value*/
minValue = readValue;
}
}
// Subtract min from max
result = ((maxValue - minValue) * 5.0) / 1024.0;
return result;
}
void setup()
{
Serial.begin(115200);
lcd.setBacklightPin(3, POSITIVE);
lcd.setBacklight(HIGH); // NOTE: You can turn the backlight off by setting it to LOW instead of HIGH
lcd.begin(16, 2);
lcd.clear();
Serial.println();
Serial.println("Booted");
Serial.println("Connecting to Wi-Fi");
WiFi.mode(WIFI_STA);
WiFi.begin (ssid, pass);
while (WiFi.status() != WL_CONNECTED) {
Serial.print(".");
delay(500);
}
Serial.println("WiFi connected");
Blynk.config(auth);
timer.setInterval(1000L, myTimerEvent);
}
void loop()
{
Blynk.run();
timer.run(); // Initiates BlynkTimer
}
Error displayed in Serial Monitor when the button on Blynk App is pressed :-
Soft WDT reset
ctx: cont
sp: 3fff1100 end: 5ccf061a offset: 01b0
>>>stack>>>
3fff12b0: 00000000 00eda996 40201770 00001388
3fff12c0: 40201786 00001388 00001388 4020177b
3fff12d0: 00000045 00000000 3fff318c 4020566e
.
.
.
.
.
.
.
.
3fff4340: 4c370342 d5df88e6 b1f224af b5ccdfc3
3fff4ÿ
ets Jan 8 2013,rst cause:4, boot mode:(1,6)
wdt reset
Kindly clarify.