The use of the ESP8266 in the world of IoT
User avatar
By Kizuna
#77587 I try to use nodemcu to send my data to firebase and calculate AC power that equipment use also control which equipment that active. I use Arduino IDE to code. The equipment is household equipment. First I try the control code and have no problem. Also I try the power measure with emonlib and its ok to send the data. After combine the 2 code its work for a moment and suddenly this error appear. I tried to upload each of the code and its still have the error. I dont know why but this error like effecting the other. This is the code i use
Code: Select all#include <EmonLib.h>

#include <ESP8266WiFi.h>
#include <FirebaseArduino.h>
EnergyMonitor emon1;
EnergyMonitor emon2;

// Set these to run example.
#define FIREBASE_HOST "firebase project host"
#define FIREBASE_AUTH "firebase authentication"
#define WIFI_SSID "wifi id"
#define WIFI_PASSWORD "pass"

int s0 = D5;
int s1 = D4;
int s2 = D3;
int analogPin = A0;
String name;

void setup() {
Serial.begin(9600);

// connect to wifi.
pinMode(D1, OUTPUT);
pinMode(D2, OUTPUT);
pinMode(s0, OUTPUT);
pinMode(s1, OUTPUT);
pinMode(s2, OUTPUT);
WiFi.mode(WIFI_STA);
WiFi.begin(WIFI_SSID, WIFI_PASSWORD);
Serial.print("connecting");
while (WiFi.status() != WL_CONNECTED) {
Serial.print(".");
delay(500);
}
Serial.println();
Serial.print("connected: ");
Serial.println(WiFi.localIP());

Firebase.begin(FIREBASE_HOST, FIREBASE_AUTH);
Firebase.set("Saklar1",1);
Firebase.set("Saklar2",1);
emon1.voltage(A0, 234.26, 1.7); // Voltage: input pin, calibration, phase_shift
emon1.current(A0, 111.1);

emon2.voltage(A0, 234.26, 1.7); // Voltage: input pin, calibration, phase_shift
emon2.current(A0, 111.1);
}

int n = 1;
int a = 1;

void loop() {
n=Firebase.getInt("Saklar1");
a=Firebase.getInt("Saklar2");
// controling on off
if (n==1 && a==1) {
digitalWrite(D1, HIGH);
digitalWrite(D2, HIGH);

}
else if(n==1 && a==0){
digitalWrite(D1, HIGH);
digitalWrite(D2, LOW);

  }
 
  else if(n==0 && a==1){
  digitalWrite(D1, LOW);
  digitalWrite(D2, HIGH);
  //saklar1;
  }
  else{
  digitalWrite(D1, LOW);
  digitalWrite(D2, LOW);
  //saklar1;
 
  }
}
//saklar 1 kirim data
void saklar1(){
digitalWrite(s0,LOW);
digitalWrite(s1,LOW);
digitalWrite(s2,LOW);
if(D1,HIGH){
emon1.calcVI(20,400);
float tegangan1 = emon1.Vrms;
float arus1 = emon1.Irms;
float daya1 = emon1.Vrms * emon1.Irms;
name=Firebase.pushFloat("Arus 1", arus1);
if (Firebase.failed()) {
Serial.print("pushing /Arus 1 failed:");
Serial.println(Firebase.error());
return;
}
Serial.print("pushed: /Arus 1/");
Serial.println(name);
delay(100);

digitalWrite(s0,HIGH);
digitalWrite(s1,LOW);
digitalWrite(s2,LOW);
name=Firebase.pushFloat("Tegangan 1", tegangan1);
if (Firebase.failed()) {
Serial.print("pushing /Tegangan 1 failed:");
Serial.println(Firebase.error());
return;
}
Serial.print("pushed: /Tegangan 1/");
Serial.println(name);
delay(100);

      name=Firebase.pushFloat("Daya 1", daya1);
          if (Firebase.failed()) {
          Serial.print("pushing /Daya 1 failed:");
          Serial.println(Firebase.error()); 
          return;
          }
      Serial.print("pushed: /Daya 1/");
      Serial.println(name);
}
}
//saklar 2 kirim data
void saklar2 (){
digitalWrite(s0,LOW);
digitalWrite(s1,HIGH);
digitalWrite(s2,LOW);

emon2.calcVI(20,400);
float tegangan2 = emon2.Vrms;
float daya2 = emon2.Vrms * emon2.Irms;
float arus2 = emon2.Irms;
name=Firebase.pushFloat("Arus 2", arus2);
if (Firebase.failed()) {
Serial.print("pushing /Arus 2 failed:");
Serial.println(Firebase.error());
return;
}
Serial.print("pushed: /Arus 2/");
Serial.println(name);
delay(100);

digitalWrite(s0,HIGH);
digitalWrite(s1,HIGH);
digitalWrite(s2,LOW);
name=Firebase.pushFloat("Tegangan 2", tegangan2);
if (Firebase.failed()) {
Serial.print("pushing /Tegangan 2 failed:");
Serial.println(Firebase.error());
return;
}
Serial.print("pushed: /Tegangan 2/");
Serial.println(name);
delay(100);

name=Firebase.pushFloat("Daya 2", daya2);
if (Firebase.failed()) {
Serial.print("pushing /Daya 2 failed:");
Serial.println(Firebase.error());
return;
}
Serial.print("pushed: /Daya 2/");
Serial.println(name);
}


and this is the error that i get
Code: Select allException (29):
epc1=0x402101ba epc2=0x00000000 epc3=0x00000000 excvaddr=0x00000004 depc=0x00000000

ctx: cont
sp: 3fff01e0 end: 3fff0860 offset: 01a0

>>>stack>>>
3fff0380:  00820000 00000082 3fff570c 4021d1e2 
3fff0390:  3ffef7ec 3fff3fe4 3fff570c 4021d3dc 
3fff03a0:  3fffb324 00000208 3fffb324 40100670 
3fff03b0:  00000104 0000a590 000014b2 00000042 
3fff03c0:  00000040 00000082 3fff56f4 4021d6f5 
3fff03d0:  00800000 00000080 00000000 00000041 
3fff03e0:  00000040 0000003f 3fff56c4 00000041 
3fff03f0:  3fffaf0c 3fff56f4 3fff56c4 3fff1abc 
3fff0400:  3fffb420 ffffffff 3fff3fe4 40208480 
3fff0410:  00000040 3fff3fe4 3fff56f4 3fff3fe4 
3fff0420:  00000040 3fff3fe4 3fff56f4 4021e22f 
3fff0430:  3fff39ec 0000003f f14c65d2 00000001 
3fff0440:  3fff3fe4 3fff56dc 3fff56f4 00000001 
3fff0450:  00000010 3fff3fe4 0000000f 4021e484 
3fff0460:  3fff56c4 3fff1aa4 0000000f 00000001 
3fff0470:  00000001 3fff82bc 3fff1cf1 4021d288 
3fff0480:  00000100 3fff37bc 3fff1cef 00000000 
3fff0490:  00000100 3fff37bc 3fff1cef 4021f60d 
3fff04a0:  3fff04d0 00000000 000000d0 00000030 
3fff04b0:  7fa05e09 767ac5a0 c2b20c26 00000004 
3fff04c0:  3fff1ce9 3fffb934 3fff1ce9 4021a308 
3fff04d0:  14e20303 0cff4050 d282d2a4 4b5133a0 
3fff04e0:  95b920b8 d3e3e0ff e6bb0399 6a1b3ea6 
3fff04f0:  feb08f53 df33c2d5 44664a96 5e0989de 
3fff0500:  3fff1ce9 00000004 3fffb934 4021a79d 
3fff0510:  f6bdb4de 9089175d f8bbfd1e 2fc86bdd 
3fff0520:  66f6aae1 00000004 3fffb88c 402133c5 
3fff0530:  00000004 3fff1ce9 00000001 3fffbac4 
3fff0540:  00000000 000008bf 00000064 40208440 
3fff0550:  00000050 00000000 0000003a 00000004 
3fff0560:  3fff1ce9 00000004 3fffb934 00000004 
3fff0570:  3fff1ce9 00000004 3fffb934 4021a110 
3fff0580:  02eae61a 00000000 00000000 00000035 
3fff0590:  0000006a 3fff1ce9 3fffb934 4021a4ec 
3fff05a0:  0000001e 3fff1d1c 3fffb934 401004d8 
3fff05b0:  3fff0608 0000000e 00000010 3fff195c 
3fff05c0:  40203400 3fffb934 3fff0600 01000000 
3fff05d0:  3fff0608 0002636e 3fffb934 4021a278 
3fff05e0:  4010500c 3fff15d4 3fff554c 3fff195c 
3fff05f0:  3fff653c 0002636e 3fff554c 40203de9 
3fff0600:  3fffb934 3fff3f24 3ffef5b0 402081a0 
3fff0610:  00001388 3fff0640 3fff4044 40203e28 
3fff0620:  00000000 00000000 3fff653c 3ffef5fc 
3fff0630:  000001bb 3fff15d4 3fff402c 40204037 
3fff0640:  00000000 00000000 3fff15d4 3ffef5fc 
3fff0650:  000001bb 3fff402c 3fff15d4 402040dd 
3fff0660:  401073c8 5561c923 401073c8 5561c923 
3fff0670:  3fff169c 00000000 3fff16a4 402068ec 
3fff0680:  00000000 00000694 00000694 402081a0 
3fff0690:  fffffff4 00000000 3fff16a4 402070dc 
3fff06a0:  3ffe8ed8 0000003b 3ffe8ca7 402049c7 
3fff06b0:  3fff4234 3fff0720 3fff169c 40204a20 
3fff06c0:  3fff4240 00000000 00000000 3ffe8ca4 
3fff06d0:  3fff169c 3fff0700 3ffe8ca4 3ffe8ca4 
3fff06e0:  3fff169c 3ffef5fc 3fff07e8 402059be 
3fff06f0:  3ffef5dc 3ffef5fc 3fff07e8 40204435 
3fff0700:  3fff4240 3ffef838 402083c8 01000000 
3fff0710:  3fff0748 3ffe8520 3fff1ce4 4021a278 
3fff0720:  3fff39a8 00000581 00000581 00000007 
3fff0730:  00000000 3fff080c 3fff07f8 3ffef5d8 
3fff0740:  3fff0788 3fff0788 402059a8 40204a08 
3fff0750:  3fff078c 3ffe8520 00000000 3ffef5dc 
3fff0760:  3fff080c 3fff0780 3fff07e8 40204766 
3fff0770:  3fff0780 3fff07c4 3fff16a4 40204a5e 
3fff0780:  3fff169c 3fff1774 3ffef5fc 3ffef838 
3fff0790:  3fff07c0 3ffef5d8 3fff15bc 40204a08 
3fff07a0:  3fff0818 00000010 00000000 3ffef838 
3fff07b0:  3fffdad0 00000000 3ffef5d8 4020509e 
3fff07c0:  3fff169c 3fff1774 00000000 3ffef838 
3fff07d0:  00000010 3fff0830 3fff0830 4020782b 
3fff07e0:  3ffe8a74 00000007 401072c8 3fff169c 
3fff07f0:  3fff1774 00000000 3ffef5fc 3ffef5fc 
3fff0800:  00000000 00000000 3fff0830 3fff12f8 
3fff0810:  3ffe8a74 00000001 3ffef5d8 40106999 
3fff0820:  00000000 3ffe8520 3ffef5d8 402023fb 
3fff0830:  3fff15bc 0000000f 00000007 402083e9 
3fff0840:  3fffdad0 00000000 3ffef831 40208414 
3fff0850:  feefeffe feefeffe 3ffef840 40100710 
<<<stack<<<


and this is the decode from the error
Code: Select allException 29: StoreProhibited: A store referenced a page mapped with an attribute that does not permit stores
PC: 0x402101ba
EXCVADDR: 0x00000004

Decoding stack results
0x4021d1e2: more_comps at crypto/bigint.c line 1072
0x4021d3dc: alloc at crypto/bigint.c line 1106
0x40100670: realloc at C:\Users\DELL\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.4.1\cores\esp8266\umm_malloc\umm_malloc.c line 1641
0x4021d6f5: regular_multiply at crypto/bigint.c line 822
0x40208480: optimistic_yield(uint32_t) at C:\Users\DELL\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.4.1\cores\esp8266\core_esp8266_main.cpp line 111
0x4021e22f: bi_barrett at crypto/bigint.c line 1289
0x4021e484: bi_mod_power at crypto/bigint.c line 1414
0x4021d288: trim at crypto/bigint.c line 1197
0x4021f60d: RSA_encrypt at crypto/rsa.c line 254
0x4021a308: send_client_key_xchg at ssl/tls1_clnt.c line 409
0x4021a79d: do_clnt_handshake at ssl/tls1_clnt.c line 123
0x402133c5: pbuf_free_LWIP2 at core/pbuf.c line 777
0x40208440: __yield() at C:\Users\DELL\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.4.1\cores\esp8266\core_esp8266_main.cpp line 96
0x4021a110: basic_read at ssl/tls1.c line 1607
0x4021a4ec: do_client_connect at ssl/tls1_clnt.c line 168
0x401004d8: malloc at C:\Users\DELL\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.4.1\cores\esp8266\umm_malloc\umm_malloc.c line 1668
0x40203400: SSLContext::_delete_shared_SSL(SSL_*) at C:\Users\DELL\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.4.1\libraries\ESP8266WiFi\src\WiFiClientSecure.cpp line 115
0x4021a278: ssl_read at ssl/tls1.c line 314
0x40203de9: SSLContext::connect(ClientContext*, char const*, unsigned int) at C:\Users\DELL\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.4.1\libraries\ESP8266WiFi\src\WiFiClientSecure.cpp line 146
0x402081a0: operator new(unsigned int) at C:\Users\DELL\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.4.1\cores\esp8266\abi.cpp line 30
0x40203e28: std::__shared_ptr ::operator=(std::__shared_ptr &&) at c:\users\dell\appdata\local\arduino15\packages\esp8266\tools\xtensa-lx106-elf-gcc\1.20.0-26-gb404fb9-2\xtensa-lx106-elf\include\c++\4.8.2\bits/shared_ptr_base.h line 862
0x40204037: WiFiClientSecure::_connectSSL(char const*) at C:\Users\DELL\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.4.1\libraries\ESP8266WiFi\src\WiFiClientSecure.cpp line 350
0x402040dd: WiFiClientSecure::connect(char const*, unsigned short) at C:\Users\DELL\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.4.1\libraries\ESP8266WiFi\src\WiFiClientSecure.cpp line 518
0x402068ec: HTTPClient::connect() at C:\Users\DELL\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.4.1\libraries\ESP8266HTTPClient\src\ESP8266HTTPClient.cpp line 845
0x402081a0: operator new(unsigned int) at C:\Users\DELL\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.4.1\cores\esp8266\abi.cpp line 30
0x402070dc: HTTPClient::sendRequest(char const*, unsigned char*, unsigned int) at C:\Users\DELL\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.4.1\libraries\ESP8266HTTPClient\src\ESP8266HTTPClient.cpp line 392
0x402049c7: std::basic_string  , std::allocator  >::_S_construct (char const*, char const*, std::allocator  const&) at c:\users\dell\appdata\local\arduino15\packages\esp8266\tools\xtensa-lx106-elf-gcc\1.20.0-26-gb404fb9-2\xtensa-lx106-elf\include\c++\4.8.2\bits/basic_string.tcc line 146
0x40204a20: std::string::_Rep::_M_destroy(std::allocator  const&) at c:\users\dell\appdata\local\arduino15\packages\esp8266\tools\xtensa-lx106-elf-gcc\1.20.0-26-gb404fb9-2\xtensa-lx106-elf\include\c++\4.8.2\bits/basic_string.tcc line 450
0x402059be: FirebaseHttpClientEsp8266::sendRequest(std::string const&, std::string const&) at C:\Users\DELL\Documents\Arduino\libraries\firebase-arduino-master\src\FirebaseHttpClient_Esp8266.cpp line 72
0x40204435: FirebaseCall::FirebaseCall(std::string const&, std::string const&, char const*, std::string const&, std::string const&, std::shared_ptr ) at C:\Users\DELL\Documents\Arduino\libraries\firebase-arduino-master\src\Firebase.cpp line 121
0x402083c8: esp_yield() at C:\Users\DELL\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.4.1\cores\esp8266\core_esp8266_main.cpp line 87
0x4021a278: ssl_read at ssl/tls1.c line 314
0x402059a8: FirebaseHttpClientEsp8266::sendRequest(std::string const&, std::string const&) at c:\users\dell\appdata\local\arduino15\packages\esp8266\tools\xtensa-lx106-elf-gcc\1.20.0-26-gb404fb9-2\xtensa-lx106-elf\include\c++\4.8.2\bits/basic_string.h line 293
0x40204a08: std::basic_string  , std::allocator  >::basic_string(char const*, std::allocator  const&) at c:\users\dell\appdata\local\arduino15\packages\esp8266\tools\xtensa-lx106-elf-gcc\1.20.0-26-gb404fb9-2\xtensa-lx106-elf\include\c++\4.8.2\bits/basic_string.tcc line 216
0x40204766: FirebaseGet::FirebaseGet(std::string const&, std::string const&, std::string const&, std::shared_ptr ) at c:\users\dell\appdata\local\arduino15\packages\esp8266\tools\xtensa-lx106-elf-gcc\1.20.0-26-gb404fb9-2\xtensa-lx106-elf\include\c++\4.8.2\bits/shared_ptr_base.h line 781
0x40204a5e: std::basic_string  , std::allocator  >::~basic_string() at c:\users\dell\appdata\local\arduino15\packages\esp8266\tools\xtensa-lx106-elf-gcc\1.20.0-26-gb404fb9-2\xtensa-lx106-elf\include\c++\4.8.2\bits/basic_string.h line 539
0x40204a08: std::basic_string  , std::allocator  >::basic_string(char const*, std::allocator  const&) at c:\users\dell\appdata\local\arduino15\packages\esp8266\tools\xtensa-lx106-elf-gcc\1.20.0-26-gb404fb9-2\xtensa-lx106-elf\include\c++\4.8.2\bits/basic_string.tcc line 216
0x4020509e: FirebaseArduino::getInt(String const&) at c:\users\dell\appdata\local\arduino15\packages\esp8266\tools\xtensa-lx106-elf-gcc\1.20.0-26-gb404fb9-2\xtensa-lx106-elf\include\c++\4.8.2\bits/shared_ptr_base.h line 781
0x4020782b: String::changeBuffer(unsigned int) at C:\Users\DELL\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.4.1\cores\esp8266\WString.cpp line 151
0x40106999: __digitalWrite at C:\Users\DELL\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.4.1\cores\esp8266\core_esp8266_wiring_digital.c line 84
0x402023fb: loop() at C:\Users\DELL\Documents\Arduino\trynodemcu/trynodemcu.ino line 58
0x402083e9: esp_schedule() at C:\Users\DELL\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.4.1\cores\esp8266\core_esp8266_main.cpp line 91
0x40208414: loop_wrapper() at C:\Users\DELL\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.4.1\cores\esp8266\core_esp8266_main.cpp line 121


I try to use the simple code from FirebaseDemo and it has the same error. Please help to fix this problem.