When the Cloud goes down

pascal boudalier
3 min readOct 24, 2023

Back in 2021, I developed an ESP32/MicroPython project to get a sense on whether my solar water heater was filled with hot water (ready for showers), or just lukewarm water. Lukewarm means trouble with my partner and I don’t even mention cold water…

This worked flawlessly until .. it didn’t anymore.

The culprit? The back-end cloud service I was using went away. Yes, the cloud can disappear.

I was using ( as I am still is) the excellent Blynk platform to build Android side of that application. However, end of 2022, the Blynk cloud based infrastructure I was using went away.

To be fair, Blynk upgraded their infrastructure to a new (not backward compatible) version. This process was well managed, with early notice and ample time to migrate. Migration itself was not too difficult and the new version has many improved features.

Even if I am running many applications on the “new” Blynk (see this award winning project), for this water heater project however , I decided not to move to the new Blynk version but instead “move out from the cloud”.

I saw two benefits:

  • no need to migrate the existing application
  • the system is “self contained”, as it does not require any external cloud service.

In addition, self-containment allows to easily install the entire system to friends and family; no need to ask them to subscribe to any cloud service.

Fortunately, the version of Blynk I was using allowed to run the server on a local Linux system.

The updated water heater application is available on github

My own little cloud

Is is rather simple to run the Blynk server locally.

I am using docker, and the Blynk server is just another docker container running on my Raspberry PI (already running many home automation applications).

With docker, no need to learn how to install the Blynk server and all its dependencies: you simply have to download a ready-made docker image, and run it. That’s it.

docker create -p 8089:8080 -p 9444:9443 -p7443:7443 --name=Blynk_private_server --restart=always -v /home/pi/APP/Blynk/config:/config -v /home/pi/APP/Blynk/data:/data maxbanton/blynk-server:latest

docker start Blynk_private_server
After 2 years of service, a breadboard and a maze of Dupont wire are replaced with a custom PCB.
The system is awake, taking measurement and sending the results to the Blynk server on the Raspberry PI. The OLED screen is powered down during deep sleep.

Power

Power is an important factor to consider before deploying an embedded application. Between two temperature readings, the ESP32 is in deep sleep and consumes less than 0,1ma (vs 50 to 150ma when awake). Therefore a small 4000mah LiPo battery should provide power for months.

Beside the ESP32 itself, the system contains 3 peripherals: the temperature sensor, the LiPo capacity sensor and a small OLED screen. To minimize overall power consumption during deep sleep, it is important to power those down as well. This is done by driving the GND pin of those 3 devices with an ESP32 GPIO. Setting this GPIO to a low state will actually power the 3 devices. Right before going to deep sleep, the same GPIO is configured as a floating input pin, to make sure no power is provided to any of the peripherals.

Over The Air

Besides power, another factor to consider when developing an embedded application is remote management.

The ESP32 MicroPython program needs to be “flashed” into the chip’s flash memory. During development, this is typically done with a USB cable connecting a laptop to the ESP32. But this becomes pretty inconvenient when the system is in operation in my cellar.

Using a simple configuration button, the ESP32 can be set to run continuously instead of going to deep sleep. In this mode, one can use any browser to access the ESP32 address via WiFi, enter a password or transfer a new version of the MicroPython app. Very convenient indeed …

Any web browser can be used to upload a new version of the MicroPython ESP32 application

As both the ESP32 and the raspberry PI are powered with solar electricity, the application is now set to run for many, many years …

--

--

pascal boudalier

Tinkering with Raspberry PI, ESP32, RiscV, Solar, LifePo4, IoT, Zigbee, energy harvesting, Python, MicroPython, Keras, Tensorflow, tflite, TPU. Ex Intel and HP