TEA5767 FM Radio with LCD and Keypad display.


The sketch for this project, together with the Phillips Application sheet and the library I used, is available on my GitHub page here.

A version using an Infra Red controller and an OLED Display can be found here.

The TEA5767 is a miniature, high quality, FM Stereo receiver. It can be set to operate on European, USA and Japanese FM systems. The device itself is not capable of operating headphones, but boards (like this one) are available with a stereo amplifier such as  the TDA1308 that will drive amplified speakers as well as headphones. The one I purchased cost just over £3 and came complete with a short antenna.

There is no shortage of libraries, sketches or YouTube postings available for this radio and the majority seem to use an LCD with keypad shield. I tried several different libraries and eventually settled on one that came with a complete project for an FM Radio using the LCD Shield. As I did not want the complexity of the multi menu display that came with this project I decided to keep the library but write my own sketch.

Tuning through the radio spectrum looking for stations is something that was very satisfying in the 1960’s, but now all I want is to push a button and get the station I want. With this in mind I decided to go for preset station frequencies (selected using the RIGHT/LEFT buttons) with the facility to fine tune 0.1mHz (using the UP/DOWN buttons). The SELECT button is used to switch to your favourite station.

The sketch is written to allow up to 10 preset stations and this should be changed to suit your own preferences. A pointer is used to show how many presets there are (set this to your number). The display shows Signal Strength(SS), Stereo/Mono, Frequency and Station name.


I used an Arduino Mega, not because the sketch was large, but because I wanted to plug the LCD Screen on and still be able to plug the radio in. The Radio board has four connections SDA (goes to pin 20), SCL (goes to pin 21). 5 volts and Gnd are at either end of the header at the end of the board.

Install the library in the usual way (this library also includes the project details for the radio project I took this from) and upload the TEA5767_FM_Radio_with_LCD_Shield.ino sketch to the Arduino IDE. Modify the preset stations in the sketch and upload to the Arduino. Press SELECT and your favourite station should play, the Up/Down arrows allow fine tuning if necessary. Either headphones or an amplified speaker can be used, but beware, the TEA5767 does not have a volume control and its always on maximum! Using an amplified speaker with volume control is probably the answer.

The quality is good and even with the small telescopic antenna provided I received several stations. I found that as long as the signal strength was above 50% the signal was clean and clear, but if it fell below that there was a sort of knocking sound and I am not sure if this was being generated by the Arduino. This noise was absent when a strong signal was being received.

I find that using the keypad on the LCD needs a lot of code to achieve a simple aim, in addition the LCD is limited in the amount of information it can provide. My next step is to use an OLED display (the colour TFT display would be good, but it brings its own problems) and to control the radio using an Infra Red controller.

Update. A version using an Infra Red controller and OLED Display can be found at my blog here.


Arduino Pro Mini and HM10/CC41A Bluetooth

Pro Mini and HM10 BT

The sketch for this project can be downloaded from my GitHub page here.

In an earlier post on using the HM10/CC41A BLE units a comment was posted asking about using this Bluetooth with an Arduino Pro Mini. I purchased a Pro Mini recently and it arrived a few days ago. once I had it up and running I connected the Bluetooth unit.

The Tx and Rx signal pins were connected to the Pro mini through a bi directional logic level converter  (Bluetooth Tx to Arduino Software Serial Rx pin and Bluetooth Rx pin to Arduino Software Serial Tx pin) but I used 5 volts to power the Pro Mini. I initially tried using 3 volts but this was unsuccessful. As the Pro Mini does not have a 3.3 volt pin I used a logic level converter with a 3.3 volt regulator.

I uploaded the sketch I use to test Bluetooth units that can be found on my GitHub link at the top of this page, switched the Serial Monitor on (9600 baud, NL and CR selected) and typed in AT . The reply OK  was received showing that the Pro Mini was talking to the Bluetooth unit. I typed in AT+BAUD and received the reply BAUD=4.

This short test shows that the Pro Mini can work with the CC41A BLE unit with no apparent problems.

Keyes KY 031 Hit Sensor

The Keyes KY 031 Hit Sensor Knock or Hit Sensor Keys 031 is a variation on the vibration sensors, except that the sensitivity is much reduced. It is designed to register a hit or contact on for example a robot.

The sketch below turns the onboard LED connected to pin 13 ON when the sensor is gently tapped. To allow the sensor to be simply plugged into the Arduino header I have used pins 6 and 7 to supply power, the sensor output being connected to pin 7. However, the sensor can just as easily be powered from the Gnd and 5 volt pins.

Keyes KY 031 Hit or Knock Sensor
Chris Rouse December 2015
This sensor is less sensitive than the vibration sensors
- on Sensor Board to Arduino Gnd (or pin 5)
Middle pin on Sensor Board to Arduino 5 volts (or pin 6)
S pin on Sensor Board to Arduino pin 7
void setup() {
pinMode(13, OUTPUT); // onboard LED
digitalWrite(13, LOW); // turn off onboard LED
pinMode(5, OUTPUT); // connect to Vibration Sensor S pin
pinMode(6, OUTPUT); // connect to Vibration Sensor MIDDLE pin
pinMode(7, INPUT); // connect to Vibration Sensor - pin
digitalWrite(5, LOW); // Gnd connection
digitalWrite(6, HIGH); // 5 volts connection
void loop() {
if (digitalRead(7) == LOW){
digitalWrite(13, HIGH); // turn ON LED
digitalWrite(13, LOW);

The Starting to use the Arduino Pro Mini.


The Arduino Pro min is a cut down version of a full size Arduino. The number of components used have been reduced to a minimum to reduce the size. The most important thing missing is the USB to TTL chip that allows Arduino users (such as the UNO) to upload programs from a PC. You will almost certainly have to solder the header pins to the board. I found the easiest way was to push the pins into a small solderless breadboard then push the Pro Mini onto the header pins and solder. This ensures the pins are straight, but don’t forget the breadboard is plastic so allow each joint to cool before soldering the next pin.

If you are uncertain which version you have you can check the voltage regulator (the middle of the three black components on the right, in the picture above), the 5volt version has a voltage regulator marked K850, although I have seen GL50. The number 5 will be in there somewhere!

Another way is to power the the board with 7 to 12 volts DC at the RAW pin (NOT Vcc) and measure the voltage at the Vcc pin – it will either be 5 volts or 3.3 volts.

Pin connections::


Programming the Pro Mini::

The communication port for the Pro Mini is the six pins on the right hand side of the board (in the picture above). An FTDI (USB to TTL) adaptor is required. My Pro Mini is the 5volt 16 mHz and my converter has 5 volt signal levels, but if you have the 3 volt Pro Mini you will either need a FTDI converter with 3volt signal outputs (some can switch from 5 volts to 3.3 volts) or use a bi directional logic level converter. The Tx and Rx connections are NOT swapped between the Pro Mini and the FTDI connector and are shown below (the DTR line on the FTDI connector is used to reset the Pro Mini). Some of the clones of the FTDI adaptor, those using the CH340, do not have CTS or DTR (RTS) broken out and so will work. Note that CTS can be left disconnected.



Once the FTDI is connected to the Pro Mini plug it into the USB port of your computer. If this is the first time you have used the FTDI adaptor the  driver should be installed, just follow the on screen instructions. Open up the Arduino IDE, select the Arduino Pro Mini from the list of boards and select the port the FTDI adaptor is connected to. Programs can now be uploaded as normal. Try uploading a simple program like Blink to check all is well, although be aware that some suppliers will load the Blink  sketch into the board to test it.

Ublox NEO 7 GPS module with Arduino.

ublox neo7

The sketch for this blog as well as a copy of the u-center software from UBlox can be found on my GitHub page here.

I ordered a Ublox NEO 7 from a Chinese source in late August. It eventually turned up on December 23! There were times when I thought it had gone missing and I was about to contact the supplier. However, it was definitely worth the wait as this is an amazing device. I have three other GPS units, an Adafruit Ultimate GPS, a Ublox NEO 6 and a navigation unit that is fitted with a Compass unit and a Ublox NEO 6. The NEO 7 is tiny, barely larger than the ceramic antenna and at a cost of less than £6 post paid I wasn’t expecting too much.

The unit is 3.3volt and so would need a logic level converter in the Tx and Rx lines and I used one that supplies 3.3 volts at 500ma to power the GPS. There are six connections, but only four (Ground, 3.3 volts, Tx and Rx) are used, the outside two are not used. The connections are shown below.

pin connections
To test how quickly the NEO 7 could get a fix I simply connected the Ground and 3.3 volt pins to the Arduino and the Red power LED lit up, there were two other LEDs one on the underside and another alongside the ceramic antenna on the top of the board. Neither of these two were lit and I assumed that they would light when the NEO 7 had a GPS fix. The LEDs remained unlit and after 5 minutes I took the Arduino and NEO 7 connected to a power block outside. In less than 30 seconds the two green LEDs lit, showing the unit had a fix. Taking the project back inside the house the LEDs remained lit and the GPS retained its lock, something that none of my other units had done without an active antenna.

The Ublox NEO 7 does not have a backup battery, so any changes made to the baud rate etc will be lost when the power is removed. It seems that there is a version, the Ublox NEO 7N, that stores changes in flash memory (according to the data sheet). The module comes set at 4800 baud, updating once per second and the output is a little slow, but if the baud rate is set to 9600 and the refresh changed to at least twice a second then the output is quite quick. Limiting the output to the $GPGGA Sentence also speeds things up.

The best software for use on an Arduino that I found was in the Arduino Playground. I modified the sketch slightly to use Software Serial on pins 2 and 3 and this version can be downloaded from my GitHub page (link at the top of this blog). This sketch puts the Neo 7 into 9600 baud and refresh at 4 times per second each time the sketch is run

For real use the $GPGGA Sentence would need to be split into its various parts to extract the time and location data and the second sketch does this. Time and location are stored in an array and at the moment this data is printed out, but could be used to set a clock, or to display the current Longitude and Latitude.

Connecting the Neo 7 to a USB to TTL adaptor would allow it to be connected to a PC (a logic level converter would be required unless the adaptor was 3.3 volt) and the UBlox U-Center software could be used. This software can be freely downloaded from the UBlox site, but I have included it in my GitHub repository.

Keyes 039 – Pulse Rate Sensor Module

This post has been updated in May 2016, now I have one of these units to test

This project uses bright infrared (IR) LED and a phototransistor to detect the pulse in the finger. A red LED flashes and phototransistor placed on the other side of the finger detects the pulse. The circuit uses a very high resistance to obtain the best reading, but this makes the circuit susceptible to stray light. Try to keep stray light, particularly mains lighting, to a minimum to reduce interference  to the small signal representing your pulse.

The output from the IR LED is normally invisible, but point the camera from your mobile phone at it to see it glowing brightly. As provided the light output will never get to the sensor, so carefully bend the LED so that it points at the photodiode. I spent some time trying to find a sketch that worked and eventually found this one in the Arduino Forum. Many thanks to the originator. The on board LED pulses to your heartbeat reasonably well and the output from the Serial Monitor gives a very rough reading that all in all at least makes this unit kind of usable.

My advice – buy the heat beat monitor shown in my blog here and use the Keyes 039 for spares!

/// Copyright (c)2015 Dan Truong
/// Permission is granted to use this software under the MIT
/// licence, with my name and copyright kept in source code
/// http://http://opensource.org/licenses/MIT
/// KY039 Arduino Heartrate Monitor V1.0 (April 02, 2015)

/// @param[in] IRSensorPin Analog pin on which IR detector is connected
/// @param[in] delay (msec) delay between calls to this method. It is
///                  best to call it at least 5 times per beat, aka
///                  no slower than 150msec for 70bpm. An ideal value
///                  is 60ms or faster to handle up to 200 BPM.
/// @brief
/// True if heartbeat is detected on the sensor.
/// This code is trivial and just does a peak detection, instead of
/// trying to detect the heart’s pulse waveform.
/// Note: I am fudging sensor data with the delay to make the integer
/// math after that uses constants, somewhat independant of the sleep
/// delay used in the main loop. Otherwise if maxValue decays too slow
/// or too fast, it causes glitches and false beat detection.
//#define HBDEBUG(i) i
#define HBDEBUG(i)

heartbeatDetected(int IRSensorPin, int delay)
static int maxValue = 0;
static bool isPeak = false;
int rawValue;
bool result = false;

rawValue = analogRead(IRSensorPin);
// Separated because analogRead() may not return an int
rawValue *= (1000/delay);
HBDEBUG(Serial.print(isPeak); Serial.print(“p, “));
HBDEBUG(Serial.print(rawValue); Serial.print(“r, “));
HBDEBUG(Serial.print(maxValue); Serial.print(“m, “));

// If sensor shifts, then max is out of whack.
// Just reset max to a new baseline.
if (rawValue * 4L < maxValue) {
maxValue = rawValue * 0.8;
HBDEBUG(Serial.print(“RESET, “));

// Detect new peak
if (rawValue > maxValue – (1000/delay)) {
// Only change peak if we find a higher one.
if (rawValue > maxValue) {
maxValue = rawValue;
// Only return true once per peak.
if (isPeak == false) {
result = true;
HBDEBUG(Serial.print(result); Serial.print(“,  *”));
isPeak = true;
} else if (rawValue < maxValue – (3000/delay)) {
isPeak = false;
// Decay max value to adjust to sensor shifting
// Note that it may take a few seconds to re-detect
// the signal when sensor is pushed on meatier part
// of the finger. Another way would be to track how
// long since last beat, and if over 1sec, reset
// maxValue, or to use derivatives to remove DC bias.
return result;

// Arduino main code
int ledPin=13;
int analogPin=0;

void setup()
// Built-in arduino board pin for the display LED

// Init serial console
Serial.println(“Heartbeat detection sample code.”);

const int delayMsec = 60; // 100msec per sample

// The main loop blips the LED and computes BPMs on serial port.
void loop()
static int beatMsec = 0;
int heartRateBPM = 0;

if (heartbeatDetected(analogPin, delayMsec)) {
heartRateBPM = 60000 / beatMsec;

// Print msec/beat and instantaneous heart rate in BPM
Serial.print(“, “);

beatMsec = 0;
} else {
// Note: I assume the sleep delay is way longer than the
// number of cycles used to run the code hence the error
// is negligible for math.
beatMsec += delayMsec;

Arduino Stop Watch using ILI9328 2.4 inch Display

tft display

The sketch and all the images can be downloaded from my GitHub page here.

There are a number of versions of this ILI9328 TFT colour display, but the one shown in the picture above and here on eBay is designed to plug onto an Arduino and can use either 3.3 volt or 5 volt logic. There are a number of versions of this board that use 3.3 volt logic only and will need either a logic level converter or resistors on the logic pins.


This project uses the touch screen to start and stop the Stop Watch, the SD Card and loading and displaying images. I use the Adafruit Libraries and you will need the Adafruit_GFX.h (Core graphics library), the Adafruit_TFTLCD.h (Hardware-specific library) and the Adafruit Touchscreen.h (Touchscreen library). In addition you will need to download to your library folder SD.h and SPI.h libraries.

I wanted the display to look like an LED display so rather than printing the time I decided to go for a graphics approach. The sketch consists of three main parts, the clock section where a one second counter increments the variable secs from 0 to 59, the variable mins is incremented once every minute and the variable hrs is incremented once each hour. The second part checks the touch screen to see if one of the buttons has been pressed, so that the watch can be started, stopped and reset. The last part is the BMP file loader from the Adafruit test sketch, this loads a BMP graphic from the SD Card and displays it on the screen.

How it works::

Download the sketch and screen graphics from my GitHub page here and save the contents of the images folder to the root of the SD Card on the display. Upload the sketch then remove power and fit the display, reconnect the power to the Arduino and an image of a stopwatch is loaded from the SD Card and displayed on the screen. The LED display consists of five small graphics, hours, minutes and seconds and two colons and when these are loaded they overlay the graphic display. Touching the START button allows a timer to increment and each second the display is updated by loading new LED graphics. There are 59 graphics plus a colon and the stopwatch. It takes approximately 132ms to load each of the three graphics (hours, minutes and seconds) which is less than half a second in total. The timer uses the Arduino example sketch that times without using delay() and this allows the clock to keep reasonable time.

I could have simply printed the time as a string using txt.print(time, x, y) but the time display would need to be erased each time before printing the new time. Besides I think the LED graphics just look better. The colons could easily be made to flash every half second with just a small change to the Sketch.

The buttons are recognised by comparing the x,y values returned by the touchscreen library to the coordinates of an imaginary square around each button. The values in the sketch for the three buttons may need a small adjustment for individual screens, but touching the centre of the button should work in most cases.