Add git tag and version number to an Arduino sketch.

The problem:

Version control and tracking is hard.
For sure in the Arduino IDE, which invites to rapid prototyping and has no built-in version tracking or version control mechanism.

A possible solution:

To make it somewhat more practical and less error prone I made some scripts to assist this process.
It works if you already use or start using git for your version control.

Using these scripts is as easy as adding them to your sketch folder and adding

#include "gitTagVersion.h"
...
Serial.println( sketchVersion );

to your Arduino sketch.
That is all that is needed.

The output in the example above will be something like v1.0.0-3-gab3fb04.
That breaks down to tag v1.0.0, 3 commits since that tag, at commit ab3fb04.

How to install and use?

Continue reading

Debug SNTP on ESP32.

Om debug output van de ESP32 SNTP library in de Arduino IDE weer te geven zijn de volgende stappen nodig:

  1. Installeer ESP-IDF.
  2. Kopieer ~/esp/esp-idf/components/lwip/apps/sntp/sntp.c naar de sketch folder.
  3. Verander in  ~/Arduino/hardware/espressif/esp32/tools/sdk/include/lwip/apps/sntp/sntp_opts.h de optie SNTP_DEBUG van LWIP_DBG_OFF naar LWIP_DBG_ON.
  4. Restart the Arduino IDE and recompile the sketch.

Nu worden de debug messages op de seriële poort weergegeven.

Meer info:

https://github.com/espressif/arduino-esp32/issues/1114

Bestand naar C, C++ variable converten.

Om een bestand als variable in C of C++ te gebruiken kun je de tool xxd gebruiken.
xxd is standaard aanwezig op de meeste linux Mint machines.

cellie@cellie-Mint-64 ~ $ echo Hello World\! > temp
cellie@cellie-Mint-64 ~ $ xxd -i temp
unsigned char temp[] = {
0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x20, 0x57, 0x6f, 0x72, 0x6c, 0x64, 0x21,
0x0a
};
unsigned int temp_len = 13;

Om de variable niet in RAM maar in ROM terecht te laten komen verander je de code als volgt:

const char temp[] = {
0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x20, 0x57, 0x6f, 0x72, 0x6c, 0x64, 0x21,
0x0a
};
const int temp_len = 13;

De link:

Natuurlijk niet zelf bedacht maar gevonden op stackoverflow.