I’ve my Blynk project well set on ESP8266. Wanted to look at ESP32 to handle more relays and inputs. Ordered a LOLIN32 board. Was not a Wemos. My experience:
Had to move from tzapu’s to zhouhan’s port of WifiManager. Small change was that shouldSaveConfig flag had to be explicitly set to true for the WiFi parameters to be saved.
WiFi.Hostname call was not available. Had to use WiFi.getHostname.
3.Wifi.setHostname did not work.
Eeprom handling gave initialisation errors (even examples). Wonder if this had something to do with the board. The board did not have a Wroom32 chip but compiled and worked with Wemos LOLIN32 compiled binary.
Questions:
Which ESP32 board would this group recommend? Wemos seems to be out of stock.
Does any one have WifiManager based Blynk provisioning running on a ESP32?
What would the recommended split of processes across the two cores be. Remember Pete’s post on pinning processes to cores. Will need to revisit that.
Does Blynk.io provisioning solve all this and work on ESP32?
So far, everything ESP32 based is still a work in progress… even from espressif themselves. Thus many ESP8266 commands and processes are subtly different… OTG and Blynk libraries are a good example. I have no need for provisioning so haven’t used it… but I am guessing it also requires some adjustments in how WiFi commands are used…
One nice thing about ESP32 chip itself is that they are pretty much all the same as far as pin naming and programming options in the IDE, so whether using Wemos, TTGO or other brand, the same code should work across the whole range… assuming some manufacturer hasn’t used up specific pins for addons like OLEDs, or skimped on making all pins available, etc.
This is a free ebook about the ESP32. It has very much information on it. And as Gunner says, the boards are all pretty much the same. I’m running on a WRoom32 dev board and it works neat
Interesting. Your experience can be of great help to me.
Are you acquiring Blynk token/server/port and storing them? If so, where and how do you store the Blynk token data? Can you share your code? I want to remove the dependency on EEPROM and see how and where we can store/restore from SPIFFS.
no, unfortunately I use the WiFiManager just and plain as a sane way to pass SSID and PASSWORD to my ESP32 when I moved it from place to place nothing more. Regarding the code that I use it is like the relevant example.
Ah. I’ve got that working for me too with the zhouhan branch. The EEPROM class example is failing with initialisation errors. The ESP32Partitions plugin to Arduino is also not loading for m to define partitions. I know it is a small hurdle and once crossed, I’ll be able to progress. Need help from others who have had some experience.
One other problem I’ve is that I’m unable to set the client hostname. WiFi.setHostname(ssid) where ssid is a char fails with a tcpip_adapter error. The module shows up as espressif as a default. If we have multiple devices, this will be an issue. Have you been able to do this?
Anyone?
I have had good experiences with the Arduino IDE and a couple ESP32 boards. I use this one:
and this one:
The Arduino IDE supports saving SSID and Password in non-volatile memory. I have good recovery from power failure (electricity died today for 2 hours even).
Since you seem to be using the Espressif IDE, I won’t comment further on my experience w Arduino IDE unless prompted, but the Wemos and DoIT ESP32 boards above are supported well. The “variants” in the Arduino IDE help to define the differences in the pinouts and I have the pinouts if you go with these. DoIT uses WROM32 module, the WeMOS uses an ESP32S. One plus on the DoIT is that it is (at least sometimes) stocked in Bangood US warehouse, so shipment time is much better than from China.
Thanks. I’m using Arduino IDE. I was struggling with eeprom usage on ESP32 not knowing whether it was due to hardware or not. On the ESP8266, I was storing the token and Blynk parameters in eeprom. A post yesterday has an example code of using SPIFFS to store this data.
As I play with the ESP32 more, I’ll learn. My board does not have the WROOM32. My ignorance of the chip and board versions is a large part of the problem. Am also not that hardware savvy.
I bought what was quoted as a LOLIN32 but it does not have the metal shield on top. Not am I able to read any marking on the chip. Bought on AliExpress.
That actually looks like one of the ESP32-PICO-D4 chips… basicly the compact version of the ESP32.
EDIT - no, probably not unless it says so…
So what you have is just a smaller dev board, but same chip as all the rest. And as a Rev1, it is new enough Perhaps a few less exposed 3.3v and GND pins, and no 5v… either way, for general purposes I believe they all work the same… and apparently still classed as WROOM32 with or without metal can.
You may wish to explore the preferences library in the standard Arduino package for the ESP32.
I use the preferences library to store the SSID, Password in the NVM quite painlessly and then can just use sketch to read them as needed. Since I run similar code on different boards at different locations, this saves hard coding a version for each board. I haven’t taken to storing the Blynk authorization numbers this way since that starts to lock the board to a single application. I appended the simple sketch to set these at the end of an application sketch but commented out. I can easily comment out the application and uncomment the appended preference sketch to set SSID and Password on a new ESP32 or reset on a previously configures board, then restore the desired sketch while re-commenting out the preference setting bit… Here is the code to set the preferences:
// copy below to end of new sketch to reset the preference keys for ssid and password
ESP32 start counter example with Preferences library
This simple example demonstrate using Preferences library to store how many times
was ESP32 module started. Preferences library is wrapper around Non-volatile
storage on ESP32 processor.
created for arduino-esp32 09 Feb 2017
by Martin Sloup (Arcao)
Modified by James Monthony to store local SSID and Password in Preferences
need to convert strings to char* for login using WiFi.h
*/
/*
#include <Preferences.h>
#include <WiFi.h>
const char* ssid = "YourSSID"; // SSID goes here
const char* password = "YourPassword"; // your password goes here to be written
const char* notSet = "Not Set!"; // function requires a default value this is it.
Preferences preferences;
void setup() {
Serial.begin(115200);
Serial.println();
// Open Preferences with WiFiLink namespace.
// Each application module, library, etc.
// has to use namespace name to prevent key name collisions. We will open storage in
// RW-mode (second parameter) has to be false or read only.
// Note: Namespace name is limited to 15 chars
preferences.begin("WiFiLink", false); false for read/write
// you can uncomment as needed below to clear out old values. after running (once) the new value will
// be stored. then re-comment out the line and run again to be sure it is stored correctly.
// Remove all preferences under opened namespace by uncommenting below
// preferences.clear();
// Or remove the counter key only
// preferences.remove("counter");
// Or change the SSID
// preferences.remove("CurrentSSID");
// Or change the password
// preferences.remove("MyPassword");
// Get a counter value, if key is not exist return default value 0
// Note: Key name is limited to 15 chars too
unsigned int counter = preferences.getUInt("counter", 0);
String CurrentSSID = preferences.getString("CurrentSSID", notSet);
String MyPassword = preferences.getString("MyPassword",notSet);
if (CurrentSSID == notSet) {
preferences.putString( "CurrentSSID", ssid);
CurrentSSID = preferences.getString( "CurrentSSID", CurrentSSID);
}
if (MyPassword == notSet) {
preferences.putString( "MyPassword",password);
MyPassword = preferences.getString( "MyPassword",MyPassword);
}
// Increase counter
counter++;
// Print counter to a Serial
Serial.printf("Current counter value: %u\n", counter);
Serial.printf("Current SSID is ");
Serial.println (CurrentSSID);
Serial.println("Current Password is ");
Serial.println(MyPassword);
Serial.println();
// Store counter to the Preferences
preferences.putUInt("counter", counter);
char cssid[CurrentSSID.length() + 1];;
char cpassword[MyPassword.length()+1];
CurrentSSID. toCharArray(cssid, CurrentSSID.length() + 1);
MyPassword.toCharArray(cpassword, MyPassword.length()+1);
WiFi.begin(cssid, cpassword);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println("");
Serial.println("WiFi connected");
Serial.println("IP address: ");
Serial.println(WiFi.localIP());
// Close the Preferences
preferences.end();
// Wait 20 seconds
Serial.println("Restarting in 20 seconds...");
delay(20000);
// Restart ESP
ESP.restart();
}
void loop() {}
*/
You can not replace a full file system, but for a few set paramaters, the preferences library is a great ESP32 feature.
@DrJFM Thanks. The preferences option worked well to store Blynk token data. This is a good step forward.
I’m still stuck in WifiManager. Code works well in ESP8266 but creates problems in ESP32. In 8266, we can capture custom data like Blynk token in the config portal and the WiFi will move from AP to STA mode post which the token is saved. In ESP32, if we use custom data capture in the web page, the first WiFi connects fails and the system connects well on reboot with the stored SSID and Password data. In this cycle, the custom data captured gets lost.
The call back to save configurations is triggered after a STA mode connect only!
If I remove the custom data capture, the switch to STA more goes through smoothly without needing a reboot.
I don’t really why token save wasn’t working earlier. Tried the token save using preferences in the wifi.autoconnect() loop and it worked as intended. Now, before the system reboots to connect, the token does get saved.
I should’ve been making some silly mistake…
Thanks @DrJFM for the preferences post. I was trying eeprom class and failing. The ESP32Partitions tool was also failing to install. This was a good pointer.
In ESP8266, one could set the WiFi.setHostname() before wifi connection getting established. In ESP32, this call gives an error tcpip_adapter not initialised.
Was very useful in controlling the wifi connection as it entered modes like AP, STA, got IP, disconnected etc… Thought I would let this group know of this so that others do not get stuck like I did.
I used the WifiEvent as under to set the hostname
void WiFiEvent(WiFiEvent_t event)
{
switch(event)
{
case SYSTEM_EVENT_AP_START:
//can set ap hostname here
Serial.println("Entering AP mode");
break;
case SYSTEM_EVENT_STA_START:
//set sta hostname here
Serial.print("Setting hostname of device to ");
Serial.println(ssid);
WiFi.setHostname(ssid);
break;
case SYSTEM_EVENT_STA_CONNECTED:
//enable sta ipv6 here
Serial.println("Wifi STA connected");
break;
case SYSTEM_EVENT_STA_GOT_IP:
Serial.println("Device has got IP");
break;
case SYSTEM_EVENT_STA_DISCONNECTED:
Serial.println("Wifi disconnected");
break;
default:
break;
}
}
Have now reached the same functionality and stability as the ESP8266 code I had. Thanks to inputs from @DrJFM@Gunner@mikekgr@Lichtsignaal for helping me achieve this. Thanks to @PeteKnight earlier for encouraging me to explore the ESP32 for 8 channel relay control needs.
Feel super confident now and so much different from where I was a couple of days ago. Next steps are to try touch input for physical switches and pinning tasks to specific cores.