Microcontroller projects

last updated: 2021-10-30

AVR, ESP, Pico, STM32

First this page was dedicated to AVR® controller from ATMEL®. The projects were in German and mostly Assembler. In meantime I often use Arduino so other controller that can directly be programmed in Arduino as Cortex-M4 (Teensy3) or ESP8266 (Wemos) are found in new projects. Even as my English isn't perfect I switched the language so more people are able to use the information on these pages (older projects are still in German).

I can't guaranty a faultless project, so using the information is at one's own risk.

SmartyReader: Reading Luxemburgish Smartmeter Port P1

Smarty Interestingly the P1 port of the new Luxemburgish smartmeters (Smarty) is encrypted. Because of the spare information it was challenging to get the data. Is use the MQTT protocoll to publish the data and a Raspi with Python to create a homepage with graphics. First I used an Wemos D1 mini board (ESP8266) to publish over Wifi. A second board with a Teensy 3.6 microcontroller was created to read 5 smartmeter and serial data from my rainwater tank (Teensy 3.6 has 6!! serial ports)

SmartyReader for 5-6 Smartys (P1, Ethernet)

SmartyReader using Smarty LED

Tips and tricks for Teensy (m32u4, M4), Wemos (ESP8266)
and Lolin (ESP32) and hardware

Tips and tricks for Teensy 2.0, 3.2 and 3.6 (mega32u4. Cortex-M4)

Using Timer1 and 3 in CTC mode, fast PWM, Teensy as I2C slave, ...
Tips and tricks for Wemos D1 mini (pro) (ESP8266)

Using external antenna, SPIFFS, Wemos as I2C master and as MQTT publisher, ...
Tips and tricks for Lolin (lite,pro) (ESP32)

Not all pins are equal!! What pins should I use?

Arduino tips and tricks

How to configure Arduino, UDEV rules...
Audio tips and tricks

From WAV or MP3 to C: Tips and tricks to play audio files on microcontroller (C/C++).
Watchdog tips and tricks

Feed the dog and use a watchdog reset counter...

Sleep tips and tricks

Using an Arduino chip with battery and LoRa for a long time.
Arduino code snippets

Arduino C/C++ code snippet that I use quite often and that can simplify life :).
ESP NTP tips and tricks

It's easy to use NTP (Network Time Protocol) time server with the ESP's.

Logic_level shifter tips and tricks

Simple logic-level shifter can get unreliable over 100 kHz!
TRIAC tips and tricks

TRIACs are needed to regulate power. Refresh your knowledge about TRIACS.


I work often with both microcontroller from Espressif, the ESP8266 and the ESP32. I'm a forgetful man, and often search quite a long time to find back pieces of code already written and used in my projects. So I wrote an Arduino library to hold all those pieces of code and named it ESPToolbox. The code is intended to work on ESP8266 and ESP32, and to help coding quicker with shorter and clearer code. esptoolbox

Direct Digital Synthesis DDS with microcontroller

dds DDS is a cool thing. To understand how it works is even cooler. So I wrote a little tutorial about DDS (for myself and others :)) . Naturally including software to make it work with an Arduino Uno and a Teensy 4.0.

Fitness Timer: Do your fitness!

"Gymnastics to the urn". Men are not multitasking. So breathing and counting the seconds is not possible. So use this "Fitness Timer" :).

Three tones are generated. The first darker tone starts the exercise. After e.g. 45 s a brighter tone indicates that the repeat is finished. After a pause (e.g. 15 s), the next repeat is done. After x (e.g. 3) repeats a triple tone indicates the end of the exercise.
fitness timer

NeoPixel Clock 2: with minimalistic design :)

neo<em>clock</em>2 A NeoPixel ring with 60 RGBW LED's connected to an ESP8266 gives us a clock using NTP server to get the accurate time. No external RTC needed.

The time lib that is integrated in the ESP8266 core gets the time from an NTP server and runs ab internal RTC. Our hardware is reduced to the strict minimum. Only a 74HCT125 IC is needed as logic-level shifter. A light sensor can be used to dim the LED's at night. The design stays minimalistic.

Garden watering: Activate valves per MQTT over WiFi using an ESP8266

In the last three summers we had months with no rain. Even my 10m³ rainwater tank did not suffice to provide water. But the vegetable garden must be regularly supplied with water. To save water, I use drip hoses, and to simplify my life, I have automated the control of the irrigation.

An ESP8266 (Lolin/Wemos D1 mini pro V2 connects us with the network over WiFi and MQTT is used to give commands and get data.
garden watering

Pico HAT: Connect your Raspi with the Pico through I²C

pico_hat The Pico connects to all the sensors and actuators and can act in Real Time. The Raspi can do the rest (Wifi, Webserver, MQTT, Display ...). The Pico is an I²C slave to the Raspi and the Raspi sends commands with a Python script to the Pico. An Arduino program on the Pico answers with sensor data or by switching an actuator.

As the Arduino IDE runs on a Raspi, both device (Raspi and Pico) can be reprogrammed via VNC from any computer, and I find this pretty amazing :).

GHIDRA: Bare-metal ARM reverse engineering

Ghidra is a free and open source reverse engineering tool, developed by the National Security Agency (NSA). The sources (java and C++) were published in 2019 on GitHub. We will use Ghidra to reverse engineer microcontroller code from an STM32 microcontroller. This is called "bare-metal" because the µC has no operating system and no driver. The application runs directly on the hardware. ghidra

First trials with STM32 microcontroller

STM32 While investigating some IoT devices, I found that quite often microcontroller from STMicroelectronics are used, especially the STM32 ARM Cortex (M0, M3, M4) processors. Here I documented my first trials with these µC. My closing claim is that I will not use these chips for my own projects.

SA1200p (CO2 device) hacks

All Luxembourgish school classrooms got CO2 devices due to Covid. Unfortunately this devices are not produced in Europe, they are not very smart nor IoT, nor are they well suited to use in a classroom. So let's change this and get them at least smarter :). sa1200p

The not completely useless box

useless box XMas again :). So here is the not completely useless box. All the material are recycled or were part of my basic electronics stock. The idea and parts of the code are from this page: https://www.labdomotic.com/2017/10/24/youtube-useless-box-fai-da-te/. To ensure that the box is not completely useless, it has a 3D printed compartment for jewellery (right corner).

The NEO clock

I had a rest of a Neopixel stripe laying around (144 RGB LEDs/m), and one hour has 60 minutes, and Christmas on the doorstep :). So here is the neo clock with the following features:
+ cheap because 3D printed
+ internal RTC synchronized with NTP
+ sound
+ brightness sensor
+ mini photo wall with magnets
+ wall mount or stand
+ webserver and alarm clock possible
neo clock

Thermostat hacks

Thermostat hacks Back in 2010 we used HR20 thermostats from Honeywell (Rondostat) for a school project. They contained an ATmega169 controller from Atmel, and a team from microcontroller.net hacked the thermostat and published the results (in German). Here we will reprogram the thermostat with Arduino and add Lora radio functions

The NEO lamp

I found cool .stl files on thingiverse to print the well known pixar lamp luxo jr. I had still two spare neopixel rings from afafruit, waiting to be integrated in a project. And I needed a gift for XMas :). So here is the neo lamp. Using an ESP8266 with 16MB of Flash (LOLIN/Wemos D1 mini pro) gives plenty of non used space to store a web page. neo lamp

ESP programmer

ESP programmer If you want to program bare ESP chips you can use this ESP programmer. It is not needed when using normal boards with USB header. They contain already a similar hardware as described here.
To program or flash an ESP chip it needs to be placed in a mode where it will accept the new incoming program. Some circuits use two buttons to do this manually. We want to use the Arduino IDE and to do it automatically. For this we need two control lines from serial (TIA-232).

Oscilloscope clock with Teensy 3.6 or ESP32 and internet time

Teensy 3.6 has an internal RTC (and crystal) and 2 DAC with 12 Bit. So no other hardware is needed then the Teensy-Board to create a nice oscilloscope clock. With an ESP8266 it synchronizes once a day with NTP.
The new Lolin32 (ESP32) has 2 DAC with 8 Bit and is able to get the time via Internet.
All the magic is in the code. The Teensy is quick enough to calculate the needed points for the clock, so we can omit tables. The clock strokes are drawn from the circle line back and forth, so no ghost lines appear. Same thing for the second line and hands. 12 Bit gets a real sharp, steady nice image of the clock. The ESP32 needs tables so we can get a stable image.

Fine dust: Measuring particulate matter

dust_sensor In Stuttgart/Germany there exists the OK Lab Stuttgart. There goal is to promote transparency development, open data and citizen science. There project luftdaten.info helps to measure fine dust with cheap but performant self-built sensors. Luftdaten.info generates a continuously updated particular matter map from the transmitted data. Fine dust becomes visible. Here we build our own (slightly modified) sensor.

Creative-Lab IoT-board

Everyone is talking about IoT and MQTT. MQTT is a publisher/subscriber protocol and it is quite simple to implement this protocol on two Wemos D1 mini boards (ESP8266) over Wifi. To read the impulse LEDs of my new five smartmeters (who aren't smart at all for the moment), I needed 5 microcontroller interrupts. This was difficult with only Wemos board, because there weren't enough interrupt pins. So I decided to combine the Teensy 2.0 board (mega32u4) with the Wemos-board.
  • The board can be powered either with the USB mini or the USB micro connector.
  • EIA232 of Teensy or Wemos can be used (selectable with jumper).
  • I2C Bus connector, pull ups if needed (jumper) and header for I2C RTC (DS3231 on photo)
  • 2 EIA485 header if max485 (or 487) is soldered (Wemos or Teensy)
  • Up to 10 Interrupt pins, 9 AD pins, PWM Pins etc.
cl IoT-board

Creative-lab space mining rover: Snyder 1

rover Der Rover lässt sich über das Wifi Netz mit einem PC oder Handy steuern. Er wurde für das creative-lab entwickelt und schon 35x auf dem Luxemburgischen Makerfest aufgebaut. Das nächste Makerfest findet im Dezember 2018 in Luxemburg statt.

The rover is WLAN controlled by a computer or phone. It was developed for the creative-lab. and was build 35 times on the 2 Luxemburgish Makerfest. The next Makerfest is in december 2018.

Kleine USB-Bibliothek für ATMEL®-USB-AVRs

Die Kleine USB-Bibliothek in Bascom, C und Assembler wurde erweitert. Sie unterstützt nun die Controller: ATmega32u4, ATmega32u2, AT90USB162 und AT90USB1287, und kann leicht an andere Controller angepasst werden. Interessante und kostengünstige Boards um die Bibliothek zu nutzen sind zum Beispiel das Entwicklungsboard AT90USBKEY von ATMEL mit dem AT90USB1287 und das Mikrocontroller-Board Teensy 2.0 mit dem ATmega32u4. Die neue Version der Bibliothek lässt sich jetzt besonders leicht einbinden und programmieren. Die Bibliothek existiert in den zwei Varianten: HID (Datentransfer, Tastatur, Maus) und VENDOR (schneller Datentransfer, USB-EIA232).

Kleine USB-HID-Bibliothek

Die HID-Klasse ermöglicht eine Kommunikation unter Windows ohne spezifische Treiber! Die Übertragungsgeschwindigkeit (64 kByte/s) reicht für die meisten Anwendungen. Für den Datentransfer stehen zwei Endpunkte (Buffer) mit je 64 Byte zur Verfügung, die in festen Zeitabständen (1ms, Interrupt-Transfers) abgefragt werden. Es stehen zusätzlich zur normalen Datenkommunikations-Firmware auch Beispielprogramme zur Emulation einer Maus oder einer Tastatur zur Verfügung.

Kleine (schnelle) USB-VENDOR-Bibliothek

Will man größere Datenmengen schneller (bis 1216 kByte/s) übertragen, so kann man Bulk-Transfers nutzen. Allerdings ist die Bus-Bandbreite nicht garantiert, so dass diese Lösung für zeitkritische Anwendungen nicht geeignet ist. Am Bus sollten nicht zu viele Geräte angeschlossen sein. Für die Bulk-Transfers wird eine VENDOR-Klasse (herstellerspezifische Klasse) genutzt. Auch hier stehen zwei Endpunkte (Buffer) mit je 64 Byte zur Verfügung. Die Bibliothek kann aber leicht auf bis zu 6 Endpunkte erweitert werden. Die Bibliothek benötigt Treiber unter Windows. Der Zugriff erfolgt über die "libusb" sowohl unter Linux, wie auch unter Windows. Zusätzlich zur normalen Datenkommunikations-Firmware gibt es auch eine experimentelle Firmware zur Emulation einer seriellen Schnittstelle (EIA232).

AVR experiments board MICES2

NEW! Convert your MICES2 board to Arduino

MICES2 Low-Cost-Experimentierboard für AVR-Controller mit folgenden Eigenschaften:
  • Einseitige Platine (200 mm x 150 mm, 11 Drahtbrücken), gut lötbar, Dateien frei verfügbar
  • Versorgung wahlweise über USB oder über externes Netzteil
  • Verbindung der Baugruppen mit Drahtbrücken (oder flexiblen Steckbrücken)
  • Integriertes Programmiergerät (USB, Kompatibel zum AVRISP mk2)
  • 16 LEDs, 4 Taster (davon 2 entprellt), 8 Schalter, 4-stelliges Siebensegmentdisplay
  • Serielle Schnittstelle, I2C-Schnittstelle, 1-Wire-Schnittstelle
  • D/A-Wandler, Mikrofonschaltung, Audio-Verstärker, 2 Potentiometer 0 V -5 V
  • externes EEPROM, externe Echtzeituhr (RTC)
  • Anschlüsse für Matrixtastatur, Schrittmotor (Treiber), LCD
  • Feld mit Lötaugen um die Platine zu erweitern
  • Schrittweiser Ausbau der Platine (beliebige Bestückung)
  • Neben dem ATmega32A kann zusätzlich der für das Programmiergerät verwendete ATmega32U4 in der Schaltung verwendet werden (2 Controller!), zum Beispiel um Daten über USB an den PC zu senden (siehe: Kleine USB-Bibliothek mit dem Teensy 2.0.

Creative-Lab RT soldering station

A cheap and compact SMD solder station built around a Teensy 2.0. It uses active soldering tips from Weller (RT series) including a heating element and a temperature sensor (standard 3.5 mm jack). The SMD soldering station has a very fast heat up time. RT soldering station

Efficient alarm clock with low electromagnetic radiation,
big display and music player

alarm clock Yes I'm getting older! So I needed an alarm clock with bright LEDs to be seen in the night without glasses. Features of the clock:

CO22 "The mobile measurement station"

Mobile Messstation zum Erfassen von CO2, Temperatur und Luftfeuchtigkeit. Automatisches Logging auf USB-Stick. PC Software um im stationären Betrieb auf dem PC zu loggen und Graphiken zu erstellen. Kommunikation mit dem PC per USB (Teensy2 mit USB-Bibliothek). solar power


Teensylogger Der Teensylogger dient dazu den Energiverbrauch eines Einfamilienhauses zu erfassen. Er loggt dazu bis zu 8 S0-Schnittstellen und kann im Schaltschrank eingebaut werden. Die Daten können zum Beispiel im Minutentakt über die serielle Schnittstelle ausgelesen werden. Zusätzlich werden die Daten als Viertelstundenwerte für einen Monat und als Tageswerte für über ein Jahr in einem externen EEprom abgespeichert.


LeafCANlog is a CAN bus (OBD2) logger and display for the EV Nissan Leaf. It's build around an AT90CAN128 and uses a VDrive2 (FTDI) to log on USB-Sticks. LeafCANlog


USBammeter Das USBammeter misst Spannung, Strom und Leistung am USB-Anschluss und gibt die Daten über ein LCD-Display und zusätzlich über die serielle Schnittstelle aus.

Arduino library for NT7534 in parallel mode

An Arduino library for displays with an NT7534 chip in parallel mode, like the GTK-281 from GEM-TECH. GTK-281

DIY cellphone hacks

DIY cellphone After showing an article of a DIY cellphone in the German MAKE journal to my eldest girl, we had to build two of them. Soldering was no problem with my new RT soldering station. The purchased LCD Displays where of very poor quality (the PCBs were too thin and bended, and so the display had bad contact). We decided to tweak the phone an use an 128*128 OLED Display. The housing is printed with PLA. The arduino file had to be adapted.

Selbstbau USB Programmieradapter

Unter Windows 7-10 nutzt man besser ein Teensy-Board mit einem ATmega32u4, das mit Software aus dem Lufa-Projekt von Dean Camera programmiert wurde. AVRISP with Teensy 2.0