Hello, this is my first post so I hope I’m doing everything properly.
I’m setting up an ESP-12F with a servomotor to control an analogic thermostate.
As there are no power sockets near where it will be installed I will use a LiFePo4 batery to power it, which means: deep sleep.
I have sucessfully installed and configured the blynkEdgent example (I need OTA updates) and it works properly when the code is constantly run without the deep sleep. But once I add it, anytime I tries to go into deep sleep, the board reboots and the following exception is thrown:
Exception 28: LoadProhibited: A load referenced a page mapped with an attribute that does not permit loads
PC: 0x4000df2f
EXCVADDR: 0x00000033
Decoding stack results
0x40100a48: pvPortMalloc(size_t, char const*, int) at C:\Users\ssbj\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.0.2\cores\esp8266\umm_malloc/umm_heap_select.h line 85
0x4021cd2d: _svfprintf_r at /workdir/repo/newlib/newlib/libc/stdio/nano-vfprintf.c line 662
0x4020a9d2: ESP8266WiFiSTAClass::begin(char const*, char const*, int, unsigned char const*, bool) at C:\Users\ssbj\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.0.2\libraries\ESP8266WiFi\src\ESP8266WiFiSTA.cpp line 198
0x4020a8fb: ESP8266WiFiSTAClass::begin(char const*, char const*, int, unsigned char const*, bool) at C:\Users\ssbj\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.0.2\libraries\ESP8266WiFi\src\ESP8266WiFiSTA.cpp line 154
0x4010114c: realloc(void*, size_t) at C:\Users\ssbj\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.0.2\cores\esp8266\umm_malloc\umm_malloc.cpp line 853
0x40100f0b: umm_free_core(umm_heap_context_t*, void*) at C:\Users\ssbj\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.0.2\cores\esp8266\umm_malloc\umm_malloc.cpp line 549
0x40101114: malloc(size_t) at C:\Users\ssbj\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.0.2\cores\esp8266\umm_malloc\umm_malloc.cpp line 821
0x401010ea: free(void*) at C:\Users\ssbj\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.0.2\cores\esp8266\umm_malloc\umm_malloc.cpp line 595
0x40100a6c: vPortFree(void*, char const*, int) at C:\Users\ssbj\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.0.2\cores\esp8266\heap.cpp line 322
0x402270ec: mem_free at core/mem.c line 236
0x40220c62: pbuf_free_LWIP2 at core/pbuf.c line 786
0x402242ed: dhcp_renew at core/ipv4/dhcp.c line 1196
0x4020aa28: ESP8266WiFiSTAClass::begin(char*, char*, int, unsigned char const*, bool) at C:\Users\ssbj\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.0.2\libraries\ESP8266WiFi\src\ESP8266WiFiSTA.cpp line 212
0x402030dc: enterConnectNet() at C:\Users\ssbj\Documents\Arduino\Termostato_new/ConfigMode.h line 361
0x40100821: millis() at C:\Users\ssbj\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.0.2\cores\esp8266\core_esp8266_wiring.cpp line 193
0x40100821: millis() at C:\Users\ssbj\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.0.2\cores\esp8266\core_esp8266_wiring.cpp line 193
0x402138b4: uart_rx_available(uart_t*) at C:\Users\ssbj\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.0.2\cores\esp8266\uart.cpp line 228
0x4020e980: HardwareSerial::available() at C:\Users\ssbj\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.0.2\cores\esp8266\HardwareSerial.cpp line 111
0x40202e10: BlynkConsole::run() at C:\Users\ssbj\Documents\Arduino\libraries\Blynk\src/Blynk/BlynkConsole.h line 190
0x40208fee: BlynkTimer::run() at C:\Users\ssbj\Documents\Arduino\libraries\Blynk\src\utility\BlynkTimer.cpp line 60
0x4020a808: ESP8266WiFiSTAClass::status() at C:\Users\ssbj\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.0.2\libraries\ESP8266WiFi\src\ESP8266WiFiSTA.cpp line 527
0x40208e6d: loop() at C:\Users\ssbj\Documents\Arduino\Termostato_new/BlynkEdgent.h line 106
0x4021229c: loop_wrapper() at C:\Users\ssbj\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.0.2\cores\esp8266\core_esp8266_main.cpp line 201
The code I’m running is the following:
// Fill-in information from your Blynk Template here
#define BLYNK_TEMPLATE_ID "TMPLHb0atsOI"
#define BLYNK_DEVICE_NAME "Termostato"
#define BLYNK_FIRMWARE_VERSION "0.1.0"
#define BLYNK_PRINT Serial
//#define BLYNK_DEBUG
#define APP_DEBUG
// Uncomment your board, or configure a custom board in Settings.h
//#define USE_SPARKFUN_BLYNK_BOARD
//#define USE_NODE_MCU_BOARD
//#define USE_WITTY_CLOUD_BOARD
//#define USE_WEMOS_D1_MINI
#include "BlynkEdgent.h"
#define SLEEP_LENGTH 10 // In seconds
#include <Servo.h>
#define servoPin 5
Servo myservo;
int servoAngle;
int tempObj;
int tempSer;
BlynkTimer timer;
BLYNK_CONNECTED() {
Serial.println("BLYNK_CONNECTED");
Blynk.syncVirtual(V0,V1);
timer.setInterval(1000L,getData);
}
BLYNK_WRITE(V0) {tempObj = param.asInt();}
BLYNK_WRITE(V1) {tempSer = param.asInt();}
void updateServo(int temp){
Serial.println("Moving servo!");
servoAngle = map(temp, 5, 30, 0, 180);
myservo.write(servoAngle);
}
void deepSleep(){
Serial.println("Going to sleep.");
Blynk.disconnect();
ESP.deepSleep(SLEEP_LENGTH * 1000000, WAKE_RF_DEFAULT);
}
void getData() {
Serial.println("Getting data.");
Serial.print("Temperature in server: ");
Serial.println(tempSer);
Serial.print("Received temperature: ");
Serial.println(tempObj);
if (tempObj != tempSer){
Serial.println("Updating temperature!");
Blynk.virtualWrite(V1, tempObj);
updateServo(tempSer);
myservo.attach(servoPin, 500, 2700);
updateServo(tempObj);
}
timer.setInterval(500L,deepSleep);
}
void setup()
{
Serial.begin(115200);
delay(100);
BlynkEdgent.begin();
}
void loop() {
BlynkEdgent.run();
timer.run();
}
The idea is for the servo motor to only move when the value in the blynk app changes (the functionality of the code works properly, I think it is just the deep sleep and the timers that make it crash for some reason).
I have searched the forums back and forth to look for a similar problem to the one I’m running into with no luck so I hope anyone can give me a hand .