After the small Chrome App experience that resulted in a very compact app that reads Video and sends an UDP binary stream to ESP32 Led controllers I decided to start learning how to program a real mobile app.
Real because I find that the way to do it must end in the App Store and the user should be able to install it with a few clicks.
This start guide is only valid for Linux but it could be a similar approach in Mac.
Soon more posts will follow explaining how to interface with Android OS (Camera as an example). There will be soon more issues to expand and implement in this repository. And my new philosophy to build Firmware for Espressif chips will be simply:
“One firmware, one mobile application”
Meaning that every firmware will have his app, where you can configure and test it, just with one click install in google Play store and setting up some very easy configuration. Starting from WiFi credentials using BLE (Bluetooth low energy) and setting up the App IP address as a last step.
My goal at last, is that internet of the things is easy to use, and not something where you need a 20 minutes complicated setup to start using something. So the mission is that for first weeks 2020 all master branches from our main ESP32 Firmwares like udpx and Remora should be bluetooth configurable.
Remora listens to UDP short commands to trigger LED Animations. Receives ; commands from ORCΛ
As a side fun idea while learning Nodejs and while working for a bigger and more complex project with my partner Hendrik I programmed Remora just to have an easy way to launch animations from ORCΛ
If you want to try it out please check the requirements and components on the repository or on the hackaday project page. After getting addressable LEDs and any ESP32 board, it’s easy to compile this, reading the provided instructions with Arduino or Plataformio. It needs simple configuration, to know your WiFi credentials and the length of your led stripe. After initializing and getting online, the firmware will listen by default in port 49161 and launch short animations as fast as the UDP message hits the chip. To test it send an UDP message using netcat or any other way. In Linux that can be done like this:
echo '82O'|nc -w1 -u ESP32_IP 49161
IMPORTANT: If you copy the upper text make sure that the quotes are single quotes otherwise the compiled C will not recognize what animation to start
That is enough if you want to send animations to one controller. If you need more then we created a simple UDP redirector script that lives in the extras folder. This can be run using:
After configuring a simple ip-config.json file that has an id to IP lookup table:
When this is running in the background, it will just process any message coming, extract the first character and pick up that ID from the table. Then it will redirect the rest of the message to that IP, same port 49161. To explain it more graphically, sending:
echo '282O'|nc -w1 -u localhost 49161
will lookup IP 2 and send 82O to 192.168.0.73 enabling you to send animations to different LED Stripes from Orca sequencer software.
About a month ago I started learning to use ESP-IDF and got very interested in Espressif Mesh Lamps. It’s a lot of fun for me to create my own ESP-Mesh LEDs lamps with this technology. But as with everything I touch that is open-source, apart of being a user, I try to collaborate and made the thing better. That’s the spirit of open source, you are a user, but also at the same time your opinion counts and usually it’s welcomed.
Comparison from previous ESP-Mesh App and new upcoming version:
03/2019 new version
More integrated and compact UX. Now On/Off switch is in the same screen allowing for easier usability
Doing White with RGB is now possible. Click on the center and the light will turn on the 3 colors at the same time (New feature)
Warm/Cold switch is also better signalized and more usable.
I really like the update and I think is a significant improvement over the last version.
Here some selfish pictures of my last lamp projects ;)
I started to dig a bit more into the Iot development network from Espressif with the intention to slowly learn something new. All the official examples of Mesh lights, ESP32-Camera and ESP-WHO that presents a preliminary version of face recognition are built on the top of the IDF.
So sooner or later, I think will be the official way to do “internet of the things” devices with these Boards. But I’m still not ready for it, I need to do simple examples and experimenting before taking over and do something for real.
So the first things I tackled on is to take this libraries “as is” and use them in existing Arduino framework projects. And it’s fully possible, below is a small example about this using the TTGO Camera with Pir sensor
“ESP–Mesh reduces the loading of smart light devices on the router by forming a mesh with the smart light device.”
I’ve started months ago getting some smart lights for home and I’ve chosen Osram since it was about half the price than Phillips VUE. But the thing with this systems, though they work nice and with very little configuration, is that you need always a “Gateway”. A central point that receives signals and then send via Radio frequency to the lights what they have to do.
The Espressif ESP-Mesh took a different approach: Every device is a network member making a Mesh of interconnected devices. There is no gateway because there is no need for one.
There is also a very important point that is very interesting if you are a maker like me. It’s open source. That means you don’t need to buy a 60€ light to test it, you can just go to the ESP-Mesh github repository and download ESP-Mesh-Light example to compile it in one of your existing ESP32 Boards. Then you can get easily something like this working :
So what I’m working on the free time to take a rest from another pending projects is to take this PWM output and amplify it using a 74HC125 Quad Bus Buffer to power more than one led.
Command lines to execute the compilation are only 2:
make menuconfig make erase_flash flash
Compile this into your ESP32 and then download Espressif official Android App or if you are using I-phone / I-Pad just search for “ESP-Mesh” The Mesh devices are configured using Bluetooth so keep in mind to have this enabled on your device. Instead of taking the “WiFi Manager” Approach, using an App, you have the benefit that you can just send the WiFi Credentials plus configuration directly to the ESP32.
Since beginning of 2019 I’m participating in a project called “Low cost / low power sleep / WiFi Camera” so I purchased a couple of low cost boards, between them the LilyGO ESP 32 Camera.
BigIot.net is an interesting IOT API site
Not only an API but a very interesting infrastructure that is also possible to link BIGIOT with WeChat allowing to “chat” with your device and use it for Smart home or just to check what was the last image uploaded. In my fork of this ESP32 Camera, since the original looks a bit unmaintained without even an issue board, I added some better display information:
This example shows how to set up an automatic camera that takes pictures every 20 seconds and sends them like an API Post push to BigIot. So far so good, it works at first glance. The issue is that BigIOT is all in Chinese and there is no english. So if you consider that a problem then you can stop here. I didn’t because I think the Chinese know hell about this and they are leading the IoT world for a good reason.
So I translated it as I could just to register and get this pieces of information:
After registering you just have to open the activation Email and you are good to go. Just log in the Admin Panel and try to feel at home. Most important parts are:
智能设备列表 List of your Devices -> Add a “Camera device”
数据接口列表 List of your Inputs -> This is the Interface, so just make an “Upload interface”
And that are the two IDs you need, device ID and interface ID. After that and compiling this, the small camera is going to start pushing pictures to BigIOT and you can just click on the stats on the interface area and start checking the pictures when you are away.
Very good to control for example a 3D printer that you leave at home finishing something. This is the result:
https://gitee.com/hejinlv/ESP32/blob/master/ESP32_bigiot_LED/ Here there is a great example on how to Listen to Commands to interact with WeChat
As an introduction I would like to make clear that I’m not a C++ advanced coder or IoT professional, I do this just because it’s a challenge, and because it’s a lot of fun compared to my 9 hrs/5 days a week web developer doing PHP and Admin panels for clients in Germany. Two months ago I started tinkering with SPI Cameras and the Espressif systems boards and that’s how this open source project was born. So far I was using Arduino since I do not need a super IDE, sometimes I also edit the code with vi or gedit instead of open a monster IDE that will eat your CPU alive. But gladly this is not the case. I was since long looking for a competitive alternative to Arduino when this github issue on the FS2 Camera Project called my interest:
tablatronix commented 8 days ago
I had to manually install this button library as it is not in platformio , is it in arduinos?
And that’s how after a few clicks I discovered Plaftormio.org that according to their home page it’s an open source IoT ecosystem. But what interested me more than this is the subtitle: “Cross-platform IDE and unified debugger. Remote unit testing and firmware updates“
So instead of answering tablatronix issue, I started installing this new IDE, that happened in a breeze. 1. First thing is to install the VS CODE Version. I choosed the Visual Studio code option since it has more features. Microsoft’s Visual Studio Code is the base and PlatformIO is built on the top of this.
2. Go to “Extensions” and install PlatformIO IDE “Development environment for IoT, Arduino, Espressif (ESP8266/ESP32)”
3. In my case since I used Arduino IDE before, go to PlatformIO alien face logo and select “Import project from Arduino”. Then select the folder where your Arduino project is and PlatformIO will create a Workspace for you with all the necessary structure.
4. Adjust serial monitor baud rate. If you are using Espressif chips edit platformio.ini and add the following line at the end:
monitor_baud = 115200
This will make your serial work in the right baud rate for ESP8266 /ESP32 (Serial is the plug icon in the bottom just before the Terminal > icon)
5. FS Data. If you are using SPIFFS that in Arduino is the /data folder inside your sketch you will notice that in PlatformIO this folder needs to be at the root level. So you can simply move it one directory above. To upload SPIFFS data use the following command in the terminal:
pio run --target uploadfs
IMPORTANT: As difference with Arduino if you try to save a file in /1.JPG here you will get it saved on: /spiffs/1.JPG so create this folder on /data or you will get; VFSFileImpl(): fopen(/spiffs/1.jpg) failed
6. Libraries in PlatformIO live inside a folder on your project called .piolibdeps Thanks god, they are not distributed on 3 different parts, like it happens with Arduino (Some in Arduino/libraries, some in Programs/Arduino/libraries and so on) but are there available for you in just one place :) To install a new library is very easy, just go to PlatformIO.org/lib and type the name of the library to search. If found copy the resultant line in the Terminal just like point 5 and the IDE will look this up for you and download it using github to the .piolibdeps folder.
pio lib install "WifiManager"
Sometimes you will need a library in a special branch and there is also an easy way to do this. Just use :
pio lib install <repository#tag>
// Install development version of WifiManager library pio lib install https://github.com/tzapu/WiFiManager.git#development
7. If you use Arduino before it’s possible that you used some of it’s constants. So if your sketch compiles, but it does not runs like expected try to add this include line at the beginning
As a footer note I must make clear that it takes some time to get accustomed to the new IDE. But it comes with a great benefit as it shows you much better C++ warnings, it’s prettier to use, and has the advantage that you can Ctrl+Click and navigate between different classes. Something that it was not possible to do with my old IDE. And the most beautiful update is that all libraries are in a single place per Project, like it should be, leaving you a clear idea of how much code and dependencies you are adding into your sketch.
In FS2 project porting it to the ESP8266 Wemos board this happened like a breeze. And it was just the fact of upgrading my code to use OneButton library. adding the include Arduino.h and that is. After uploading SPIFFS data and the new code, the camera was ready to be used. Now it’s not always that easy. trying to compile the same code to an Heltec ESP32 board, I got SPI communication issues with the camera and I’m still fighting with it.
UPDATE: I found what is going on here, and it’s that there are some problems with my sketch that uses I2C and wire library to comunicate with the Camera on the Heltec ESP32 environment. Error message is: i2cCheckLineState(): Bus Invalid State, TwoWire() Can’t init. I solved it updating the platformio.ini configuration file to use: board = lolin_d32 So using this board it compiles and works correctly. No idea why it does not using heltec_wifi_lora_32 I will have to research more.
Additional links of interest:
Source filter: src_filter This option allows to specify which source files should be included/excluded from build process. It could be useful to keep the same core for ESP8266 and ESP32 but including different files to support both. So far I’ve been using 2 different branches something that is hard to maintain for obvious reasons.
Library dependencies: lib_deps declaration in platformio.ini Like composer for PHP, this IDE offers a way to declarate your libs in the ini file. To check how a professional software for 3D-printing does take a look in Marlin configuration file. This is a very important point to keep in mind since after the lib_deps list is correctly added and tested, people testing your code just need to hit “build” to download them, saving a huge amount of time. This are FS2 library dependencies.
FS2 Camera project
If you are interested to build your own WiFi Camera for around 40€ of components and maybe 5€ of 3D-printed case, then check this project on github:
I’m giving out in december ten free 3D-printed cases, if you are interested on getting one and putting together a WIFi Camera please choose between Black PLA, black PETG or RED transparent and comment in this post. You can send me the address later per private message or in twitter. Thanks for your interest!