Hello Pete
First let me apologize because what I am about to ask is not a Blynk related issue. But since you have experience with the ESP range of controllers and already have seen what I am trying to achieve, I would like some advice and assistance. I am stuck at the moment trying to get my code to compile for the ESP32 board that I am transitioning to from the Arduino Mega. My program compiles and runs on the Mega but does not compile for the ESP32. This is the error message that is produced:
In file included from C:\Users\Hp Zbook 15\Desktop\Light Control Project\BedSideLightControlExampleV1_7_AddingWS2812LEDControl\BedSideLightControlExampleV1_7_AddingWS2812LEDControl.ino:25:0:
C:\Users\Hp Zbook 15\Documents\Arduino\libraries\FastLED/FastLED.h:14:21: note: #pragma message: FastLED version 3.003.002
# pragma message "FastLED version 3.003.002"
^
In file included from C:\Users\Hp Zbook 15\Documents\Arduino\libraries\FastLED/FastLED.h:65:0,
from C:\Users\Hp Zbook 15\Desktop\Light Control Project\BedSideLightControlExampleV1_7_AddingWS2812LEDControl\BedSideLightControlExampleV1_7_AddingWS2812LEDControl.ino:25:
C:\Users\Hp Zbook 15\Documents\Arduino\libraries\FastLED/fastspi.h:130:23: note: #pragma message: No hardware SPI pins defined. All SPI access will default to bitbanged output
# pragma message "No hardware SPI pins defined. All SPI access will default to bitbanged output"
^
In file included from C:\Users\Hp Zbook 15\Documents\Arduino\libraries\FastLED/FastLED.h:48:0,
from C:\Users\Hp Zbook 15\Desktop\Light Control Project\BedSideLightControlExampleV1_7_AddingWS2812LEDControl\BedSideLightControlExampleV1_7_AddingWS2812LEDControl.ino:25:
C:\Users\Hp Zbook 15\Documents\Arduino\libraries\FastLED/fastpin.h: In instantiation of 'class FastPin<24u>':
C:\Users\Hp Zbook 15\Documents\Arduino\libraries\FastLED/platforms/esp/32/clockless_rmt_esp32.h:178:23: required from 'class ClocklessController<24, 60, 150, 90, (EOrder)66u, 0, false, 5>'
C:\Users\Hp Zbook 15\Documents\Arduino\libraries\FastLED/chipsets.h:582:7: required from 'class WS2812Controller800Khz<24u, (EOrder)66u>'
C:\Users\Hp Zbook 15\Documents\Arduino\libraries\FastLED/FastLED.h:103:52: required from 'class WS2812<24u, (EOrder)66u>'
C:\Users\Hp Zbook 15\Documents\Arduino\libraries\FastLED/FastLED.h:302:39: required from 'static CLEDController& CFastLED::addLeds(CRGB*, int, int) [with CHIPSET = WS2812; unsigned char DATA_PIN = 24u; EOrder RGB_ORDER = (EOrder)66u]'
C:\Users\Hp Zbook 15\Desktop\Light Control Project\BedSideLightControlExampleV1_7_AddingWS2812LEDControl\BedSideLightControlExampleV1_7_AddingWS2812LEDControl.ino:201:56: required from here
C:\Users\Hp Zbook 15\Documents\Arduino\libraries\FastLED/fastpin.h:207:2: error: static assertion failed: Invalid pin specified
static_assert(validpin(), "Invalid pin specified");
^
Multiple libraries were found for "BlynkSimpleEsp32.h"
Used: C:\Users\Hp
Multiple libraries were found for "LedControl.h"
Used: C:\Users\Hp
Multiple libraries were found for "FastLED.h"
Used: C:\Users\Hp
Multiple libraries were found for "WiFi.h"
Used: C:\Users\Hp
Not used: C:\Program
exit status 1
Error compiling for board ESP32 Dev Module.
The line being referred to by C:\Users\Hp Zbook 15\Desktop\Light Control Project\BedSideLightControlExampleV1_7_AddingWS2812LEDControl\BedSideLightControlExampleV1_7_AddingWS2812LEDControl.ino:201:56: required from here
is actually this line in my program FastLED.addLeds<WS2812, DATA_PIN, GRB>(leds, NUM_LEDS);
Strange thing is that the āBlinkā example code on github,here., which uses the same line of code, compiles successfully
Hereās my variable declaration, setup and loop programming code:
//#define BLYNK_PRINT Serial
//#include <Blynk.h>
#include <FastLED.h>
#include <WiFi.h>
#include <WiFiClient.h>
#include <BlynkSimpleEsp32.h>
#define DATA_PIN 24
#define NUM_LEDS 30
#define NUM_LEDS1 14
#define NUM_LEDS2 15
CRGB leds[NUM_LEDS];
char auth[] = "XXXXXXXXXXXXXXXXXXXX";
String Lamp1="XXXXXXX";
String Lamp2="XXXXXXX";
byte PBIncLight1=18; //2
byte PBDecLight1=19; //4
byte PBIncLight2=20; //A0
byte PBDecLight2=21; //A1
byte PBHardNormLight1=22; //A2
byte PBHardNormLight2=23; //A3
void BlynkComms();
byte counter1=0; //Used to control the execution of the brightness display on the app and LED bar graph
byte RGBColourReset=0; //Used to control the execution of normalising the LED colours
byte r1=255,g1=255,b1=255; //Stores RGB command from Blynk app and writes it to the LED strip1
byte r2=255,g2=255,b2=255; //Stores RGB command from Blynk app and writes it to the LED strip2
byte r=255,g=255,b=255;
byte ResetRGB1=0; //For ZeRGB widget 1
byte ResetRGB2=0; //For ZeRGB widget 2
void ChangeLEDColour1(); //Subroutine responsible for changing the RGB LED strip1 colour
void ChangeLEDColour2(); //Subroutine responsible for changing the RGB LED strip2 colour
void ChangeLEDColour(); //This changes the colour of the whole strip
byte BrightnessSlider1=0; //Blynk slider widget used to select the brightness setting of LED strip 1
byte BrightnessSlider2=0; //Blynk slider widget used to select the brightness setting of LED strip 2
byte ConfigureBrightnessDisplay1=0; //Controls the updating of the brightness display widget 1 so blynk app is not flooded
byte ConfigureBrightnessDisplay2=0; //Controls the updating of the brightness display widget 1 so blynk app is not flooded
byte AppReconnected=0; //Controls when the reconnection subroutine should start occuring from
void CheckBrightnessSetting1(); //Checks the brightness setting j and is used to update the app when the slider changes brightness and when app disconnects and reconnects it updates the app
void CheckBrightnessSetting2(); //Checks the brightness setting j and is used to update the app when the slider changes brightness and when app disconnects and reconnects it updates the app
byte LED1BrightnessPin=10;
byte LED2BrightnessPin=11;
byte BrightnessR1=0, BrightnessG1=0, BrightnessB1=0; //To set the brighness of the LED strip 1 whilst still allowing the ZeRGB to be set by variables r1, g1 and b1
byte BrightnessR2=0, BrightnessG2=0, BrightnessB2=0; //To set the brighness of the LED strip 2 whilst still allowing the ZeRGB to be set by variables r2, g2 and b2
byte BrightnessR=0, BrightnessG=0, BrightnessB=0;
void LEDNormalisationButton1(); //Reset the colour of the RGB LED strip 1 to white
void LEDNormalisationButton2(); //Reset the colour of the RGB LED strip 2 to white
byte PresetLightColour=0;
byte PresetLightBrightness=0;
byte PresetLightSelection=0;
void PresetLightSettings();
void DeactivatePreset();
//To control selection of the preset light settings
byte PartyMode=1;
byte RainbowMode=1;
byte RomanceMode=1; //Brightness must be adjustable, allow it to be set at a standard value of i when the widget when it is first toggled
byte ReadingMode=1; //Brightness must be adjustable, allow it to be set at a standard value of i when the widget when it is first toggled
byte MovieMode=1; //Brightness must be adjustable, allow it to be set at a standard value of i when the widget when it is first toggled
byte FireTorchMode=1;
byte FadeMode=1;
byte LightningMode=1;
byte FadeOnOffMode=1; //Allow colour to be adjusted
byte LightningCounter=0;
byte LightningCounterValue=5;
void CheckLightSettings(); //Checks if any of the preset modes are active and deactivates it before a second preset mode is activated
void UpdateLightSettings(); //Updates the state of the app widgets upon app hardware reconnection
void NormalisePresets(); //To update the state of a preset light condition push button of the app if the light settings was normalised whilst the app was offline
byte x=0; //Used to indicate which was the last preset light condition selected even after that light condition was deselcted. Works with NormalisePresets()
//The initialisations from the orignal WS2812..V1_4 which are needed for some of the preset light settings
CRGBPalette16 currentPalette;
TBlendType currentBlending;
#include "LedControl.h"
#define MAX_LED 26 // Number of LEDs in bar graph array (10 * 2) but first 10 on rows 1 and 2 and second 10 on rows 3 and 4
#define MAX_BRIGHTNESS 15 // 0-15 LED brightness
#define LED_TIMEOUT 6000 // Time out after which LED bar turns off
boolean isSleeping1=false; //LED bar graph 1
boolean isSleeping2=false; //LED bar graph 2
unsigned long lastOn1 = 0; // Last time LED Bar graph 1 was turned ON
unsigned long lastOn2 = 0; // Last time LED Bar graph 2 was turned ON
/*
pin 9 is connected to the DataIn
pin 8 is connected to the CLK
pin 7 is connected to LOAD
*/
LedControl lc=LedControl(29,28,27,1); //Originally was 9,8,7,1
void HardwarePushbuttons();
void DisplayLEDBarGraphs();
void DisplayToSerialMonitor();
void MainFunction();
int i=0; //Startoff LED bar graph 1 on OFF (No LEDs ON)
int j=16; //Startoff LED bar graph 2 on OFF (No LEDs ON)
byte k1=0, k2=0, k3=0,k4=0, k5=0, k6=0;
int n=0;
int o=0;
int p=0;
BlynkTimer timer1;
//To allow the system to connect to another recognized WiFi network if the one is disabled
byte BlynkCounter=0;
void CheckBlynkConnection();
byte BlynkRunCounter=0;
byte SwitchLED=0;
int WifiConnected=0;
//*HOME*
char ssid0[] = "XXXXXXXXXXXX";
char pass0[] = "XXXXXXXXXXX";
//*PHONE 1 MOBILE HOT SPOT*
char ssid1[] = "XXXXXXXXXXX";
char pass1[] = "XXXXXXXXXXXX";
//PHONE 2 MOBILE HOT SPOT
//char ssid2[] = "XXXXXXXXXX";
//char pass2[] = "XXXXXXXXXX";
char server[] = "blynk-cloud.com"; // URL for Blynk Cloud Server
int port = 8080;
// Hardware Serial on Mega, Leonardo, Micro...
//#define EspSerial Serial1
// or Software Serial on Uno, Nano...
//#include <SoftwareSerial.h>
//SoftwareSerial EspSerial(12, 13); // RX, TX
// Your ESP8266 baud rate:
//#define ESP8266_BAUD 9600
//ESP8266 wifi(&EspSerial);
void setup() {
Serial.begin(9600);
Serial.println(F("Establishing connections..."));
//EspSerial.begin(ESP8266_BAUD);
delay(10);
//For Blynk communication
Blynk.begin(auth, ssid1, pass1);
//SetupBlynkConnection();
lc.shutdown(0,false);
/* Set the brightness to a medium values */
lc.setIntensity(0,MAX_BRIGHTNESS);
/* and clear the display */
lc.clearDisplay(0);
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
//**Just for testing purposes:**
pinMode(6, OUTPUT);
pinMode(5,INPUT_PULLUP);
FastLED.addLeds<WS2812, DATA_PIN, GRB>(leds, NUM_LEDS);
Serial.println (F("Light Control System Version 1_7 (ESP32)"));
Blynk.virtualWrite(V0, Lamp1);
Blynk.virtualWrite(V5, Lamp2);
CheckLightSettings(); //To normalise all the app widgets before starting the program
DeactivatePreset();
Blynk.notify("Light control app paired and ready");
AppReconnected=1;
delay(200);
timer1.setInterval(300L, MainFunction);
}
void loop() {
Blynk.run();
timer1.run();
}
I have tested and successfully compiled the Blink example code