Skip to content
This repository was archived by the owner on Feb 22, 2026. It is now read-only.

Commit 3330d37

Browse files
authored
Update README.md
1 parent 132e85d commit 3330d37

1 file changed

Lines changed: 56 additions & 47 deletions

File tree

README.md

Lines changed: 56 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,7 @@
44

55
[TEA5767](https://www.sparkfun.com/datasheets/Wireless/General/TEA5767.pdf) is a cheap but functional FM radio module, which allow you to build DIY FM radios. It comes with an antenna via a 3.5mm jack but have no internal volume control.
66

7-
This driver has been tested on ESP8266, ESP32 and RPi Pico running MicroPython v1.16.
8-
9-
The CircuitPython version can be found [here](https://github.com/alankrantas/circuitpython-TEA5767).
7+
This driver has been tested on ESP8266, ESP32 and RPi Pico running MicroPython v1.16. The **CircuitPython** version can be found [here](https://github.com/alankrantas/circuitpython-TEA5767).
108

119
## Wiring
1210

@@ -21,49 +19,60 @@ Both 3.3V and 5V power works; 5V may results better sound quality.
2119

2220
## Import and Initialize
2321

24-
To import and initialize the module:
22+
Upload ```TEA5767.py``` to your board. You can use [Thonny](https://randomnerdtutorials.com/getting-started-thonny-micropython-python-ide-esp32-esp8266/) to do so.
23+
24+
To import and initialize the driver:
2525

2626
```python
2727
from machine import Pin, SoftI2C
2828
from TEA5767 import Radio
2929

3030
i2c = SoftI2C(scl=Pin(5), sda=Pin(4), freq=400000)
3131
radio = Radio(i2c) # initialize and set to the lowest frequency
32-
radio = Radio(i2c, freq=99.7) # initialize and set to a specific frequency
32+
radio = Radio(i2c, freq=106.7) # initialize and set to a specific frequency
3333

3434
print('Frequency: FM {}\nReady: {}\nStereo: {}\nADC level: {}'.format(
3535
radio.frequency, radio.is_ready, radio.is_stereo, radio.signal_adc_level
3636
))
3737
```
3838

39-
You can use ```I2C``` module on pins that supported hardware I2C bus.
39+
You can also use ```I2C``` module on pins that supported hardware I2C bus (ESP8266s dno't have them):
40+
41+
```python
42+
from machine import Pin, I2C
43+
from TEA5767 import Radio
44+
45+
# Hardware I2C bus 0 on ESP32
46+
i2c = I2C(0, scl=Pin(18), sda=Pin(19), freq=400000)
47+
radio = Radio(i2c)
48+
```
4049

4150
## Parameters
4251

43-
There are a list of parameters that you can set for the radio:
52+
The radio can be initialized with the following parameters:
4453

4554
```python
46-
radio = Radio(i2c, addr=0x60, freq=99.7, band="US", stereo=True,
55+
radio = Radio(i2c, addr=0x60, freq=106.7, band="US", stereo=True,
4756
soft_mute=True, noise_cancel=True, high_cut=True)
4857
```
4958

5059
| Parameter | description |
5160
| --- | --- |
52-
| i2c | machine.I2C or machine.SoftI2C object |
53-
| addr | I2C address (default 0x60) |
54-
| freq | FM frequency (default = lowest freq by the band setting) |
55-
| band | band limits; "US" (default) = US/Europe band (87.5-108 MHz); "JP" = Japan band (76-91 MHz) |
56-
| stereo | stereo mode (default True = use stereo sound if possible; False = forced mono) |
57-
| soft_mute | soft mute mode (noise control, default True) |
58-
| noise_cancel | stereo noise cancelling (default True) |
59-
| high_cut | high cut control (noise control, default True) |
61+
| ```i2c``` | ```machine.I2C``` or ```machine.SoftI2C``` object |
62+
| ```addr``` | I2C address (default ```0x60```) |
63+
| ```freq``` | FM frequency (default = lowest freq by the ```band``` setting) |
64+
| ```band``` | band limits; ```"US"``` (default) = US/Europe band (87.5-108 MHz); ```"JP"``` = Japan band (76-91 MHz) |
65+
| ```stereo``` | stereo mode (default ```True``` = use stereo audio if possible; ```False``` = forced mono) |
66+
| ```soft_mute``` | soft mute mode (noise control, default ```True```) |
67+
| ```noise_cancel``` | stereo noise cancelling (default ```True```) |
68+
| ```high_cut``` | high cut control (noise control, default ```True```) |
6069

6170
## Set Frequency
6271

6372
Set the radio to a specific frequency:
6473

6574
```python
66-
radio.set_frequency(99.7) # set to FM 99.7
75+
radio.set_frequency(106.7) # set to FM 106.7
6776
```
6877

6978
## Change Frequency
@@ -75,51 +84,51 @@ radio.change_freqency(-0.1) # decrease 0.1 MHz
7584

7685
These methods also will change the direction of search mode (see below).
7786

78-
## Search Mode
87+
## Mute/standby Mode
7988

8089
```python
81-
radio.search(True) # turn on search mode
82-
radio.search(False) # turn off search mode
83-
radio.search(not radio.search_mode) # toogle search mode
84-
radio.search(True, dir=1, adc=7) # turn on search mode and set search parameters
90+
radio.mute(True)
91+
radio.standby(True)
8592
```
8693

87-
If the search mode is enabled, the radio would attempt to find a station with strong signal whenever you set a new frequency.
88-
89-
* dir = search direction; 1 = search upward along frequency (default), 0 = downward.
90-
* adc = desired signal ADC resolution (sound quality), default 7. Can be set as 0, 5, 7 or 10. The radio would try to find a station which ADC level satisfied this setting.
94+
```radio.mute()``` is simply turning off the sound output. If you want to save power, use ```radio.standby()``` instead.
9195

92-
The radio might need some time to find a new station.
96+
The TEA5767 also allows you to turn off right and/or left speaker, but I decided not to implement these functions.
9397

94-
## Mute/standby Mode
98+
## Search Mode
9599

96100
```python
97-
radio.mute(True)
98-
radio.standby(True)
101+
radio.search(True) # turn on search mode
102+
radio.search(False) # turn off search mode
103+
radio.search(not radio.search_mode) # toogle search mode
104+
radio.search(True, dir=1, adc=7) # turn on search mode and set search parameters
99105
```
100106

101-
```radio.mute()``` is simply turning off the sound output. If you want to save power, use ```radio.standby()``` instead.
107+
* ```dir``` = search direction; ```1``` = search station by increasing frequency (default), ```0``` = decreasing.
108+
* ```adc``` = desired signal ADC resolution (sound quality). Available values are ```0```, ```5```, ```7``` (default) or ```10```. The radio would try to find a station which ADC level satisfied this setting.
102109

103-
The TEA5767 also allows you to turn off right and/or left speaker, but I decided not to implement these functions.
110+
When the search mode is enabled, the radio would attempt to find a station with strong signal **whenever you set a new frequency or change it**.
111+
112+
The radio may need a bit of time to tune on a stable signal, so it would be recommended to run ```radio.read()``` and keep updating your external display with ```radio.frequency``` on loop.
104113

105114
## Read Status From the Radio
106115

107116
Some variables will be updated after calling ```radio.read()```:
108117

109118
```python
110119
radio.read()
111-
my_variable = radio.frequency
112-
my_variable = radio.search_mode
113-
my_variable = radio.is_ready
114-
my_variable = radio.is_stereo
115-
my_variable = radio.signal_adc_level
120+
frequency = radio.frequency
121+
search_mode = radio.search_mode
122+
is_ready = radio.is_ready
123+
is_stereo = radio.is_stereo
124+
signal_adc_level = radio.signal_adc_level
116125
```
117126

118-
* radio.frequency: current frequency, float number (may be changed in search mode)
119-
* radio.search_mode: search mode status (True/False)
120-
* radio.is_ready: station is ready (signal is strong enough)? (True/False)
121-
* radio.is_stereo: stereo mode status? (True/False)
122-
* radio.signal_adc_level: station ADC resolution? (0, 5, 7 or 10)
127+
* ```radio.frequency```: current frequency, float number (may be changed in search mode)
128+
* ```radio.search_mode```: search mode status (True/False)
129+
* ```radio.is_ready```: station is ready (signal is strong enough)? (True/False)
130+
* ```radio.is_stereo```: stereo mode status? (True/False)
131+
* ```radio.signal_adc_level```: station ADC resolution? (0, 5, 7 or 10)
123132

124133
You may need to call it a few times with some time delay when the search mode is enabled (the radio frequency would jump around a bit).
125134

@@ -129,7 +138,7 @@ You may need to call it a few times with some time delay when the search mode is
129138
radio.update()
130139
```
131140

132-
This method will be automatically called by many other methods of the radio. If you wish to change some parameters, you can manually call ```radio.update()``` to update radio.
141+
This method will be automatically called by many other methods of the radio. If you wish to change some parameters, you can manually call ```radio.update()``` to update radio status:
133142

134143
```python
135144
radio.stereo_mode = True
@@ -138,11 +147,11 @@ radio.high_cut_mode = True
138147
radio.update()
139148
```
140149

141-
By default ```radio.update()``` will wait 50 ms at the end and then call ```radio.read()```.
150+
By default ```radio.update()``` will wait 1 ms at the end and then call ```radio.read()``` for the I2C bus have maximum delay of 400 us.
142151

143152
## A Simplified MicroPython Version Without Using This Driver
144153

145-
If you just want to tune the frequency of TEA5767, you can use code as short as below (simply paste it into your script):
154+
If you just want to set the frequency of TEA5767, you can use code as short as below (simply paste it into your script):
146155

147156
```python
148157
from machine import Pin, SoftI2C
@@ -153,7 +162,7 @@ def radio_frequency(freq):
153162
freqB = 4 * (freq * 1000000 + 225000) / 32768
154163
i2c.writeto(0x60, bytearray([int(freqB) >> 8, int(freqB) & 0XFF, 0X90, 0X1E, 0X00]))
155164

156-
radio_frequency(99.7)
165+
radio_frequency(106.7)
157166
```
158167

159-
This code does not read anything back and don't use enable search mode, but turn on stereo mode, soft mute, stereo noise cancelling and high cut.
168+
This code does not read anything back and don't enable the search mode, but will turn on stereo mode, soft mute, stereo noise cancelling and high cut.

0 commit comments

Comments
 (0)