Building and Flashing ESP32 applications with Eclipse

entries

Erich Styger shared the steps how to use Eclipse with CMake:

The current Espressif documentation integrating with Eclipse are kind of broken and did not work for me (they are changing from make files to use CMake).  The good news is that I have found a way to easily integrate the IDF with Eclipse which is documented below. Because I’m using the ESP32 in combination with the NXP Kinetis and SDK, it makes sense to have everything in the MCUXpresso IDE (I’m using the Version 11.0.0).

See the full post on MCU on Eclipse blog.

Open source hardware ESP32-ADF

esp32-adf

Here’s an open source hardware development board for Espressif audio development framework, the ESP32-ADF, from Olimex:

With ESP32-WROOM-B module with 8MB RAM and 4MB of Flash, two microphones, two 3W speakers, codec, amplifier, Lipo charger, USB with programming, Audio 3.5mm jack, ESP32-ADF board offers everything you need to start playing with Espressif Audio Development Framework.

Check out the video after the break.

ESP32 (38) – Factory reset

In the previous two posts of this tutorial, I explained how to perform an over-the-air update of the firmware running on the esp32 chip.

Sometimes you may need to revert to the factory firmware, that is the firmware stored in the flash memory when the chip was programmed. Many consumer devices have a button or a pin that, if you press it for some seconds, triggers a reset function:

A10317_image1

In this post I’ll show you how to add this functionality to your project.

Partitions

As explained in a previous post, the flash memory connected to the esp32 chip is divided into some partitions, based on a layout configured when you program the chip.

Partitions that can store firmwares are of the app type. The partition that contains the firmware programmed via USB, has the factory subtype.

The esp-idf framework includes a method to search partitions in the flash memory:

#include "esp_partition.h"
[...]
esp_partition_iterator_t esp_partition_find(
  esp_partition_type_t type, esp_partition_subtype_t subtype, const char* label);

You can specify some filters to narrow down the results (they are not mandatory, use NULL if a filter is not needed): the type of the partition, the subtype and also a specific label.

If you want to look for the partition that contains the factory firmware, you can therefore write:

esp_partition_iterator_t pi = esp_partition_find(
  ESP_PARTITION_TYPE_APP, ESP_PARTITION_SUBTYPE_APP_FACTORY, NULL);

The method returns a partition iterator, that is an object that allows to scroll through the partitions found.

If the search was successful, this object is not NULL and you can get a pointer to the partition with the method:

const esp_partition_t* esp_partition_get(esp_partition_iterator_t iterator);

After the use, it’s important to release the iterator object with:

void esp_partition_iterator_release(esp_partition_iterator_t iterator);

After having obtained the correct partition, that contains the factory firmware, you only have to flag it as the boot partition and restart the chip:

if(pi != NULL) {
  const esp_partition_t* factory = esp_partition_get(pi);
  esp_partition_iterator_release(pi);
  if(esp_ota_set_boot_partition(factory) == ESP_OK) esp_restart();	
}

Demo

In the following video you can see how to perform a factory reset. In the video you can also learn how to “count” the number of seconds a button is pressed to trigger the reset function only after a fixed threshold (3 seconds in my example). Enjoy!

Polar Coaster drawing machine

20181219_213454-600

Barton Dring designed and built a Polar Coaster drawing machine to draw custom, round drink coasters:

I recently decided to update the Polar Coaster project. The primary reason was to update the controller to use Grbl_ESP32 firmware. I also thought I could make it smaller, lighter and remove a little cost.
The old controller was not custom made and just sort of tacked onto the back. This increased the size and didn’t look very good. It had a Bluetooth module, but you still had to stream the gcode. You could use an Android app, but that was still a little awkward.
The controller runs Grbl_ESP32. This was recently updated to include pen machine features. This allows precise control and calibration of the pen servo. You can control the speed, timing and endpoints of the servo travel.

Project info at Buildlog.Net blog.

Check out the video after the break.https://www.youtube.com/watch?v=7_aS0PbP8HY

New 2.5D pen/laser ESP32 controller

20181128_204306

Bdring published a new build:

I have done several pen and laser machines lately, so I decided to create a custom PCB for Grbl_ESP32 for these types of machines. This is a small (70mm x 60mm) PCB with all the features a pen plotter or laser cutter/engraver would need.
These typically use stepper motors for the X and Y axes. On pen plotters, the Z axis is controlled by a servo or solenoid. On lasers you need an accurate PWM for laser power control.

Project info at Buildlog.Net blog and the library GitHub repository here. It’s also up on Tindie.

Grbl_ESP32 development board version 3.1

20181007_153826

A board to control your CNC machine with Grbl_ESP32 designed by Bart Dring, that is available on GitHub:

This is a Grbl_ESP32 CNC Development board. This is a quick and easy way to use and test CNC on the ESP32 controller.
Grbl is a great CNC firmware that has been around for nearly a decade. It was originally designed for the Arduino UNO and basic 3 axis CNC routers, but it has been ported to other CPUs and was the basis for many other CNC and 3D printer firmwares.
The firmware was written using the Arduino IDE to make it as user friendly as possible. If you have experience with Arduinos, this will not be much different.

Project info at Buildlog.Net Blog. It’s also up on Tindie.

ESP32 (37) – https OTA

In the previous post of this tutorial, I explained how it is possible to update your board Over-The-Air thanks to a feature of the Freshen IoT dashboard.

Today I’ll show you how to update the firmware running on an esp32 chip using only components included in the esp-idf framework, without the need of any external tools or platforms.

OTA API

The esp-idf framework offers a set of native functions to implement, in your program, the ability to be updated over the air.

Those functions are grouped in the app_update component and to use them in your program you have to include the corresponding header file:

#include "esp_ota_ops.h"

Altough the use of the native functions is not very difficult (on Github you can find an example program), Espressif developers have added a component to the framework that makes it even easier the over the air update if the new firmware is located on a web site.

The component is named esp_https_ota.

esp_https_ota

The esp_https_ota component uses the OTA API to update the firmware of your board, downloading the binary file that contains the new firmware from a web site. As the name suggests, the only requirement (for security reason) is that the web site supports the secure version of the protocol (HTTPS).

The component is able to automatically identify an OTA partition in the flash memory that is not in use and to save the new firmware in that partition. It then configures the chip to boot from that partition:

https_ota_001

The use is very simple. First create an esp_http_client_config_t struct to configure the URL of the file with the new firmware and the SSL certificate of the server (or the certificate of the CA that signed it):

esp_http_client_config_t ota_client_config = {
  .url = "https://mysite.com/newfirmware.bin",
  .cert_pem = server_cert_pem_start,
};

You have to provide the certificate in PEM format. To store the certificate in your program, you can leverage the embedding binary files functionality of the firmware, as I already explained in a previous tutorial.

Then you only have to call the function:

esp_err_t ret = esp_https_ota(&ota_client_config);

to start the update process. If – when the process is complete – the ret variable contains a positive result (ESP_OK), you can reboot the chip to run the new firmware:

esp_restart();

A real application would probably need to periodically check if a new firmware is available and, only in that case, to start the update process. How can it be done?

In the program I wrote for this post and that is explained in the video below, I’m going to show a way widely used also in commercial products… enjoy the show ;)

as usual, the source code of the program is available in my Github repository

uMesh – A self-contained, battery operated ESP32 module

Jarrett published a new build:

I’ve been working on an ESP32 module. Part of the problem I’ve been seeing with inexpensive IoT dev boards, is that the design around the power system hasn’t been very good. Here’s my attempt to fix that. This is a battery-ready module with a proper lithium battery charge circuit, lithium battery protection circuit, power supply, and antenna, all in a 1 inch by 1 inch package.
The goal is to have a tiny, inexpensive module that can immediately accept a battery and be deployed in the field, along with 30 of its mates.

See the full post on his blog.

ESP32 AM radio transmitter

am-modulation

A how-to on making a simple AM radio transmitter using the ESP32 microcontroller by Bitluni:

AM Radio transmissions are based on a carrier signal which is modulated by the audio signal. It’s a very basic principle but prone to noise from the environment. Using the ESP32 it is really simple to generate an analog signal using the built-in DACs. With the provided code here just a wire as an antenna has to be connected to the pin 25 of the ESP32. The transmission will end up on the AM frequency ~835kHz.

Via Bitluni’s Lab.

Check out the video after the break.