Hello Blynk Community
Trying to get my program to work on the ESP32 has been a complete nightmare.
After the program compiled I began functional testing and was immediately met with a error message on the serial monitor on start up:
Light Control System Version 1_7 (ESP32)
Guru Meditation Error: Core 1 panic'ed (LoadProhibited). Exception was unhandled.
Core 1 register dump:
PC : 0x401403fa PS : 0x00060630 A0 : 0x800d191b A1 : 0x3ffb1f10
A2 : 0x3ffc1400 A3 : 0x00000000 A4 : 0x3ffc1308 A5 : 0x00000b97
A6 : 0x00060420 A7 : 0x00000000 A8 : 0x00000000 A9 : 0x3ffb1ef0
A10 : 0x00000000 A11 : 0x00000000 A12 : 0x00000b97 A13 : 0x00004340
A14 : 0x00000000 A15 : 0x00000002 SAR : 0x0000000a EXCCAUSE: 0x0000001c
EXCVADDR: 0x00000000 LBEG : 0x401407f8 LEND : 0x40140801 LCOUNT : 0x0000000f
Backtrace: 0x401403fa:0x3ffb1f10 0x400d1918:0x3ffb1f30 0x400d1f95:0x3ffb1f50 0x400d3d69:0x3ffb1f90 0x400d6541:0x3ffb1fb0 0x40088f49:0x3ffb1fd0
Rebooting...
ets Jun 8 2016 00:22:57
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:0x3fff0018,len:4
load:0x3fff001c,len:1216
ho 0 tail 12 room 4
load:0x40078000,len:9720
ho 0 tail 12 room 4
load:0x40080400,len:6352
entry 0x400806b8
Establishing connections...
Light Control System Version 1_7 (ESP32)
Guru Meditation Error: Core 1 panic'ed (LoadProhibited). Exception was unhandled.
Core 1 register dump:
PC : 0x401403fa PS : 0x00060630 A0 : 0x800d191b A1 : 0x3ffb1f10
A2 : 0x3ffc1400 A3 : 0x00000000 A4 : 0x3ffc1308 A5 : 0x00000b32
A6 : 0x00060420 A7 : 0x00000000 A8 : 0x00000000 A9 : 0x3ffb1ef0
A10 : 0x00000000 A11 : 0x00000000 A12 : 0x00000b32 A13 : 0x00004380
A14 : 0x00000000 A15 : 0x00000002 SAR : 0x0000000a EXCCAUSE: 0x0000001c
EXCVADDR: 0x00000000 LBEG : 0x401407f8 LEND : 0x40140801 LCOUNT : 0x0000000f
Backtrace: 0x401403fa:0x3ffb1f10 0x400d1918:0x3ffb1f30 0x400d1f95:0x3ffb1f50 0x400d3d69:0x3ffb1f90 0x400d6541:0x3ffb1fb0 0x40088f49:0x3ffb1fd0
Rebooting...
ets Jun 8 2016 00:22:57
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:0x3fff0018,len:4
load:0x3fff001c,len:1216
ho 0 tail 12 room 4
load:0x40078000,len:9720
ho 0 tail 12 room 4
load:0x40080400,len:6352
entry 0x400806b8
I tried looking through a few ESP32 support forums the last few days to see if someone experienced similar problems but after struggling to understand the comments/suggestions people had offered I eventually gave up and then tried to run my program in smaller chunks to see where the problem lay. I started with this program which worked perfectly:
/*************************************************************
Download latest Blynk library here:
https://github.com/blynkkk/blynk-library/releases/latest
Blynk is a platform with iOS and Android apps to control
Arduino, Raspberry Pi and the likes over the Internet.
You can easily build graphic interfaces for all your
projects by simply dragging and dropping widgets.
Downloads, docs, tutorials: http://www.blynk.cc
Sketch generator: http://examples.blynk.cc
Blynk community: http://community.blynk.cc
Follow us: http://www.fb.com/blynkapp
http://twitter.com/blynk_app
Blynk library is licensed under MIT license
This example code is in public domain.
*************************************************************
You’ll need:
- Blynk App (download from AppStore or Google Play)
- ESP32 board
- Decide how to connect to Blynk
(USB, Ethernet, Wi-Fi, Bluetooth, ...)
There is a bunch of great example sketches included to show you how to get
started. Think of them as LEGO bricks and combine them as you wish.
For example, take the Ethernet Shield sketch and combine it with the
Servo example, or choose a USB sketch and add a code from SendData
example.
*************************************************************/
/* Comment this out to disable prints and save space */
//#define BLYNK_PRINT Serial
#include <WiFi.h>
#include <WiFiClient.h>
#include <BlynkSimpleEsp32.h>
byte SwitchLED=0;
void SwitchLEDState();
// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "XXXXXXXXXXXXX";
// Your WiFi credentials.
// Set password to "" for open networks.
//*HOME*
char ssid0[] = "XXXXXXXXXXX";
char pass0[] = "XXXXXXXXXXX";
void setup()
{
// Debug console
Serial.begin(115200);
Serial.println("Establishing connections...");
Blynk.begin(auth, ssid0, pass0);
Serial.println("ESP32 Blynk test code: Switching on Button widget with another button widget");
Blynk.notify("Test program ready");
}
void loop()
{
Blynk.run();
// You can inject your own code or combine it with other sketches.
// Check other examples on how to communicate with Blynk. Remember
// to avoid delay() function!
}
//__________________________Test code__________________________________________________________________________________
void SwitchLEDState(){
if(SwitchLED==1){
Blynk.virtualWrite(V7,1); //Switch LEDOn
Serial.println("LED On");
}
else if(SwitchLED==0){
Blynk.virtualWrite(V7,0); //SwitchLEDoff
Serial.println("LED Off");
}
}
BLYNK_WRITE(V8){
if(SwitchLED==1){
SwitchLED=0;
Serial.println("Push Button switched Off");
}
else if(SwitchLED==0){
SwitchLED=1;
Serial.println("Push Button switched On");
}
SwitchLEDState();
}
//____________________________________________________________________________________________________________________
I then tried the following program because I thought maybe there is some conflict with the ESP32 and the FastLED code but it too worked perfectly:
#include <FastLED.h>
#define LED_PIN 18
#define NUM_LEDS 30
#define BRIGHTNESS 255
#define LED_TYPE WS2811
#define COLOR_ORDER GRB
CRGB leds[NUM_LEDS];
#define UPDATES_PER_SECOND 100
// This example shows several ways to set up and use 'palettes' of colors
// with FastLED.
//
// These compact palettes provide an easy way to re-colorize your
// animation on the fly, quickly, easily, and with low overhead.
//
// USING palettes is MUCH simpler in practice than in theory, so first just
// run this sketch, and watch the pretty lights as you then read through
// the code. Although this sketch has eight (or more) different color schemes,
// the entire sketch compiles down to about 6.5K on AVR.
//
// FastLED provides a few pre-configured color palettes, and makes it
// extremely easy to make up your own color schemes with palettes.
//
// Some notes on the more abstract 'theory and practice' of
// FastLED compact palettes are at the bottom of this file.
CRGBPalette16 currentPalette;
TBlendType currentBlending;
extern CRGBPalette16 myRedWhiteBluePalette;
extern const TProgmemPalette16 myRedWhiteBluePalette_p PROGMEM;
void setup() {
Serial.begin(115200);
Serial.println("FastLED test code");
delay( 3000 ); // power-up safety delay
FastLED.addLeds<LED_TYPE, LED_PIN, COLOR_ORDER>(leds, NUM_LEDS).setCorrection( TypicalLEDStrip );
FastLED.setBrightness( BRIGHTNESS );
currentPalette = RainbowColors_p;
currentBlending = LINEARBLEND;
}
void loop()
{
ChangePalettePeriodically();
static uint8_t startIndex = 0;
startIndex = startIndex + 1; /* motion speed */
FillLEDsFromPaletteColors( startIndex);
FastLED.show();
FastLED.delay(1000 / UPDATES_PER_SECOND);
}
void FillLEDsFromPaletteColors( uint8_t colorIndex)
{
uint8_t brightness = 255;
for( int i = 0; i < NUM_LEDS; i++) {
leds[i] = ColorFromPalette( currentPalette, colorIndex, brightness, currentBlending);
colorIndex += 3;
}
}
// There are several different palettes of colors demonstrated here.
//
// FastLED provides several 'preset' palettes: RainbowColors_p, RainbowStripeColors_p,
// OceanColors_p, CloudColors_p, LavaColors_p, ForestColors_p, and PartyColors_p.
//
// Additionally, you can manually define your own color palettes, or you can write
// code that creates color palettes on the fly. All are shown here.
void ChangePalettePeriodically()
{
uint8_t secondHand = (millis() / 1000) % 60;
static uint8_t lastSecond = 99;
if( lastSecond != secondHand) {
lastSecond = secondHand;
if( secondHand == 0) { currentPalette = RainbowColors_p; currentBlending = LINEARBLEND; }
if( secondHand == 10) { currentPalette = RainbowStripeColors_p; currentBlending = NOBLEND; }
if( secondHand == 15) { currentPalette = RainbowStripeColors_p; currentBlending = LINEARBLEND; }
if( secondHand == 20) { SetupPurpleAndGreenPalette(); currentBlending = LINEARBLEND; }
if( secondHand == 25) { SetupTotallyRandomPalette(); currentBlending = LINEARBLEND; }
if( secondHand == 30) { SetupBlackAndWhiteStripedPalette(); currentBlending = NOBLEND; }
if( secondHand == 35) { SetupBlackAndWhiteStripedPalette(); currentBlending = LINEARBLEND; }
if( secondHand == 40) { currentPalette = CloudColors_p; currentBlending = LINEARBLEND; }
if( secondHand == 45) { currentPalette = PartyColors_p; currentBlending = LINEARBLEND; }
if( secondHand == 50) { currentPalette = myRedWhiteBluePalette_p; currentBlending = NOBLEND; }
if( secondHand == 55) { currentPalette = myRedWhiteBluePalette_p; currentBlending = LINEARBLEND; }
}
}
// This function fills the palette with totally random colors.
void SetupTotallyRandomPalette()
{
for( int i = 0; i < 16; i++) {
currentPalette[i] = CHSV( random8(), 255, random8());
}
}
// This function sets up a palette of black and white stripes,
// using code. Since the palette is effectively an array of
// sixteen CRGB colors, the various fill_* functions can be used
// to set them up.
void SetupBlackAndWhiteStripedPalette()
{
// 'black out' all 16 palette entries...
fill_solid( currentPalette, 16, CRGB::Black);
// and set every fourth one to white.
currentPalette[0] = CRGB::White;
currentPalette[4] = CRGB::White;
currentPalette[8] = CRGB::White;
currentPalette[12] = CRGB::White;
}
// This function sets up a palette of purple and green stripes.
void SetupPurpleAndGreenPalette()
{
CRGB purple = CHSV( HUE_PURPLE, 255, 255);
CRGB green = CHSV( HUE_GREEN, 255, 255);
CRGB black = CRGB::Black;
currentPalette = CRGBPalette16(
green, green, black, black,
purple, purple, black, black,
green, green, black, black,
purple, purple, black, black );
}
// This example shows how to set up a static color palette
// which is stored in PROGMEM (flash), which is almost always more
// plentiful than RAM. A static PROGMEM palette like this
// takes up 64 bytes of flash.
const TProgmemPalette16 myRedWhiteBluePalette_p PROGMEM =
{
CRGB::Red,
CRGB::Gray, // 'white' is too bright compared to red and blue
CRGB::Blue,
CRGB::Black,
CRGB::Red,
CRGB::Gray,
CRGB::Blue,
CRGB::Black,
CRGB::Red,
CRGB::Red,
CRGB::Gray,
CRGB::Gray,
CRGB::Blue,
CRGB::Blue,
CRGB::Black,
CRGB::Black
};
// Additional notes on FastLED compact palettes:
//
// Normally, in computer graphics, the palette (or "color lookup table")
// has 256 entries, each containing a specific 24-bit RGB color. You can then
// index into the color palette using a simple 8-bit (one byte) value.
// A 256-entry color palette takes up 768 bytes of RAM, which on Arduino
// is quite possibly "too many" bytes.
//
// FastLED does offer traditional 256-element palettes, for setups that
// can afford the 768-byte cost in RAM.
//
// However, FastLED also offers a compact alternative. FastLED offers
// palettes that store 16 distinct entries, but can be accessed AS IF
// they actually have 256 entries; this is accomplished by interpolating
// between the 16 explicit entries to create fifteen intermediate palette
// entries between each pair.
//
// So for example, if you set the first two explicit entries of a compact
// palette to Green (0,255,0) and Blue (0,0,255), and then retrieved
// the first sixteen entries from the virtual palette (of 256), you'd get
// Green, followed by a smooth gradient from green-to-blue, and then Blue.
Since the previous 2 programs worked, I had combined the first program with a simplified version of the second:
#include <Blynk.h>
#include <WiFi.h>
#include <WiFiClient.h>
#include <BlynkSimpleEsp32.h>
#include <FastLED.h>
#define DATA_PIN 18
#define NUM_LEDS 30
CRGB leds[NUM_LEDS];
int SwitchLED=0;
void SwitchLEDState();
char auth[] = "XXXXXXXXXXXXXXXXXXX";
byte RGBColourReset=0; //Used to control the execution of normalising the LED colours
byte r1=0,g1=0,b1=0; //Stores RGB command from Blynk app and writes it to the LED strip1
void ChangeLEDColour();
byte PBIncLight1=19; //2
byte PBDecLight1=20; //4
byte PBIncLight2=21; //A0
byte PBDecLight2=22; //A1
byte PBHardNormLight1=23; //A2
byte PBHardNormLight2=24; //A3
//*HOME*
char ssid0[] = "XXXXXXXXXXXX";
char pass0[] = "XXXXXXXXXXXX";
//*PHONE 1 MOBILE HOT SPOT*
char ssid1[] = "XXXXXXXXXXXX";
char pass1[] = "XXXXXXXXXXXX";
void UpButtonPress1();
void DownButtonPress1();
void UpButtonPress2();
void DownButtonPress2();
void HardwarePushbuttons();
void DisplayLEDBarGraphs();
void DisplayToSerialMonitor();
int n=0;
BlynkTimer timer1;
void setup() {
delay(1000);
Serial.begin(115200);
delay(1000);
Serial.println ("Establishing connections...");
//For Blynk communication
Blynk.begin(auth, ssid0, pass0);
pinMode(PBIncLight1, INPUT_PULLUP); //Button press to increase lamp1 light
pinMode(PBDecLight1, INPUT_PULLUP); //Button press to decrease lamp1 light
pinMode(PBIncLight2, INPUT_PULLUP); //Button press to increase lamp2 light
pinMode(PBDecLight2, INPUT_PULLUP); //Button press to decrease lamp2 light
pinMode(PBHardNormLight1,INPUT_PULLUP); //Hardware normalises the LED strip 1 to white
pinMode(PBHardNormLight2,INPUT_PULLUP); //Hardware normalises the LED strip 2 to white
FastLED.addLeds<WS2812, DATA_PIN, GRB>(leds, NUM_LEDS);
Serial.println ("LED Bar graph test program including Blynk control (version 3_1)_ESP32");
timer1.setInterval(300L, HardwarePushbuttons);
}
void loop() {
Blynk.run();
timer1.run();
}
void HardwarePushbuttons(){
//For lamp 1
if(digitalRead(19)==LOW){
UpButtonPress1();
}
else if(digitalRead(20)==LOW){
DownButtonPress1();
}
//For lamp 2
if(digitalRead(21)==LOW){
UpButtonPress2();
}
else if(digitalRead(22)==LOW){
DownButtonPress2();
}
}
void UpButtonPress1(){
Serial.println("UpButton1 was pressed");
}
void DownButtonPress1(){
Serial.println("DownButton1 was pressed");
}
void UpButtonPress2(){
Serial.println("UpButton2 was pressed");
}
void DownButtonPress2(){
Serial.println("DownButton2 was pressed");
}
BLYNK_WRITE(V2){
UpButtonPress1();
}
BLYNK_WRITE(V3){
DownButtonPress1();
}
BLYNK_WRITE(V8){
UpButtonPress2();
}
BLYNK_WRITE(V9){
DownButtonPress2();
}
//ZeRGB widget 1
BLYNK_WRITE(V5){
//Set RGB to be white
r1=255;g1=255;b1=255;
//Update the ZeRGB widget
ChangeLEDColour();
}
BLYNK_WRITE(V11) // zeRGBa LED strip 1 assigned
{
// get a RED channel value
r1 = param[0].asInt();
// get a GREEN channel value
g1 = param[1].asInt();
// get a BLUE channel value
b1 = param[2].asInt();
ChangeLEDColour();
}
void ChangeLEDColour(){
//Change colour of the LEDs for strip 1
for(n=NUM_LEDS;n<=NUM_LEDS;n++){
leds[n]=CRGB(r1,g1,b1);
FastLED.show();
}
//For debugging
Serial.print("Red= ");
Serial.println(r1);
Serial.print("Green= ");
Serial.println(g1);
Serial.print("Blue= ");
Serial.println(b1);
Serial.println("");
}
//Executes when the hardware connects to the app
BLYNK_CONNECTED(){
Blynk.notify("Light system connected");
//Serial.println("Light system Connected");
}
void SwitchLEDState(){
if(SwitchLED==1){
Blynk.virtualWrite(V8,255); //Switch LEDOn
Serial.println("LED On");
}
else if(SwitchLED==0){
Blynk.virtualWrite(V8,0); //SwitchLEDoff
Serial.println("LED Off");
}
}
BLYNK_WRITE(V7){
if(SwitchLED==1){
SwitchLED=0;
Serial.println("Push Button switched Off");
}
else if(SwitchLED==0){
SwitchLED=1;
Serial.println("Push Button switched On");
}
SwitchLEDState();
}
For some reason this program, although it compiles and a connection to Blynk is established, crashes whenever i toggle the ZeRGB widget to change the colour and it never switches the LED strip on. The controller reboots and starts the program over. When i toggle the pushbutton V7 then the pushbutton V8 does not switch On. The following is printed on the serial monitor:
Guru Meditation Error: Core 1 panic'ed (LoadProhibited). Exception was unhandled.
Core 1 register dump:
PC : 0x40088c3a PS : 0x00060630 A0 : 0x800d2261 A1 : 0x3ffb1d50
A2 : 0x0000007b A3 : 0x00000000 A4 : 0xffffffff A5 : 0x00000000
A6 : 0x00000000 A7 : 0x00000004 A8 : 0x00000000 A9 : 0x00000000
A10 : 0x00000000 A11 : 0x00060423 A12 : 0x00000050 A13 : 0x3ffc1410
A14 : 0x00000000 A15 : 0x00000000 SAR : 0x0000000a EXCCAUSE: 0x0000001c
EXCVADDR: 0x000000bb LBEG : 0x400014fd LEND : 0x4000150d LCOUNT : 0xffffffff
Backtrace: 0x40088c3a:0x3ffb1d50 0x400d225e:0x3ffb1d90 0x400d2071:0x3ffb1db0 0x400d3915:0x3ffb1df0 0x400d1269:0x3ffb1e30 0x400d131e:0x3ffb1e50 0x400d157a:0x3ffb1e80 0x400d182d:0x3ffb1ee0 0x400d1a9b:0x3ffb1f50 0x400d1f1d:0x3ffb1f90 0x400d43c1:0x3ffb1fb0 0x40088f49:0x3ffb1fd0
Rebooting...
ets Jun 8 2016 00:22:57
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:0x3fff0018,len:4
load:0x3fff001c,len:1216
ho 0 tail 12 room 4
load:0x40078000,len:9720
ho 0 tail 12 room 4
load:0x40080400,len:6352
entry 0x400806b8
Establishing connections...
LED Bar graph test program including Blynk control (version 3_1)_ESP32
I can’t understand what is it that is about toggling Blynk functions that is causing the project to crash. Please, anyone who has experience with the ESP32 please advice.