Software preparation.
1. Enable Raspberry Pi 2 i2c module:
- sudo raspi-config
- Go to advace menu, and enable i2c module and load on boot
2. Enable and Load some drivers.
- sudo nano /etc/modules
- Add i2c-bcm2708 and i2c-dev at the bottom of the file, then save it and exit.
# /etc/modules: kernel modules to load at boot time.
#
# This file contains the names of kernel modules that should be loaded
# at boot time, one per line. Lines beginning with “#” are ignored.
# Parameters can be specified after the module name.
snd-bcm2835
i2c-bcm2708
i2c-dev
2. Install i2c-tools, for testing purposes:
sudo apt-get install i2c-tools
3. Connect TEA5767 to your Pi GPIO pins as follows:
V3.3 with GPIO V3.3 (pin 1)
SDA with GPIO SDA (pin 3)
SCL with GPIO SCL (pin 5)
Ground with GPIO GND (pin 9 or pin 6)
Be careful not to connect mix up the connection as it could burn your Pi.
4. Reboot Pi
5. TEA5767 should be detected in 0x60
pi@raspberrypi ~ $ i2cdetect 1
WARNING! This program can confuse your I2C bus, cause data loss and worse! I will probe file /dev/i2c-1. I will probe address range 0x03-0x77. Continue? [Y/n] y 0 1 2 3 4 5 6 7 8 9 a b c d e f 00: -- -- -- -- -- -- -- -- -- -- -- -- -- 10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 60: 60 -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 70: -- -- -- -- -- -- -- -- pi@raspberrypi ~ $
6. If you want to start programming i2c devices with Python 3, you should install smbus library and quick2wire.
If you use the latest version of Raspbian, simply do the following to install python3-smbus:
- sudo apt-get update
- sudo apt-get install python3-smbus
Otherwise, you need to install it manually as per this instruction: smbus library
7.Plug in TEA5767 antenna and speaker. Once ready. You are all good to go. Download the following Python 3 programs to your home project directory : https://github.com/LinuxCircle/tea5767/blob/master/tea5767controller.py and https://github.com/LinuxCircle/tea5767/blob/master/tea5767stationscanner.py
Run it the console controller with:
sudo python3 tea5767controller.py
8. To try the web interface, you could also clone the repository https://github.com/LinuxCircle/tea5767.git
16 thoughts on “TEA5767 FM radio digital tuner with Raspberry Pi 2 (part 2 of 3)”
Comments are closed.
great info, there was an easier information obtained explained possible by, I hope by the third party to see that there are interesting
Is this setup specifique to pi 2? what about the B+ models?
IS it safe if i follow the same steps on an old P?
You can apply this to B+ which has the same gpio pin assignments as Pi 2. Or you can use other models so long you can map the right pin assignments to match the instruction for the SDA and SDL pin. The v3.3 and gnd are in the same locations generally.
when ‘sudo python3 tea5767controller.py’
File “tea5767controller.py”, line 29, in
from tea5767stationscanner import tea5767
File “/home/pi/tea5767/tea5767stationscanner.py”, line 22, in
import websocket
ImportError: No module named ‘websocket’
how to solve this problem ?
from the terminal, type
sudo apt-get install python3-websocket
Really helpful guidelines for the project. I have one question, is there a part 3 in this document?
The link is in the menu. Or I’ll add this link at the bottom of the article.
Thanks for the feedback!
https://www.linuxcircle.com/2015/08/19/tea5767-fm-radio-digital-tuner-with-raspberry-pi-2-part-3-of-3/
Hi Dipto! Great instructions and code. I got it working on Pi 3 in June 2017. Had to alter the code to have i2clib.I2CMaster(1) (explicitly specified the “1”) because the pins slightly changed in Pi 3 with respect to previous versions. One question though – it seems that the stations do not set correctly in between 101 and 108: whenever I set the frequency using your code, and the frequency is within this range, I first hear a chirping sound, whose pitch increases with frequency increase, but the station playing (I mean, the music behind the heavy static) remains the same. What might be the reason? Is it due to the formula used for converting the frequency in MHz into values written to the tea5767 for setting the station?
Never experienced that before. I suspect interference with other electronics. Anyone else can help?
when ‘sudo python3 tea5767controller.py’
Traceback (most recent call last):
File “tea5767controller.py”, line 29, in
from tea5767stationscanner import tea5767
File “/home/pi/tea5767-master/tea5767stationscanner.py”, line 25, in
import quick2wire.i2c as i2clib
ImportError: No module named ‘quick2wire’
how to resolve this problem__
Just install it:
https://github.com/quick2wire/quick2wire-python-api
i downloaded the quick2wire and when i do
sudo python setup.py
it didnt work
ok, i installed the quick2wire and activated i2c, when i do
sudo python3 tea5767controller.py
i have problems
Traceback (most recent call last):
File “tea5767controller.py”, line 31, in
a = tea5767()
File “/home/pi/tea5767-master/tea5767stationscanner.py”, line 36, in __init__
self.bus = i2clib.I2CMaster()
File “/usr/local/lib/python3.4/dist-packages/quick2wire_api-0.0.0.2-py3.4.egg/quick2wire/i2c.py”, line 48, in __init__
FileNotFoundError: [Errno 2] No such file or directory: ‘/dev/i2c-0’
Did you enable i2c driver as per the instruction?
# ensure the pi has i2c enabled by adding this to the end of /etc/modules
sudo vim /etc/modules
i2c-bcm2708
i2c-dev
# download and install prerequisites
sudo apt-get update
sudo apt-get install python-smbus
sudo apt-get install i2c-tools
# un-blacklist spi and i2c (disabled by default)
# by commenting out the lines that say
# blacklist spi-bcm2708
# blacklist i2c-bcm2708
sudo vim /etc/modprobe.d/raspi-blacklist.conf
# look for an i2c device on the bus (assuming you have rpi revB)
sudo i2cdetect -y 1
Yes, all is correct, i had done all and the i2cdetect its 60
Can you check if it is installed for python3 or python2?
https://www.linuxcircle.com/2015/05/03/how-to-install-smbus-i2c-module-for-python-3/