All Projects → alankrantas → micropython-TEA5767

alankrantas / micropython-TEA5767

Licence: MIT license
MicroPython driver for TEA5767 FM radio module on ESP8266/ESP32/Pico

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to micropython-TEA5767

Awot
Arduino web server library.
Stars: ✭ 200 (+733.33%)
Mutual labels:  esp8266, esp32
wireless-esp8266-dap
ESP8266 Wireless Debugger. Based on CMSIS-DAP v2.0.0. Optional 40MHz SPI acceleration, etc. ESP8266 无线调试器
Stars: ✭ 154 (+541.67%)
Mutual labels:  esp8266, esp32
Dsckeybusinterface
An Arduino/esp8266/esp32 library to directly interface with DSC security systems.
Stars: ✭ 202 (+741.67%)
Mutual labels:  esp8266, esp32
Esp Webota
Simple web based Over-the-Air (OTA) updates for ESP based projects
Stars: ✭ 189 (+687.5%)
Mutual labels:  esp8266, esp32
smart-pod
An ESP8266 and VS1053 driven WebRadio and Internet music player.
Stars: ✭ 17 (-29.17%)
Mutual labels:  radio, esp8266
Jled
Non-blocking LED controlling library for Arduino and friends.
Stars: ✭ 197 (+720.83%)
Mutual labels:  esp8266, esp32
Awesome Esp
📶 A curated list of awesome ESP8266/32 projects and code
Stars: ✭ 212 (+783.33%)
Mutual labels:  esp8266, esp32
Mongoose Os
Mongoose OS - an IoT Firmware Development Framework. Supported microcontrollers: ESP32, ESP8266, CC3220, CC3200, STM32F4, STM32L4, STM32F7. Amazon AWS IoT, Microsoft Azure, Google IoT Core integrated. Code in C or JavaScript.
Stars: ✭ 2,234 (+9208.33%)
Mutual labels:  esp8266, esp32
Esp32marauder
A suite of WiFi/Bluetooth offensive and defensive tools for the ESP32
Stars: ✭ 233 (+870.83%)
Mutual labels:  esp8266, esp32
Ems Esp
ESP8266 firmware to read and control EMS and Heatronic compatible equipment such as boilers, thermostats, solar modules, and heat pumps
Stars: ✭ 226 (+841.67%)
Mutual labels:  esp8266, esp32
Esp8266 React
A framework for ESP8266 & ESP32 microcontrollers with a React UI
Stars: ✭ 193 (+704.17%)
Mutual labels:  esp8266, esp32
Softrf
✈️ Multifunctional, compatible DIY general aviation proximity awareness system
Stars: ✭ 321 (+1237.5%)
Mutual labels:  radio, esp32
Blynk Server
Blynk is an Internet of Things Platform aimed to simplify building mobile and web applications for the Internet of Things. Easily connect 400+ hardware models like Arduino, ESP8266, ESP32, Raspberry Pi and similar MCUs and drag-n-drop IOT mobile apps for iOS and Android in 5 minutes
Stars: ✭ 8 (-66.67%)
Mutual labels:  esp8266, esp32
Blog
A set of various projects based on ESP8266, ESP32, ATtiny13, ATtiny85, ATtiny2313, ATmega8, ATmega328, ATmega32, STM32 and more.
Stars: ✭ 198 (+725%)
Mutual labels:  esp8266, esp32
Easybutton
Arduino library for debouncing momentary contact switches, detect press, release, long press and sequences with event definitions and callbacks.
Stars: ✭ 187 (+679.17%)
Mutual labels:  esp8266, esp32
Lwesp
Lightweight Espressif AT parser library for ESP8266 and ESP32 devices.
Stars: ✭ 212 (+783.33%)
Mutual labels:  esp8266, esp32
Openmqttgateway
MQTT gateway for ESP8266, ESP32, Sonoff RF Bridge or Arduino with bidirectional 433mhz/315mhz/868mhz, Infrared communications, BLE, Bluetooth, beacons detection, mi flora, mi jia, LYWSD02, LYWSD03MMC, Mi Scale, TPMS, BBQ thermometer compatibility, SMS & LORA.
Stars: ✭ 2,413 (+9954.17%)
Mutual labels:  esp8266, esp32
Dhtesp
Optimized DHT library for ESP32/ESP8266 using Arduino framework
Stars: ✭ 184 (+666.67%)
Mutual labels:  esp8266, esp32
Arduinowebsockets
A library for writing modern websockets applications with Arduino (ESP8266 and ESP32)
Stars: ✭ 213 (+787.5%)
Mutual labels:  esp8266, esp32
codec2 talkie
Turn your Android phone into Codec2 Walkie-Talkie (Bluetooth/USB/TCPIP KISS modem client for DV digital voice communication)
Stars: ✭ 65 (+170.83%)
Mutual labels:  radio, fm

MicroPython Driver for TEA5767 FM Radio Module

41015747

TEA5767 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.

This driver has been tested on ESP8266, ESP32 and RPi Pico running MicroPython v1.16.

The CircuitPython version can be found here.

Wiring

Pin Connect to
+5V 3.3V or 5V
SDA SDA
SLC SCL
GND GND

Both 3.3V and 5V power works; 5V may results better sound quality.

Import and Initialize

To import and initialize the module:

from machine import Pin, SoftI2C
from TEA5767 import Radio

i2c = SoftI2C(scl=Pin(5), sda=Pin(4), freq=400000)
radio = Radio(i2c)  # initialize and set to the lowest frequency
radio = Radio(i2c, freq=99.7)  # initialize and set to a specific frequency

print('Frequency: FM {}\nReady: {}\nStereo: {}\nADC level: {}'.format(
        radio.frequency, radio.is_ready,  radio.is_stereo, radio.signal_adc_level
        ))

You can use I2C module on pins that supported hardware I2C bus.

Parameters

There are a list of parameters that you can set for the radio:

radio = Radio(i2c, addr=0x60, freq=99.7, band="US", stereo=True,
                      soft_mute=True, noise_cancel=True, high_cut=True)
Parameter description
i2c machine.I2C or machine.SoftI2C object
addr I2C address (default 0x60)
freq FM frequency (default = lowest freq by the band setting)
band band limits; "US" (default) = US/Europe band (87.5-108 MHz); "JP" = Japan band (76-91 MHz)
stereo stereo mode (default True = use stereo sound if possible; False = forced mono)
soft_mute soft mute mode (noise control, default True)
noise_cancel stereo noise cancelling (default True)
high_cut high cut control (noise control, default True)

Set Frequency

Set the radio to a specific frequency:

radio.set_frequency(99.7)  # set to FM 99.7

Change Frequency

radio.change_freqency(0.1)  # increase 0.1 MHz
radio.change_freqency(-0.1)  # decrease 0.1 MHz

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

Search Mode

radio.search(True)  # turn on search mode
radio.search(False)  # turn off search mode
radio.search(not radio.search_mode)  # toogle search mode
radio.search(True, dir=1, adc=7)  # turn on search mode and set search parameters

If the search mode is enabled, the radio would attempt to find a station with strong signal whenever you set a new frequency.

  • dir = search direction; 1 = search upward along frequency (default), 0 = downward.
  • 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.

The radio might need some time to find a new station.

Mute/standby Mode

radio.mute(True)
radio.standby(True)

radio.mute() is simply turning off the sound output. If you want to save power, use radio.standby() instead.

The TEA5767 also allows you to turn off right and/or left speaker, but I decided not to implement these functions.

Read Status From the Radio

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

radio.read()
my_variable = radio.frequency
my_variable = radio.search_mode
my_variable = radio.is_ready
my_variable = radio.is_stereo
my_variable = radio.signal_adc_level
  • radio.frequency: current frequency, float number (may be changed in search mode)
  • radio.search_mode: search mode status (True/False)
  • radio.is_ready: station is ready (signal is strong enough)? (True/False)
  • radio.is_stereo: stereo mode status? (True/False)
  • radio.signal_adc_level: station ADC resolution? (0, 5, 7 or 10)

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).

Manually Update the Radio

radio.update()

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.

radio.stereo_mode = True
radio.stereo_noise_cancelling_mode = True
radio.high_cut_mode = True
radio.update()

By default radio.update() will wait 50 ms at the end and then call radio.read().

A Simplified MicroPython Version Without Using This Driver

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

from machine import Pin, SoftI2C

i2c = SoftI2C(scl=Pin(5), sda=Pin(4), freq=400000)

def radio_frequency(freq):
    freqB = 4 * (freq * 1000000 + 225000) / 32768
    i2c.writeto(0x60, bytearray([int(freqB) >> 8, int(freqB) & 0XFF, 0X90, 0X1E, 0X00]))
    
radio_frequency(99.7)

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.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].