Easy Way to Do Many Things at Once on ESP8266 and ESP32
by Phil Bowles in Circuits > Electronics
494 Views, 6 Favorites, 0 Comments
Easy Way to Do Many Things at Once on ESP8266 and ESP32
Many people find it tricky to get past the first stage of running simple programs on ESP8266. They find that doing many things at once causes a lot of problems and can be quite difficult.
Luckily there is a library for the Arduino IDE that makes it really simple to do many things at the same time. It has over 80 examples, so everyone will find something to get them started!
It also works on ESP32 and allows one set of code to perform the same on both boards and saves the user having to learn the freeRTOS for the ESP32 which many people find very hard.
Supplies
1. ESP8266 or ESP32 dev board e.g. WemosD1 mini, nodeMCU etc
2. Sensors, LEDs
3. ArduinoIDE + ESP8266 core
4. The H4Plugins library from https://github.com/philbowles/h4plugins
Install the Software
1. If you do not already have ArduinoIDE installed, get it from here.
2. Next you need to add the ESP8266 core firmware (or the ESP32 core, or both) Links: ESP8266 Arduino core or ESP32 Arduino Core
3. Test your installation by running a simple example e.g. Blink
4. Install H4Plugins library This requires a few other libraries to be installed first as it can do just about anything for you. The site contains an easy "road map" of the installation process.
Familiarise Yourself With H4Plugins
The author of H4Plugins has a Youtube Channel which contains many videos to show you the abilities, features and functions of the library and the (amazing!) range of things it can do.
Watch one or two to get a "feel" for the new programming style before "dipping your toe" with your own project
There are two "series" the "Arduino Blue" series whaich are the serious ones that walk you through the library and its 80+ examples and the "orange" or "Backchannel" series which are much more light-hearted and give background information.
We recommend first watching the overview (Episode 0)
Then, if you come from a pure Arduino or PIC hardware background we recommend you watch Waaaaaaaaaaaaaaaah ! why does my Arduino code keep crashing on my esp8266? It works fine on my UNO!
Finally, jump to one of the practical videos where you are shown an actual piece of hardware desgined and built for use with the H4Plugins system. It is a light-depenedent alarm that can be controlled by a built-in web user interface, MQTT commands , Alexa Voice control, HTTP rest url, and can be easily linked to your mobile phone being present / not present to automatically "arm" or "disarm" it. Internet of "Things ain't what they used to be".
It's just one example of the type of thing that H4Plugins does with tens of lines of codes, not the hundreds you find in other libraries.
You are now ready to gather some sensors and components and start building mult-tasking ESP8266 apps!
Do-it-yourself
If you have had some previous failed attempts at getting multi-sensor apps running, you can go back to your workbench and rebuild your app the H4Plugins way.
If you are new to all of this, get several different sensors / actuators and try out the H4Plugins way of making them all work together easily in a few lines of code!
Good Luck!