Arduino controlled Dual Mono AK4490 DAC (part 1)


This article is the first of a series detailing the design and build process of an Arduino controlled Dual Mono AK4490 DAC by DimDim:

The design goal was to do a dual mono design so as to maximize SNR and channel separation. A 4-layer PCB design was chosen so as to have a very solid, low impedance ground plane as well as proper power and signal planes. The I2S, audio signals and power after the local LDO regulators are routed on the top layer, the 2 middle layers are ground and power planes, and the bottom layer serves to route I2C signals and some power lines.

See the full post here, Dimdim’s blog.

How to configure I2C sensors with Arduino


Edward Mallon writes:

I’ve spent the last year in the ‘uncanny valley’ of the Arduino. That’s the point where you understand the tutorials at, but still don’t get much from the material on gitHub because trained programmers would never stoop to using the wire.h library when they could just roll their own in native C++ using the avr-g++ compiler.  The problem with establishing sensor communication at the level of the TWI peripheral inside the AVR is that there are so many fiddling details to keep track of that it quickly overruns the 7±2 things this average human can hold in his head at one time: Computers aren’t the only things that crash after a buffer overflow!  So this post is meant to be a chunking exercise for beginner-intermediate level people like myself who want to get a new sensor working using the standard IDE.  I’ve tried to distill it all down to things that I run into frequently, but there’s still a lot of material here:  So pour yourself a cuppa before diving in…

More details at Arduino based underwater sensors blog.

ESP8266 Deep Sleep with Arduino IDE


Rui Santos has written a great guide shows us what’s Deep Sleep and how to use it with the ESP8266 in the Arduino IDE.

With most of the ESP8266 modules, you can’t change the hardware to save power, but you can write software to do it. If you use the sleep functions with the ESP8266, it will draw less power and your batteries will last longer. In this guide, we’re going to talk about Deep Sleep with the ESP8266.

See the full post on his blog, Random Nerd Tutorials.

Check out the video after the break.

Pulse Oximeter functionality for a medical device

Pulse Oximeter on my finger-600

Alexander Lang writes:

The gentlemen for whom I’m developing this hardware for has requested some additional functionality. The additional functionality requested is a Pulse Oximetry measurement.  Pulse Oximetry is the measurement of a person’s pulse along with how much oxygen is present within their blood.  It is a common measurement made by medical practitioners to ensure their patients are in good health.  I suspect for the medical device, this information will be correlated with a person’s breathing to assess how well a person’s lungs are working and how much oxygen from the air is getting into their blood.

See the full post on his blog here.

DCC shield for Arduino

In addition to the love for electronics, in my (little) spare time I’m working with my friend Davide on a model railway in H0 scale; in particular my main task is to take care of the digital control of locos, turnouts and accessories.

Davide’s main job is to create architectural and railway models. You can see his projects and follow the updates to our model railway on the dedicated Facebook page and website.

The de facto standard to digitally control a model railway is named DCC (Digital Command Control); it is a communication protocol defined by the american National Model Railroad Association. The specs of the protocol are available on NMRA’s website.

Using DCC, you control a loco sending commands through the rails to modules (decoders) installed within the loco itself: based on the commands it receives, the decoder controls motor, lights and in some cases also sounds and smoke generators…


DCC decoder installed in a locomotive

Specific decoders are also available to control turnouts and accessories:


turnout DCC decoder DCC by Esu

Thanks to Alex Shepherd and other developers, an Arduino library is available to receive and parse DCC commands.

You can install the library using the IDE’s Library Manager:


I designed in Eagle a simple shield to have an optocoupled connection between Arduino and the DCC bus:


The NmraDcc library requires that you connect the DCC signal to an Arduino pin which supports interrupts. Because of Arduino Uno has pin 2 and 3 with that feature, I added a jumper to the shield you can use to choose the pin:


The Eagle files for the shield are available on Github; in the same repository you can also find an example program, which changes color and brightness of an led based on speed and direction of the loco with id 10:

The use of the library is quite straightforward. First specify the pin for the DCC signal:, 2, 1);

The first parameter is the interrupt number, the second is the pin number and the third is the status of the internal pullup resistor (1 means enabled). You can find the link between pin and interrupt number in the official documentation:


Then initialize the library:

Dcc.init(MAN_ID_DIY, 10, 0, 0);

The first two parameters are the manufacturer and the version of the decoder. NMRA keeps a list of manufacturers and reserved the value 0x0D (constant MAN_ID_DIY) for opensource and DIY decoders:


With the third parameter you can change the default behaviour of the library:


while the last one is the EEPROM address from which the library stores its values.

To let the library process incoming packets, you have to call the process() method as frequently as possible in the loop:


If the library receives a command to change the speed/direction of a loco, it executes the callback function notifyDccSpeed:

void notifyDccSpeed( uint16_t Addr, DCC_ADDR_TYPE AddrType, uint8_t Speed, 

in this function I implemented the code that controls the led.

dccshield-02 dccshield-01

RFID and Arduino (1)

In this tutorial, divided in two posts, I’ll show you how to use RFID (Radio-frequency Identification) tags with Arduino.

In the first part you’ll learn how to connect the reader to your Arduino and how to write a simple sketch to display the tag’s ID, while in the second part you’ll learn how to build a complete access control system based on RFID tags.


I chose as RFID reader a board based on the PN532 chip by NXP. This is a very versatile chip: it can work as a tag reader/writer but it can also act as a RFID tag; moreover it supports both I2C and SPI communication buses.

Adafruit created a breakout board for the PN532 chip and the Arduino libraries we’re going to use. Alternatively you can find on several webstores the following board, that I’m also going to use for this tutorial:

rfid-03 rfid-04


As I wrote before, the PN532 chip supports both I2C and SPI. For simplicity, I’ll use the first one, connecting the SDA and SCL pins of the board to the corresponding pins of Arduino. You have also to connect the IRQ pin to a digital pin of your Arduino (I chose pin 2); thanks to this connection the PN532 pin “warns” Arduino if a new tag is being read:

rfid-06 rfid-07

To select the I2C bus, you have to set the board’s dip switches as explained on the silk screen:


Finally, power the board connecting the VCC and GND pins to pins 5V and GND of Arduino.

For this project, I used the beta version of a new LCD shield by Lemontech. The main feature of this shield is that the LCD is connected to Arduino via an I2C expander; moreover all the buttons are connected to only one pin, the analog pin A0. This means that almost all the Arduino pins are still available for connecing other devices. The display’s default address – but you can change it – is 0x27 while the PN532 chip has address 0x24 so there’s no conflict.

rfid-10 rfid-11jpg

Having two devices connected to the I2C bus, I had to add two 10Kohm pull-up resistors for SCL and SDA as explained in the following schematics:


To keep things simple, I place them on a small breadboard:


I also added a small speaker (connected to pin 8 and GND) to play a sound everytime Arduino reads a tag:



To be able to compile the sketch of this tutorial you have to install the following libraries in your IDE:

  • Adafruit PN532 di Adafruit
  • hd44780 di Bill Perry

Both the libraries are available in the Library Manager:



The complete sketch is available in my Github repository.

To use the LCD, first you have to define its size (rows and columns), the address on the I2C bus and the pins it’s connected to. You can then initialize the library in the setup():

#define LCD_COLS      16
#define LCD_ROWS      2
hd44780_I2Cexp lcd(0x27, I2Cexp_PCF8574, 0,1,2,4,5,6,7,3,HIGH);
if(lcd.begin(LCD_COLS, LCD_ROWS) != 0) {
  Serial.println("- Unable to initialize LCD!");

The same for the PN532 chip: you have to declare the pin connected to the IRQ signal (RESET is optional) and then initialize it. Using the getFirmwareVersion method you can get the chip version and therefore verify that it’s working correctly:

#define PN532_IRQ     2
#define PN532_RESET   3
Adafruit_PN532 nfc(PN532_IRQ, PN532_RESET);
uint32_t versiondata = nfc.getFirmwareVersion();
if(!versiondata) {
  Serial.println("- Unable to find a PN532 board");
Serial.print("- found chip PN5"); 
Serial.println((versiondata>>24) & 0xFF, HEX);

Lastly, call the SAMConfig() method to configure the chip in normal mode and to enable the IRQ pin:


It’s very easy to read a tag. The readPassiveTargetID method returns true if a tag is near the reader:

success = nfc.readPassiveTargetID(PN532_MIFARE_ISO14443A, uid, &uidLength);
if (success) {

In this case, you can play a sound and display the tag’s ID on the display:

lcd.print("Found RFID tag!");
lcd.print("ID: 0x");
for(int i = 0; i < uidLength; i++) {
  if(uid[i] <= 0xF) lcd.print("0");
  lcd.print(uid[i] & 0xFF, HEX);    


Solid-state joystick


Paul Gardner-Stephen writes:

Early in the year, one of my colleagues, Damian, showed me one of these strain-gauge solid-state joysticks that they were using as part of the undergraduate engineering curriculum.
Their goal was to teach the students how to read strain-gauges. But I immediately saw the applicability for making a no-moving-parts super-robust joystick for the MEGA65 and all other retro computer users.

See the full post on his blog.

STM32 and Arduino

STM32 is a family of 32bit microcontrollers manufactured by STMicroelectronics and based on the ARM Cortex M core.

The STM32 family is divided into different lines of microcontrollers (L0-1-4, F0-1-2…) depending on their features and the use they are designed for:


These microcontroller are widely used in the industrial world… for example both Pebble watches and Fitbit bracelets are based on STM32 MCUs.

If you’re interested in quadricopters or drones, you probably have heard or used F1, F3, F4 flight control boards. The board name (“F…”) indicated indeed the STM32 microcontroller they are based on.

Thanks to the work made by the stm32duino community and to the support of ST itself, starting from the past June STM32 microcontrollers can be easily used with the Arduino IDE and it’s also possible to take advantage of most of the libraries available for Arduino.

I decided to buy a minimal development board based on the STM32F103C8T6 microcontroller (these boards are sometimes known as blue pills); let’s see how to use it with Arduino.


Many boards are sold unprogrammed: the first thing to do is therefore to program a bootloader, that is a small program which will allow to upload the “real” program via USB port.

To flash the bootloader, you need an USB -> serial adapter, connected to your dev board as it follows:

  • RX -> A9
  • TX -> A10
  • VCC -> 5V
  • GND -> GND

stm32-18 stm32-19

You have also to enable the programming mode, moving the first jumper (labeled BOOT0) to position 1:


Now you need a software to flash the file with the bootloader into the chip. If you’re under Windows, you can download the Flash Loader from ST’s official website: after having registered (for free) you’ll receive the download link via email.

The bootloader is developed and maintained by Roger Clark and it’s available in his Github repository. For STMF1 boards there are several binary files, depending on the PIN the onboard led is connected to. My board uses P13, so I downloaded the file generic_boot20_pb13.bin.

Run the Demonstrator GUI program and select the serial port your adapter is connected to:


If all the connections are ok, the software should be able to detect the microcontroller:


Now you can select the specific MCU your board uses:


then select the file with the bootloader and program it. To be sure, you can ask the software to perform also a global erase of the memory:


The program will flash the chip and, when complete, will confirm the operation with a message:


If you now move back the BOOT0 jumper to the original position, you should see the led blink: this means that the bootloader is running and can’t find a program to execute… now it’s time to configure the IDE.

Arduino IDE

Open your IDE and select File – Preferences. Type the following address in the Additional Boards Manager URLs field:


Now open the Boards Manager:


Search STM32F1 and install the corresponding Cores package:


You’re almost ready to compile and run your first program…


Connect the dev board to your PC using an USB cable and verify how it is identified.

It may happen that Windows cannot correctly identify the board and displays it as Maple 003, is this case you have to install the correct drivers:


Download the following files from Clark’s repository:

  • install_STM_COM_drivers.bat
  • install_drivers.bat
  • wdi-simple.exe

Run the two .bat:


now Windows should identify the board correctly:


Sometimes Windows cannot see the additional serial port of the board. To solve the problem, you can try to program on the board a simple sketch that uses the Serial object. Open for example the blink sketch and change it as it follows:


Program the sketch choosing BluePill F103C8 as board and STM32duino bootloader as upload method.

Once the sketch is programmed and executed, Windows should detect and install the new COM port:


You’re done, now the board is fully integrated with the Arduino IDE:


Building a single pixel scanner


Kerry Wong published a new build:

A flat bed scanner typically uses three rows of CCD sensors (RGB) to capture images placed directly on top of the glass bed. When the CCD array scans from one end of the image to the other, the digitized color image is formed. So with a similar approach, we could use just one photosensitive device to capture the entire image one pixel at a time via raster scanning. Now that I have an HP 7044A X-Y recorder I could use it’s X/Y servo mechanism with a suitable sensor to build a single pixel scanner.
The simplest sensor would be just a photodiode or a CdS photocell. For capturing grayscale images, either of these sensors could be used. To capture color images though, we would need a sensor that is capable of discerning the RGB components of each pixel. For that I used an inexpensive TCS34725 based color sensor module.

More details at Kerry D. Wong blog.

Check out the video after the break.