Below is the code that I have done on Lolin Wemos D1 R2 and mini
it works fine but it throws exceptions every time, I tried understanding my problem by reading this: NodeMCU 1.0 - Exception 9 `Fatal exception 9(LoadStoreAlignmentCause):` but couldn't!
#include <FirebaseArduino.h>
#include <SoftwareSerial.h>
#include <NTPClient.h>
#include <WiFiUdp.h>
//#include "FS.h"
//---------firebase creds---------
#define FIREBASE_HOST "homeauto-3130d.firebaseio.com"
#define FIREBASE_AUTH ""
//--------wifi creds--------
#define WIFI_SSID "********"
#define WIFI_PASSWORD "***************"
SoftwareSerial esp(D2,D8); //rx tx
//--------data from arduino to esp-------
float temp_fb;
float gas_fb;
float hum_fb;
//-------checking time elapsed b4 printing ------
unsigned long last_chk = 0 ;
unsigned long time_elapsed;
//-----ctrlling sending rate to firebase----
bool t_ar , h_ar , g_ar = false ; //chk arrival of all data b4 sending
char r;
int found = 1;
//-----setting feeder pos from firebase
String feed_load = "0" ;
//-----getting time stamp from ntp server
char time_stamp[12];
int len;
const long utcOffsetInSeconds = 19800; //gmt+5hrs:30mins => 19800 sec
WiFiUDP ntpUDP;
NTPClient timeClient(ntpUDP, "pool.ntp.org", utcOffsetInSeconds);
//------------------------schedule vars----------------------------
void setup()
{
Serial.begin(9600);
esp.begin(4800);
SPIFFS.begin();
// connect to wifi.
WiFi.begin(WIFI_SSID, WIFI_PASSWORD);
Serial.print("connecting");
while (WiFi.status() != WL_CONNECTED) {
Serial.print(".");
delay(500);
}
Serial.println("connected: ");
Serial.println(WiFi.localIP());
Firebase.begin(FIREBASE_HOST, FIREBASE_AUTH);
if(Firebase.failed())
{
Serial.print("failed...");
Serial.println(Firebase.error());
}
timeClient.begin();
}
void loop()
{
time_elapsed = millis();
if(time_elapsed - last_chk > 5000)
{
Serial.println("checking for data from arduino...");
last_chk = time_elapsed;
time_elapsed = millis();
}
while(esp.available()>0)
{
if(found == 1)
{
Serial.println("................found data...............") ;
timeClient.update();
len = sprintf(time_stamp , "%d:%d:%d" , timeClient.getHours() , timeClient.getMinutes() , timeClient.getSeconds() ) ;
Serial.print("Time stamp:\t");
Serial.println(time_stamp);
found = 0;
}
r = esp.read();
switch(r)
{
case 't':
{
Serial.print("got t...") ;
t_ar = true;
temp_fb = esp.parseFloat();
Serial.println(temp_fb);
break ;
}
case 'g':
{
Serial.print("got g...") ;
g_ar = true;
gas_fb = esp.parseFloat();
Serial.println(gas_fb);
break ;
}
case 'h':
{
Serial.print("got h...") ;
h_ar = true;
hum_fb = esp.parseFloat();
Serial.println(hum_fb);
break ;
}
default: break;
}
}
found = 1 ;
if(g_ar and t_ar and h_ar)
{
//writing to firebase
Serial.println("got the set.. to fb now");
Firebase.pushString("Time stamp" , time_stamp);
Firebase.setFloat("GAS SENSORinst" ,gas_fb);
Firebase.setFloat("HUMIDITY SENSORinst" ,hum_fb);
Firebase.setFloat("TEMP SENSORinst" ,temp_fb);
Firebase.pushFloat("GAS SENSOR" ,gas_fb);
Firebase.pushFloat("HUMIDITY SENSOR" ,hum_fb);
Firebase.pushFloat("TEMP SENSOR" ,temp_fb);
}
t_ar , h_ar , g_ar = false ;
feed_load = Firebase.getString("feeder");
if (feed_load != "0")
{
Serial.println("\trecd req to feed");
esp.print('w');
esp.print(feed_load);
feed_load = "0";
Serial.println("\tsetting feeder to close in firebase");
Firebase.setString("feeder" , "0");
}
}
Here's the error log:(I've only pasted the exceptions, they just repeat over and over again)
Exception (28):
epc1=0x4020cda0 epc2=0x00000000 epc3=0x00000000 excvaddr=0x00000034 depc=0x00000000
>>>stack>>>
ctx: cont
sp: 3ffffc50 end: 3fffffc0 offset: 01a0
3ffffdf0: 0000000b 3ffeeb28 3fff0e18 40206e5c
3ffffe00: 3ffe8857 000001bb 3fff0e18 40207d34
3ffffe10: 3ffe890b 0000003b 3fff0e18 4020817c
3ffffe20: 0000003b 3fffff00 3ffeec64 40203eb0
3ffffe30: 3ffffe78 0000003b 3ffffe60 40209018
3ffffe40: 3ffeeb24 3ffffe60 3ffe890b 3ffffee0
3ffffe50: 3ffeeb24 3ffffea4 3fff0e14 402057ab
3ffffe60: 3fff10bc 003b003f 00fffea4 3fff0f4c
3ffffe70: 000c000f 00ffff5c 3fff0ef4 001d001f
3ffffe80: 00fe876b 3ffeeb20 3fffff62 3ffffee0
3ffffe90: 3ffeeb24 3ffe8888 3fff0ca4 402034ec
3ffffea0: 3ffe876b 3fff0f38 3fff0ec4 3ffeea78
3ffffeb0: 3fffff5c 3ffffee0 3ffe876b 40203e74
3ffffec0: 3ffffee8 3fffff00 3fffff00 3ffeea78
3ffffed0: 3fffff5c 3fff0ca4 3ffeeb20 40204765
3ffffee0: 3ffeeb60 3fff0ed0 05e353f7 40205fef
3ffffef0: 3ffeeb20 3ffeeb20 3fffff50 402047a6
3fffff00: 00220000 3fff0174 3ffeea78 402068ca
3fffff10: 00000006 00000002 40205fbc 402067ac
3fffff20: 00c3c10e 00000006 3fffff5c 40209018
3fffff30: 3ffeeb20 3fffff5c 3ffe8804 4020904e
3fffff40: 3ffeeb20 3ffe851c 3ffeea61 40201438
3fffff50: 3ffe0000 3fffff80 80feeb84 64656566
3fffff60: 00007265 86595cc2 3ffeeb00 4020113a
3fffff70: 00000000 00000000 feefeffe feefeffe
3fffff80: 00000000 00000000 00000001 40100580
3fffff90: 3fffdad0 00000000 3ffeec74 3ffeecb4
3fffffa0: 3fffdad0 00000000 3ffeec74 40209f08
3fffffb0: feefeffe feefeffe 3ffe8584 401012d1
<<<stack<<<
Exception (9):
epc1=0x4020cda0 epc2=0x00000000 epc3=0x00000000 excvaddr=0x65656663 depc=0x00000000
>>>stack>>>
ctx: cont
sp: 3ffffc50 end: 3fffffc0 offset: 01a0
3ffffdf0: 0000000b 3ffeeb28 3fff0e18 40206e5c
3ffffe00: 3ffe8857 000001bb 3fff0e18 40207d34
3ffffe10: 3ffe890b 0000003b 3fff0e18 4020817c
3ffffe20: 0000003b 3fffff00 3ffeec64 40203eb0
3ffffe30: 3ffffe78 0000003b 3ffffe60 40209018
3ffffe40: 3ffeeb24 3ffffe60 3ffe890b 3ffffee0
3ffffe50: 3ffeeb24 3ffffea4 3fff0e14 402057ab
3ffffe60: 3fff0f1c 003b003f 00fffea4 3fff0f04
3ffffe70: 000c000f 00ffff5c 3fff0eac 001d001f
3ffffe80: 00fe876b 3ffeeb20 3fffff62 3ffffee0
3ffffe90: 3ffeeb24 3ffe8888 3fff0c7c 402034ec
3ffffea0: 3ffe876b 3fff0ef0 3fff0cbc 3ffeea78
3ffffeb0: 3fffff5c 3ffffee0 3ffe876b 40203e74
3ffffec0: 3ffffee8 3fffff00 3fffff00 3ffeea78
3ffffed0: 3fffff5c 3fff0c7c 3ffeeb20 40204765
3ffffee0: 3ffeeb60 3fff0cc8 a7ae147a 40205fef
3ffffef0: 3ffeeb20 3ffeeb20 3fffff50 402047a6
3fffff00: 00220000 3fff0174 3ffeea78 402068ca
3fffff10: 00000006 00000002 40205fbc 402067ac
3fffff20: 00c15609 00000006 3fffff5c 40209018
3fffff30: 3ffeeb20 3fffff5c 3ffe8804 4020904e
3fffff40: 3ffeeb20 3ffe851c 3ffeea61 40201438
3fffff50: 3ffe0000 3fffff80 80feeb84 64656566
3fffff60: 00007265 86461819 3ffeeb00 4020113a
3fffff70: 00000000 00000000 feefeffe feefeffe
3fffff80: 00000000 00000000 00000001 40100580
3fffff90: 3fffdad0 00000000 3ffeec74 3ffeecb4
3fffffa0: 3fffdad0 00000000 3ffeec74 40209f08
3fffffb0: feefeffe feefeffe 3ffe8584 401012d1
<<<stack<<<
edit1 decoding error stack, this is what i get...
Exception 28: LoadProhibited: A load referenced a page mapped with an attribute that does not permit loads
PC: 0x402141d4: HTTPClient::connected() at C:\Users\Admin\Documents\ArduinoData\packages\esp8266\hardware\esp8266\2.6.3\libraries\ESP8266HTTPClient\src\ESP8266HTTPClient.cpp line 472
EXCVADDR: 0x00000040
Decoding stack results
0x40206e64: HTTPClient::disconnect(bool) at C:\Users\Admin\Documents\ArduinoData\packages\esp8266\hardware\esp8266\2.6.3\libraries\ESP8266HTTPClient\src\ESP8266HTTPClient.cpp line 435
0x40207d3c: HTTPClient::end() at C:\Users\Admin\Documents\ArduinoData\packages\esp8266\hardware\esp8266\2.6.3\libraries\ESP8266HTTPClient\src\ESP8266HTTPClient.cpp line 425
0x40208184: HTTPClient::begin(String, unsigned short, String, String) at C:\Users\Admin\Documents\ArduinoData\packages\esp8266\hardware\esp8266\2.6.3\libraries\ESP8266HTTPClient\src\ESP8266HTTPClient.cpp line 379
0x40203eb8: std::string::_Rep::_M_destroy(std::allocator const&) at c:\users\admin\documents\arduinodata\packages\esp8266\tools\xtensa-lx106-elf-gcc\2.5.0-4-b40a506\xtensa-lx106-elf\include\c++\4.8.2\bits/basic_string.tcc line 452
0x40209164: String::copy(char const*, unsigned int) at C:\Users\Admin\Documents\ArduinoData\packages\esp8266\hardware\esp8266\2.6.3\cores\esp8266\WString.cpp line 214
0x402057b3: FirebaseHttpClientEsp8266::begin(std::string const&, std::string const&) at C:\Users\Admin\Documents\Arduino\libraries\firebase-arduino-master\src\FirebaseHttpClient_Esp8266.cpp line 51
0x402034f4: FirebaseRequest::sendRequest(std::string const&, std::string const&, char*, std::string const&, std::string const&) at C:\Users\Admin\Documents\Arduino\libraries\firebase-arduino-master\src\Firebase.cpp line 73
0x40203e7c: std::basic_string , std::allocator >::basic_string(char const*, std::allocator const&) at c:\users\admin\documents\arduinodata\packages\esp8266\tools\xtensa-lx106-elf-gcc\2.5.0-4-b40a506\xtensa-lx106-elf\include\c++\4.8.2\bits/basic_string.tcc line 218
0x4020476d: FirebaseArduino::getRequest(String const&) at C:\Users\Admin\Documents\Arduino\libraries\firebase-arduino-master\src\FirebaseArduino.cpp line 101
0x40205ff7: std::_Function_base::_Base_manager ::_M_manager(std::_Any_data &, const std::_Any_data &, std::_Manager_operation) at c:\users\admin\documents\arduinodata\packages\esp8266\tools\xtensa-lx106-elf-gcc\2.5.0-4-b40a506\xtensa-lx106-elf\include\c++\4.8.2/functional line 1954
0x402047ae: FirebaseArduino::getString(String const&) at C:\Users\Admin\Documents\Arduino\libraries\firebase-arduino-master\src\FirebaseArduino.cpp line 132
0x402068d2: SoftwareSerial::rxBits() at C:\Users\Admin\Documents\ArduinoData\packages\esp8266\hardware\esp8266\2.6.3\libraries\SoftwareSerial\src\SoftwareSerial.cpp line 394
0x40205fc4: std::_Function_base::_Base_manager ::_M_manager(std::_Any_data &, const std::_Any_data &, std::_Manager_operation) at c:\users\admin\documents\arduinodata\packages\esp8266\tools\xtensa-lx106-elf-gcc\2.5.0-4-b40a506\xtensa-lx106-elf\include\c++\4.8.2/functional line 1931
0x402067b4: std::_Function_handler ::_M_invoke(const std::_Any_data &, unsigned int &&) at C:\Users\Admin\Documents\ArduinoData\packages\esp8266\hardware\esp8266\2.6.3\libraries\SoftwareSerial\src\SoftwareSerial.cpp line 393
0x40209164: String::copy(char const*, unsigned int) at C:\Users\Admin\Documents\ArduinoData\packages\esp8266\hardware\esp8266\2.6.3\cores\esp8266\WString.cpp line 214
0x4020919a: String::String(char const*) at C:\Users\Admin\Documents\ArduinoData\packages\esp8266\hardware\esp8266\2.6.3\cores\esp8266\WString.cpp line 36
0x40201440: loop() at C:\Users\Admin\Desktop\dummy\iot1\tonodemcu/tonodemcu.ino line 151
0x40201142: setup() at C:\Users\Admin\Desktop\dummy\iot1\tonodemcu/tonodemcu.ino line 72
0x40100580: ets_post(uint8, ETSSignal, ETSParam) at C:\Users\Admin\Documents\ArduinoData\packages\esp8266\hardware\esp8266\2.6.3\cores\esp8266\core_esp8266_main.cpp line 160
0x4020a054: loop_wrapper() at C:\Users\Admin\Documents\ArduinoData\packages\esp8266\hardware\esp8266\2.6.3\cores\esp8266\core_esp8266_main.cpp line 180
Exception 9: LoadStoreAlignmentCause: Load or store to an unaligned address
PC: 0x402141d4: HTTPClient::connected() at C:\Users\Admin\Documents\ArduinoData\packages\esp8266\hardware\esp8266\2.6.3\libraries\ESP8266HTTPClient\src\ESP8266HTTPClient.cpp line 472
EXCVADDR: 0x65656663
Decoding stack results
0x40206e64: HTTPClient::disconnect(bool) at C:\Users\Admin\Documents\ArduinoData\packages\esp8266\hardware\esp8266\2.6.3\libraries\ESP8266HTTPClient\src\ESP8266HTTPClient.cpp line 435
0x40207d3c: HTTPClient::end() at C:\Users\Admin\Documents\ArduinoData\packages\esp8266\hardware\esp8266\2.6.3\libraries\ESP8266HTTPClient\src\ESP8266HTTPClient.cpp line 425
0x40208184: HTTPClient::begin(String, unsigned short, String, String) at C:\Users\Admin\Documents\ArduinoData\packages\esp8266\hardware\esp8266\2.6.3\libraries\ESP8266HTTPClient\src\ESP8266HTTPClient.cpp line 379
0x40203eb8: std::string::_Rep::_M_destroy(std::allocator const&) at c:\users\admin\documents\arduinodata\packages\esp8266\tools\xtensa-lx106-elf-gcc\2.5.0-4-b40a506\xtensa-lx106-elf\include\c++\4.8.2\bits/basic_string.tcc line 452
0x40209164: String::copy(char const*, unsigned int) at C:\Users\Admin\Documents\ArduinoData\packages\esp8266\hardware\esp8266\2.6.3\cores\esp8266\WString.cpp line 214
0x402057b3: FirebaseHttpClientEsp8266::begin(std::string const&, std::string const&) at C:\Users\Admin\Documents\Arduino\libraries\firebase-arduino-master\src\FirebaseHttpClient_Esp8266.cpp line 51
0x402034f4: FirebaseRequest::sendRequest(std::string const&, std::string const&, char*, std::string const&, std::string const&) at C:\Users\Admin\Documents\Arduino\libraries\firebase-arduino-master\src\Firebase.cpp line 73
0x40203e7c: std::basic_string , std::allocator >::basic_string(char const*, std::allocator const&) at c:\users\admin\documents\arduinodata\packages\esp8266\tools\xtensa-lx106-elf-gcc\2.5.0-4-b40a506\xtensa-lx106-elf\include\c++\4.8.2\bits/basic_string.tcc line 218
0x4020476d: FirebaseArduino::getRequest(String const&) at C:\Users\Admin\Documents\Arduino\libraries\firebase-arduino-master\src\FirebaseArduino.cpp line 101
0x40205ff7: std::_Function_base::_Base_manager ::_M_manager(std::_Any_data &, const std::_Any_data &, std::_Manager_operation) at c:\users\admin\documents\arduinodata\packages\esp8266\tools\xtensa-lx106-elf-gcc\2.5.0-4-b40a506\xtensa-lx106-elf\include\c++\4.8.2/functional line 1954
0x402047ae: FirebaseArduino::getString(String const&) at C:\Users\Admin\Documents\Arduino\libraries\firebase-arduino-master\src\FirebaseArduino.cpp line 132
0x402068d2: SoftwareSerial::rxBits() at C:\Users\Admin\Documents\ArduinoData\packages\esp8266\hardware\esp8266\2.6.3\libraries\SoftwareSerial\src\SoftwareSerial.cpp line 394
0x40205fc4: std::_Function_base::_Base_manager ::_M_manager(std::_Any_data &, const std::_Any_data &, std::_Manager_operation) at c:\users\admin\documents\arduinodata\packages\esp8266\tools\xtensa-lx106-elf-gcc\2.5.0-4-b40a506\xtensa-lx106-elf\include\c++\4.8.2/functional line 1931
0x402067b4: std::_Function_handler ::_M_invoke(const std::_Any_data &, unsigned int &&) at C:\Users\Admin\Documents\ArduinoData\packages\esp8266\hardware\esp8266\2.6.3\libraries\SoftwareSerial\src\SoftwareSerial.cpp line 393
0x40209164: String::copy(char const*, unsigned int) at C:\Users\Admin\Documents\ArduinoData\packages\esp8266\hardware\esp8266\2.6.3\cores\esp8266\WString.cpp line 214
0x4020919a: String::String(char const*) at C:\Users\Admin\Documents\ArduinoData\packages\esp8266\hardware\esp8266\2.6.3\cores\esp8266\WString.cpp line 36
0x40201440: loop() at C:\Users\Admin\Desktop\dummy\iot1\tonodemcu/tonodemcu.ino line 151
0x40201142: setup() at C:\Users\Admin\Desktop\dummy\iot1\tonodemcu/tonodemcu.ino line 72
0x40100580: ets_post(uint8, ETSSignal, ETSParam) at C:\Users\Admin\Documents\ArduinoData\packages\esp8266\hardware\esp8266\2.6.3\cores\esp8266\core_esp8266_main.cpp line 160
0x4020a054: loop_wrapper() at C:\Users\Admin\Documents\ArduinoData\packages\esp8266\hardware\esp8266\2.6.3\cores\esp8266\core_esp8266_main.cpp line 180
Read from here: NodeMCU Exception 28 - intermitent problem that exception 28
maybe because of some functions not returning values and I can take that because, i just connected the ESP without arduino just to check what happens, but during other times I only recall exception 9
being repeated
The var String feed_load
is read from firebase , which gets the value from a app made from MIT app inventor , I store 0 or value of load in it (a float) ; but app inventor stores it as a string, so i am reading it as a string , i tried putting char feed_load[5]
but it gave a error saying string cannot be stored in char[5]
kindly help in fixing this problem , there's some more code to be written for scheduling activities , so i don't want the board to be constantly resetting or restarting