my project have this error like 10 mins after the code is running and its looping, like the code running again but then 10 mins later error again
- Guru Meditation Error: Core 1 panic'ed (Interrupt wdt timeout on CPU1).
- Core 1 register dump:
- PC : 0x400d3160 PS : 0x00060035 A0 : 0x800d2c78 A1 : 0x3ffc54e0
- A2 : 0x000032b2 A3 : 0x00000001 A4 : 0x3ffc1c60 A5 : 0x00000001
- A6 : 0x00060420 A7 : 0x00000001 A8 : 0x800d2b80 A9 : 0x000032b2
- A10 : 0x00000005 A11 : 0x00000000 A12 : 0x011142e5 A13 : 0x00000020
- A14 : 0x00000028 A15 : 0x003fffff SAR : 0x00000005 EXCCAUSE: 0x00000006
- EXCVADDR: 0x00000000 LBEG : 0x40085751 LEND : 0x40085759 LCOUNT : 0x00000027
- Backtrace: 0x400d315d:0x3ffc54e0 0x400d2c75:0x3ffc5500 0x400d2e69:0x3ffc5660 0x400d167b:0x3ffc5680 0x400d170b:0x3ffc56a0 0x400d4225:0x3ffc56c0
- Core 0 register dump:
- PC : 0x400f5b7e PS : 0x00060535 A0 : 0x800dc4d1 A1 : 0x3ffbcec0
- A2 : 0x00000000 A3 : 0x40086c94 A4 : 0x00060520 A5 : 0x80000000
- A6 : 0x007bf398 A7 : 0x003fffff A8 : 0x800dc0d2 A9 : 0x3ffbce90
- A10 : 0x00000000 A11 : 0x3ffbf394 A12 : 0x3ffbf394 A13 : 0x00000000
- A14 : 0x00060520 A15 : 0x00000000 SAR : 0x0000001d EXCCAUSE: 0x00000006
- EXCVADDR: 0x00000000 LBEG : 0x00000000 LEND : 0x00000000 LCOUNT : 0x00000000
- Backtrace: 0x400f5b7b:0x3ffbcec0 0x400dc4ce:0x3ffbcee0 0x4008aa41:0x3ffbcf00
- ELF file SHA256: edb769177ab717cc
- Rebooting...
- ets Jul 29 2019 12:21:46
- rst:0xc (SW_CPU_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
- configsip: 0, SPIWP:0xee
- clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
- mode:DIO, clock div:1
- load:0x3fff0030,len:1344
- load:0x40078000,len:13964
- load:0x40080400,len:3600
- entry 0x400805f0
- E (100) psram: PSRAM ID read error: 0xfffffff
- //#define BLYNK_TEMPLATE_ID "TMPL6S4jVtrpE"
- //#define BLYNK_TEMPLATE_NAME "Power Box"
- //#define BLYNK_AUTH_TOKEN "aW3hlV_wLSxG5jDedw6Re_DLOdcn3S8V"
- //#define BLYNK_PRINT Serial
- //#include <WiFi.h>
- //#include <WiFiClient.h>
- //#include <BlynkSimpleEsp32.h>
- #include <PZEM004Tv30.h>
- #include <ModbusMasterPzem017.h>
- #include <LiquidCrystal_I2C.h>
- #include "DHT.h"
- //char auth[] = BLYNK_AUTH_TOKEN ; // Put in the Auth Token for the project from Blynk. You should receive it in your email.
- //char ssid[] = "admin"; // Key in your wifi name. You can check with your smart phone for your wifi name
- //char pass[] = "admin123";
- static uint8_t pzemSlaveAddr = 0x01; //PZem Address
- static uint16_t NewshuntAddr = 0x0001; // Declare your external shunt value. Default is 100A, replace to "0x0001" if using 50A shunt, 0x0002 is for 200A, 0x0003 is for 300A
- #define RXD1 33
- #define TXD1 32
- #define PZEM_SERIAL Serial2
- #define DHTTYPE DHT22
- const int DHTPIN = 5;
- const int relay = 18;
- float pwr;
- float randnum;
- float PZEMVoltage = 0;
- float PZEMCurrent = 0;
- float PZEMPower = 0;
- float PZEMEnergy = 0;
- float vr, ir, freq, pf_r, energy, power;
- float t, h;
- uint8_t result;
- ModbusMaster node;
- //BlynkTimer timer;
- LiquidCrystal_I2C lcd(0x27, 20, 4);
- PZEM004Tv30 pzem_r(PZEM_SERIAL, RXD1, TXD1);
- DHT dht(DHTPIN, DHTTYPE);
- void baca_pzemdc() {
- result = node.readInputRegisters(0x0000, 6);
- }
- void baca_pzem() {
- vr = pzem_r.voltage();
- ir = pzem_r.current();
- freq = pzem_r.frequency();
- pf_r = pzem_r.pf();
- power = pzem_r.power();
- energy = pzem_r.energy();
- }
- void setShunt(uint8_t slaveAddr) {
- static uint8_t SlaveParameter = 0x06; /* Write command code to PZEM */
- static uint16_t registerAddress = 0x0003; /* change shunt register address command code */
- uint16_t u16CRC = 0xFFFF; /* declare CRC check 16 bits*/
- u16CRC = crc16_update(u16CRC, slaveAddr); // Calculate the crc16 over the 6bytes to be send
- u16CRC = crc16_update(u16CRC, SlaveParameter);
- u16CRC = crc16_update(u16CRC, highByte(registerAddress));
- u16CRC = crc16_update(u16CRC, lowByte(registerAddress));
- u16CRC = crc16_update(u16CRC, highByte(NewshuntAddr));
- u16CRC = crc16_update(u16CRC, lowByte(NewshuntAddr));
- Serial.println("Change shunt address");
- Serial1.write(slaveAddr); //these whole process code sequence refer to manual
- Serial1.write(SlaveParameter);
- Serial1.write(highByte(registerAddress));
- Serial1.write(lowByte(registerAddress));
- Serial1.write(highByte(NewshuntAddr));
- Serial1.write(lowByte(NewshuntAddr));
- Serial1.write(lowByte(u16CRC));
- Serial1.write(highByte(u16CRC));
- delay(10); delay(100);
- while (Serial1.available()) {
- Serial.print(char(Serial1 .read()), HEX); //Prints the response and display on Serial Monitor (Serial)
- Serial.print(" ");
- }
- } //setShunt Ends
- //void sendSensor() {
- // h = dht.readHumidity();
- // t = dht.readTemperature();
- // if (isnan(h) || isnan(t)) {
- // Serial.println(F("Failed to read from DHT sensor!"));
- // return;
- // }
- // // Blynk.virtualWrite(V0, PZEMVoltage);
- // // Blynk.virtualWrite(V1, PZEMCurrent);
- // // Blynk.virtualWrite(V2, pwr);
- // // Blynk.virtualWrite(V5, vr);
- // // Blynk.virtualWrite(V6, ir);
- // // Blynk.virtualWrite(V7, power);
- //}
- void setup() {
- Serial.begin(115200);
- dht.begin();
- lcd.init();
- lcd.backlight();
- Serial2.begin(9600, SERIAL_8N2, RXD1, TXD1);
- Serial1.begin(9600, SERIAL_8N2, 26, 27);
- setShunt(pzemSlaveAddr);
- node.begin(pzemSlaveAddr, Serial1);
- // Blynk.begin(auth, ssid, pass);
- // timer.setInterval(100L, sendSensor);
- pinMode(relay, OUTPUT);
- digitalWrite(relay, HIGH);
- lcd.setCursor(0, 0); lcd.print("Standby...");
- delay(1000);
- lcd.clear();
- }
- void loop() {
- // Blynk.run();
- // timer.run();
- // sendSensor();
- baca_pzem();
- baca_pzemdc();
- // setShunt();
- h = dht.readHumidity();
- t = dht.readTemperature();
- if (isnan(h) || isnan(t)) {
- Serial.println(F("Failed to read from DHT sensor!"));
- return;
- }
- if (t < 30) {
- digitalWrite(relay, LOW);
- }
- else {
- digitalWrite(relay, HIGH);
- }
- lcd.setCursor(0, 0); lcd.print("DCV:"); lcd.print(PZEMVoltage, 1); lcd.print(" V ");
- lcd.setCursor(8, 0); lcd.print("DCCur:"); lcd.print(PZEMCurrent, 3); lcd.print("A ");
- lcd.setCursor(0, 1); lcd.print("DCPow:"); lcd.print(pwr, 2); lcd.print(" W ");
- lcd.setCursor(0, 2); lcd.print("ACV:"); lcd.print(vr, 1); lcd.print(" V ");
- lcd.setCursor(8, 2); lcd.print("ACCur:"); lcd.print(ir, 3); lcd.print("A ");
- lcd.setCursor(8, 1); lcd.print("ACPow: "); lcd.print(power, 2); lcd.print(" W ");
- if (result == node.ku8MBSuccess) {
- uint32_t tempdouble = 0x00000000;
- PZEMVoltage = node.getResponseBuffer(0x0000) / 100.0;
- PZEMCurrent = (node.getResponseBuffer(0x0001) / 100.0);
- tempdouble = (node.getResponseBuffer(0x0003) << 16) + node.getResponseBuffer(0x0002); // get the power value. Power value is consists of 2 parts (2 digits of 16 bits in front and 2 digits of 16 bits at the back) and combine them to an unsigned 32bit
- PZEMPower = tempdouble / 10.0; //Divide the value by 10 to get actual power value (as per manual)
- tempdouble = (node.getResponseBuffer(0x0005) << 16) + node.getResponseBuffer(0x0004); //get the energy value. Energy value is consists of 2 parts (2 digits of 16 bits in front and 2 digits of 16 bits at the back) and combine them to an unsigned 32bit
- PZEMEnergy = tempdouble;
- // PZEMCurrent = PZEMVoltage * 0.308;
- Serial.print(PZEMVoltage, 1); //Print Voltage value on Serial Monitor with 1 decimal*/
- Serial.print("V ");
- Serial.print(PZEMCurrent, 5); Serial.print("A ");
- Serial.print(PZEMPower, 1); Serial.print("W ");
- Serial.print(PZEMEnergy, 0); Serial.print("Wh ");
- Serial.println();
- }
- else {
- Serial.println("Failed to read modbus");
- }
- Serial.print("Volt: "); Serial.print(vr, 2); Serial.print("V, ");
- Serial.print("curr: "); Serial.print(ir, 3); Serial.print("A, ");
- Serial.print("pf: "); Serial.print(pf_r); Serial.println("%, ");
- Serial.print("Power: "); Serial.print(power); Serial.print("W, ");
- Serial.print("Energy: "); Serial.print(energy, 3); Serial.print("kWh, ");
- Serial.print("freq: "); Serial.print(freq, 1); Serial.print("Hz, ");
- Serial.print("Temp: "); Serial.print(t); Serial.print("C, ");
- Serial.print("Humid: "); Serial.print(h); Serial.println("%, ");
- Serial.println();
- delay(1000);
- }
regards,
james