The sketch for this project can be found on my GitHub page here.
My last blog used the little FM radio, TEA5767, with a two line LCD and keypad display. I felt that it was a little clumsy and so decided to use an Infra Red controller and display the radio data on an OLED Display. I have gone for a number of preset stations and not to use the scan function. As it stands the sketch has six preset stations and the infra red remote is used to switch between them. There is also a favourite station button, press this and the radio tunes straight to your favourite. Two other buttons on the IR controller allow fine tuning up or down, this increases or decreases the frequency by 0.1 mHz.
The radio wil automatically switch from Stereo to Mono if the signal strength drops to a level that affects sound quality. The display shows the audio mode, in this case it has switched to mono. The radio reports the signal strength and this is shown as a figure from 1 to 10. The third row shows the frequency the radio is tuned to, this is the value reported by the radio, for example a value of 102.0 mHz had been sent to the radio, but the radio had tuned to 101.99 mHz. The next row down is the station name and the last row is the tuning scale from 80 mHz to 110 mHz, a cursor shows the frequency.
The TEA5767 and the OLED Display are I2C, connect Vcc and Gnd to the Arduino 5volts and Gnd. Connect SDA to Arduino pin A4 and SCL to Arduino pin A5. The infra red receiver has three connections, Vcc, Gnd and signal. Connect the signal, or data out, to Arduino data pin 3 and Vcc and Gnd to Arduino 5 volts and Gnd. Connect a flying lead to Arduino digital pin 3, this will be used to switch the display to the IR decode display. Almost any IR controller can be used and the sketch allows a setup mode to be entered, and this displays the decimal value of the key press. Decide which keys you are going to use for Preset Up, PresetDown, Favourite, fineTuneUp, finetuneDown and Radio On/Off. Put the sketch into setup mode by connecting the flying lead from pin 3 to Gnd, point the controller at the IR receiver and press a key (the onboard LED will light) and its value will be displayed as shown below. Press the key a few times to confirm the value and once you have all the key values needed put them into the sketch.
Adding the station names and frequencies:
Make a list of up to six stations you want to listen to (this can be increased or decreased by changing the values of stationMHZ[n] and stations[n] where n is the number of preset stations + 1. Station names and frequencies are stored in these arrays, for example:
stationsMHZ = 88.58;
stations = “BBC Radio 2”;
stationsMHZ = 96.10;
stations = “Radio Solent”;
the maximum number of preset stations and the favourite are set as follows:
maxPresets = 6; // number of stations in list, change this as required
favourite = 6; // select your own favourite
The favourite station will play when power is first applied.
I found a number of libraries on the internet, but settled on this one by Marcos R. Oliveira and this is the library I have used here. I have included a copy of this library on my GitHub page as shown at the top of this blog.