ESP32 (36) – OTA with Freshen

In one of the first posts of this tutorial, I wrote about the bootloader and about how the flash memory is organized. That article says:

This allows to implement an over-the-air (OTA) application update process: you send the new version of your application to the esp32 chip; the version is stored in a new app partition

There are different ways to implement OTA updates for your application… today I’ll show you how to do it in an easy way, thanks to a cloud service named Freshen.


Freshen is an IoT backend, that is a cloud dashboard (published on the Internet) to manage IoT devices.

After having connected your devices to Frashen (I’ll show you later how to do it) you can:

  • display the list of the devices and their status
  • send a command to a device
  • manage the files stored in a device
  • update the firmware over-the-air (OTA)

Freshen is developed by Cesanta, the company that also develops the Mongoose library and the MongooseOS, very used in the embedded world and compatible with the esp32 chip. The service has different fees, including a free one:


To use Freshen, first you have to register, using your Github or Google account:


Client library

Cesanta offers a client library you can use to connect your IoT project based on the esp32 chip to Freshen. The library consists only in a header file (freshen.h), and is available on the official site.

The library is fully compatible with the esp-idf framework and supports all the functionalities of the dashboard:


It’s also very easy to use. First copy the freshen.h file in the main folder of your project:


Then include the file in your program:

#include "freshen.h"

To let the library communicate with the Freshen platform in the cloud, in your program you have to periodically call the freshen_loop() function:

You can do it in a dedicated task:

void freshen_task(void *pvParameter) {
  while(1) {	
    vTaskDelay(2000 / portTICK_RATE_MS);

This task calls the function every 2 seconds. Create the task in your app_main() with:

// start the freshen update task
xTaskCreate(&freshen_task, "freshen_task", 10000, NULL, 5, NULL);

The freshen_loop() function requires two parameters: the firmware version (it’s a text string at your choice, for example “v1.0″) and the access token, a code that is generated by the platform when you register a device.

Connect to the dashboard and click on Add new device:


A new device will be added (My Device #n). You can click on its name to display the details.

The access token is hidden… Click on click to copy to save it in the clipboard on your computer; you can then paste it in your program:


The device details page also allows to change the name of your device.

If you run the example program (you can download it from my Github repository) you’ll notice that, after a couple of seconds, the status of your device changes to online, to indicate that it’s correctly sending data to the dashboard:


In the details page, you can now list the functions that you can remotely call:


For example, if you call the Sys.GetInfo function you can retrieve the information about firmware version, architecture, compile date…:



To be able to update the firmware of your device over the air, you have to select an appropriate partition layout. For example you can choose the “OTA” layout that is already included in the framework:


Let’s now modify the firmware version, to be “1.1”:


then compile the program but don’t use the flash command. Note the path of the binary (compiled) file:


Select your device in the dashboard and click on OTA update selected:



Choose the .bin file that contains the new version of your firmware.

After a few moments, you’ll probably see the device going offline and return online. If the update process was successful, call the Sys.GetInfo function again and you’ll see the new version:



Build a Multisensor Shield for ESP8266


Rui Santos has a great write-up on building a Multisensor Shield for ESP8266, that is available on GitHub:

In this project you’ll discover how to design and create a Multisensor Shield for the ESP8266 Wemos D1 Mini board. The shield has temperature sensor (DS18B20), a PIR motion sensor, an LDR, and a terminal to connect a relay module. We’ll start by preparing all the hardware and then program it.

See the full post on Random Nerd Tutorials blog.

Tutorial: Using the Arduino’s internal EEprom to store calibration data and LCD screen fonts


Edward Mallon writes:

This is a follow-up to our post about using Nokia 5110 screens on three unused analog lines with shift-out. That saved me from messing with the hardware SPI bus which we reserve for the SD cards. A secondary benefit is that the code is really lean, on the order of about 250 bytes for the default font after the compile if you already have EEprom.h in the build anyway. The font, however takes up about 500 bytes, and I wanted the smallest possible footprint so that we could add live data output to loggers that are already compile near the memory limits. As it turns out, stuffing those fonts into the internal EEprom was pretty easy to do:
Using the Arduino’s Internal EEprom to Store Calibration Data & LCD Screen Fonts

More details on Underwater Arduino Data Loggers blog.

Via the comments.

How to use I2C LCD with ESP32 on Arduino IDE


A how-to on using an I2C LCD display with the ESP32 using Arduino IDE from Random Nerd Tutorials:

This tutorial shows how to use the I2C LCD (Liquid Crystal Display) with the ESP32 using Arduino IDE. We’ll show you how to wire the display, install the library and try sample code to write text on the LCD: static text, and scroll long messages. You can also use this guide with the ESP8266.

See the full post at

Dual ultrasonic sensors combine for 2D echolocation


A how-to on making a Dual-sensor ultrasonic echo locator by lingib, project instructables here:

This instructable explains how to pinpoint the location of an object using an Arduino, two ultrasonic sensors, and Heron’s formula for triangles. There are no moving parts.
Heron’s formula allows you to calculate the area of any triangle for which all sides are known. Once you know the area of a triangle, you are then able to calculate the position of a single object (relative to a known baseline) using trigonometry and Pythagoras.
The accuracy is excellent. Large detection areas are possible using commonly available HC-SR04, or HY-SRF05, ultrasonic sensors.
Construction is simple … all you require is a sharp knife, two drills, a soldering iron, and a wood saw.

Via Arduino Blog.

Check out the video after the break.

ESP32 with multiple DS18B20 temperature sensors


Guide to ESP32 with multiple DS18B20 temperature sensors from Random Nerd Tutorials:

This guide shows how to read temperature from multiple DS18B20 temperature sensors with the ESP32 using Arduino IDE. We’ll show you how to wire the sensors on the same data bus to the ESP32, install the needed libraries, and a sketch example you can use in your own projects. This tutorial is also compatible with the ESP8266 and the Arduino boards.

EEPROM rotation for ESP8266 and ESP32


Xose Pérez over at Tinkerman writes:

The Arduino Core for ESP8266 and ESP32 uses one SPI flash memory sector to emulate an EEPROM. When you initialize the EEPROM object (calling begin) it reads the contents of the sector into a memory buffer. Reading a writing is done over that in-memory buffer. Whenever you call commit it write the contents back to the flash sector.
Due to the nature of this flash memory (NOR) a full sector erase must be done prior to write any new data. If a power failure (intended or not) happens during this process the sector data is lost.
Also, writing data to a NOR memory can be done byte by byte but only to change a 1 to a 0. The only way to turn 0s to 1s is to perform a sector erase which turns all memory positions in that sector to 1. But sector erasing must be done in full sectors, thus wearing out the flash memory faster.

How can we overcome these problems?

Full details at

Amiga 500 power supply build


A how-to on building an Amiga 500 power supply from Inkoo Vintage Computing:

The power supply of my Amiga 500 is a bit unreliable. I’ve had some issues with the machine where the PSU could be the culprit, so I thought that it would be better to get a new power supply. There are used Amiga 500 power supplies occasionally available on online auctions, and there are also unused (but probably quite old) power supplies available on some online retailers. The issue with these 20-30 year old power supplies is that the capacitors are starting to dry. This can be a fire hazard, as old capacitors may even explode (this has happened to the PSU of my old IBM XT, it was not a pleasant experience). So in order to get safe and reliable operation from an old PSU, the capacitors should be replaced.

More details on Inkoo Vintage Computing homepage.

Video tutorials: Building the Arduino based data loggers

From the comments on our Arduino data logger post:

A visiting researcher dropped by our humble basement workshop with questions about the physical skill level students would need if they added one of our DIY data loggers to their environmental curriculum. I figured the easiest way to cover that was to simply build one, while they recorded the process.
The result of that 3 hour session is now available on YouTube

Thanks Edward Mallon!

Project info at the Cave Pearl Project website.

Tutorial: Setting up a low cost QRP (FT8, JT9, WSPR etc) monitoring station with an RTL-SDR v3 and Raspberry pi 3


A detailed tutorial on how to set up a cheap QRP monitoring station using an RTL-SDR V3 and a Raspberry Pi 3 from

This tutorial is inspired by dg0opk’s videos and blog post on monitoring QRP with single board computers. We’ll show you how to set up a super cheap QRP monitoring station using an RTL-SDR V3 and a Raspberry Pi 3. The total cost should be about US $56 ($21 for the RTL-SDR V3, and $35 for the Pi 3).
With this setup you’ll be able to continuously monitor multiple modes within the same band simultaneously (e.g. monitor 20 meter FT8, JT65+JT9 and WSPR all on one dongle at the same time). The method for creating multiple channels in Linux may also be useful for other applications. If you happen to have an upconverter or a better SDR to dedicate to monitoring such as an SDRplay or an Airspy HF+, then this can substitute for the RTL-SDR V3 as well.

More details at