Monday, December 31, 2018
ESP8266 library for EFM8 microcontrollers - Server mode
Of course this is not a real web server although with an SD card whole HTML pages could be served. The purpose of this library is to extract queries from a URL requested by a client. This way for example you could change color and brightness of an RGB led using a color wheel in a phone app or control home appliances from anywhere in the world.
Saturday, December 8, 2018
ESP8266 library for EFM8 microcontrollers
Thursday, July 12, 2018
AVR EEPROM Library | ATmega328P
- Flash memory - for the program code
- SRAM memory - also referred as data memory (volatile memory)
- EEPROM memory
Normally, to make use of the EEPROM memory, you would have to read the datasheet and implement some read/write functions using some registers. But fear not - the AVR-GCC compiler comes with prebuilt routines making things much easier.
Friday, July 6, 2018
How to tin your PCB using plumber's paste | Homemade PCB
The last step in making your own printed circuit board (PCB) is tinning. Tinning is important because copper oxidize very fast, leading to an ugly look, hard to solder pads and over longer time, breaks in traces.
When you order PCB's from a manufacturer, the pads look all nice a shiny. I was looking for a way to achieve this at home and I found one. It doesn't involve strong chemicals, it's cheap and it only takes a few minutes.
![]() |
Example of homemade PCB tinning |
![]() |
PCB after tinning |
![]() |
PCB before tinning |
Thursday, May 24, 2018
Analog to Digital Converter (ADC) library for AVR microcontrollers
This library provides a quick and easy way to set up an ADC on AVR microcontrollers and retrieve the values in 8-bit or 10-bit format in an interrupt driven fashion.
Nowadays even the cheapest microcontroller has a build-in ADC (Analog to Digital Converter). An ADC converts analog signals into digital signals and can be used in a wide range of applications like recording a signal from a microphone into a digital format, reading light sensors like an LDR (light dependent resistor), measuring current consumption, reading temperature or humidity sensors, etc. All these requires voltage measurements that an ADC can do.
Wednesday, May 23, 2018
Watchdog library | AVR microcontrollers | ATmega328P
Even if you are a dog or a cat person, you should still be using the watchdog.
For those who don't know, a watchdog is a timer inside the microcontroller generated by an RC oscillator - with 128kHz frequency on an AVR device. When it times out, the microcontroller is reset. To prevent it from resetting the MCU, the watchdog timer must be reset by the code inside the while loop. The idea is that if you have a loop and gets stuck, the watchdog timer will not be reset and so the microcontroller will be reset after the timer reaches the timeout period. Say you read a sensor and in a loop the code waits for the sensor response but the sensor is malfunctioning. If not for the watchdog, the MCU will get stuck and your drone will crash.
On ATmega328 the available timeouts are 16ms, 32ms, 64ms, 0.125s, 0.25s, 0.5s, 1s, 2s, 4s, 8s. Choosing the right timeout depends on the specific application. The while loop must be able to finish executing the code and reset the watchdog timer before the timer runs out. For critical applications where if the CPU being stuck for more than 1 second is unacceptable, you can choose timeouts of a few milliseconds. Those cases can be a drone where reaction time needs to be fast, or a 3D printer reaches the end and the motor needs to be stopped in time. But in most cases the timeout can even be 8s, like when taking room temperature readings.
Other uses for the Watchdog timer
Tuesday, May 8, 2018
Library for reading multiple buttons with 1 ADC pin | AVR microcontrollers
There are many ways of reading switches, and one of them is using ADC pins. The advantages of this method is that it uses very low pin count compared to other methods, and all is needed are switches, resistors and an ADC (analog to digital converter). With a 10bit ADC, at least 20 switches can be used per pin.
To read the buttons the conventional way where every button is connected directly to a GPIO pin, check out this other library https://www.programming-electronics-diy.xyz/2021/01/button-debouncing-library-for-avr.html.
Library Features
- Supports multiple groups of buttons on different ADC pins
- Ability to read combination of multiple button press on different ADC pins
- Can have different number of buttons on each pin
- Check if a button was pressed for a certain amount of time
- Timer 2 and ADC is setup by default
Reading buttons using ADC (configuration #1)
![]() |
Fig. 1 Reading buttons using ADC (configuration #1) |
Tuesday, April 24, 2018
Eagle CAD Tip | How to export PCB layout to an image
Tuesday, March 27, 2018
LC75824 LCD driver chip library for EFM8 microcontrollers
The interface between the LCD driver and the microcontroller is done by using only 3 pins (CLK, CE and DATA).
I know this is an old and rare LCD driver but the library code can be used to adapt other LCD drivers. I use this because I have a broken Samsung MM-N7 audio system with a good display using this IC.
![]() |
LC75824 pinout |
Sunday, March 4, 2018
UART library for EFM8BB1 Busy Bee microcontrollers
This UART library is made for EFM8 microcontrollers. It uses circular buffers for transmission and reception of data. This way large amounts of data can be sent or received with only 5 or 10 bytes per buffer, thus saving memory.
Uses 8 data bits, 1 stop bit, no parity. Supported baud rates: 9600, 14400, 19200, 38400, 57600, 115200, 128000, 256000.
On EFM8BB10F8G-A device, the UART pins are on port 0 and pin 4 is TX and pin 5 is used for RX.
Saturday, March 3, 2018
Delay functions for EFM8 microcontrollers
Because of this I made two functions one for milliseconds and one for microseconds, that uses NOPs that holds the CPU for a certain amount of time.
The milliseconds delay is quite accurate, the microseconds one, not so much.
Eagle CAD Quick Tip | How to remove unwanted copper pour
Friday, March 2, 2018
globals header file for EFM8 microcontrollers
C functions for EFM8 microcontrollers
You often need to use functions or macros across multiple header files, so it is better to put them in a separate header file for better organization. I use a header file called 'globals' and I will be adding or improving things as I go.At the moment the file includes some macros such as CPU frequency and some functions.
uint16_t stringToInt(const char* str); char toUpperCase(char c); bool isLowerCase(const char c);
char *intToString(int16_t number);
Cheap and powerful 50 cents microcontroller | EFM8 Family

Thursday, February 1, 2018
How to build your own USB to UART serial converter using FT232 with voltage level shifting
The board includes 500mA fuse protection, EMI filtering, power LED indicator, RX and TX LED indicators, and a voltage level shifter that makes it compatible with 3.3V and 5V boards. This way you don't need to check the jumper if it outputs 5 or 3.3V so you don't risk burning your microcontroller. It works with both voltages.
Eagle schematic and board layout are available for download down below.
Wednesday, January 24, 2018
EAGLE CAD Tips | How to Add Custom Image Logo to Your PCB
In this video I show as an example a USB to UART board. Eagle expects a Bitmap image with less than 256 color depth.The text image was made in Inkscape and since Inkscape can't export Bitmap (.bmp), I exported the image as PNG, then using IrfanView I lowered the color depth to 2 colors and saved as Bitmap.