This library is intended to provide an easy-to-use interface for controlling the QN8066 FM transceiver.
The primary goal of this Arduino library project for the QN8066 is to simplify the development of robust applications using this device. I hope that hobbyists, electronics technicians, radio amateurs, and others interested in this work will find success in their projects. All the C/C++ funcions and methods are documented [here].(https://pu2clr.github.io/QN8066/extras/apidoc/html/index.html)
This library can be freely distributed using the MIT Free Software model. By using or installing Library you are agreeing to the terms of the MIT licence.
Copyright (c) 2024 Ricardo Lima Caratti.
Contact: pu2clr@gmail.com.
I hold a Master's degree in Educational Technology from the Federal University of Ceará, where I delved into the ways technology can enhance learning experiences. My passion for computer science led me to specialize in it, focusing on Distributed Systems Development with an Object-Oriented approach, at the University of Brasília. My academic journey began with a Bachelor's degree in Information Systems from the União Pioneira de Integração Social (UPIS-Brasília). Outside the classroom, my main hobbies are electronics and Amateur Radio.
This library is continuously evolving, with both corrective and feature updates. While the implemented functions have been tested, it is possible that in certain situations, the library may exhibit unexpected behavior. I encourage users to always utilize the latest release of this library. Should you encounter any issues, please feel free to contact me at pu2clr@gmail.com. I will do my best to address or clarify any problems as quickly as possible. Thank you.
- Legal Compliance Guidelines
- QN8066 Arduino Library Features
- Technical Overview of the QN8066 RX/TX Device (IC)
- Why a QN8066 library for Arduino?
- Groups and Forums
- QN8066 Functional Blocks
- QN8066 PINOUT
- QN8066 Summary of User Control Registers
- DIY Kit 5W-7W FM Transceiver
- Arduino Library Documentation
- Arduino Sketch examples
- Boards where this library can be compiled
- Donate
- References
Please, be aware that the use of FM transmitters is regulated by the laws and regulations of each country. It is crucial to ensure that your use of any FM transmitter complies with the applicable legal requirements and does not violate any broadcasting regulations.
- Frequency Range: Ensure that the frequency range used by your FM transmitter is permitted in your country.
- Transmission Power: Adhere to the maximum allowed transmission power to avoid interference with licensed broadcasters and other communication services.
- Licensing: Check if a license is required to operate an FM transmitter in your region. Obtain the necessary permissions if required.
- Interference: Avoid causing interference with other electronic devices and communication services. Ensure your setup follows the prescribed technical standards.
- Public Safety: Be mindful of public safety and ensure your use of the FM transmitter does not pose any risks.
By following these guidelines, you can ensure that your use of the FM transmitter respects the laws and regulations of your country and does not result in any legal issues.
There is a Facebook group called QN80XX FM Transmitters & Receivers Enthusiasts where the purpose is exchanging experiences with projects based on Quintic QN80XX IC family. You will be welcome there.
-
Mr. Grazianny Carvalho Tavares - I would like to thank Mr. Grazianny Carvalho Tavares, PU7MGR, for introducing me to the QN8066 and encouraging me to develop this library. Mr. Grazianny also played a crucial role in helping me understand various concepts about FM modulation, audio quality criteria, as well as in testing the fundamental functions implemented in this library using equipment for precise value measurements.
-
I would like to thank Mr. Adam Fabio for his article published in the online magazine Hackaday titled Be Your Own DJ With QN8066 And An Arduino Library.
-
I would like to thank Mr. Gareth Halfacree for his article published in the online magazine hackster.io titled Ricardo Lima Caratti's Handy Arduino Library Delivers Easy QN8066-Powered FM Radio Projects.
Technically, no Arduino application strictly requires a library. In some cases, avoiding libraries might even be the right decision. However, there are several compelling reasons to consider using them.
Libraries often simplify the design and maintenance of code, and they can make your projects more portable by implementing the necessary functionality across multiple hardware platforms.
For example, if you want to use an LCD or another display device in a project that monitors temperature and atmospheric pressure, there are many excellent libraries available for Arduino users. These libraries usually include most, if not all, of the features you might need. Re-inventing the wheel by not using a library generally doesn't make sense—unless you need a feature that no existing library supports. Using a library is often the smarter choice, particularly when it can simplify porting your code to different hardware.
Utilizing a library can reduce programming complexity and enhance the robustness of your application. It simplifies life not only for other developers but also for yourself. You don't need to be a software engineer to see the value in this. A library is similar to an integrated circuit (IC); while you could manually implement the functionality of many ICs in a circuit, doing so would significantly increase the cost, complexity, size, and potential for failure of your project. Often, it's better to abstract certain functions inside a ready-made IC. The user only needs to know how to interact with the chip, not how the chip itself is designed.
Finally, if you're already using libraries to handle the I2C bus (Wire.h), TFT or OLED displays, SPI devices, and Serial UART communication, it makes sense to use a library to manage the QN8066 device as well. The QN8066 Arduino Library can add convenience, development speed, and robustness to your project. Unlike closed-source solutions, this library is open-source, allowing you to learn from and modify the code as needed.
This library uses the I²C communication protocol and implements most of the functions offered by QN8066 IC from QUINTIC. This library also has primitive functions that make it easier for you to implement commands that may not have been implemented yet. As said before, this library is constantly improving. Check the API documentation before implementing a new function. It is likely that your function is already implemented. See the API documentation for this library.
- Open Source. It is free. You can use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software. See MIT License to know more.
- Built based on QN8066 Datasheet
- C++ Language and Object-oriented programming. You can easily extend the QN8066 class by adding more functionalities.
- API Documentation. All functions implemented in this library have documentation that can be checked in the source code or at this link
- Available on Arduino IDE (via Manage Libraries). Easy to install and use.
- Cross-platform. You can compile and run this library on most of boards supported by the Arduino IDE (Examples: ATtiny85, boards based on ATmega328 and ATmega-32u4, ATmega2560, ARM Cortex, STM32, Arduino DUE, ESP32 and more).
- Simplifies projects based on QN8066
- A lot of examples to guide the user
- RDS support
- Clock reference selection
The QN8066 is a highly integrated and versatile receiver/transmitter (RX/TX) device designed for use in FM radio applications. It offers a comprehensive solution for high-quality audio reception and transmission with minimal external components, making it suitable for a wide range of applications, including portable radios, automotive systems, and multimedia devices.
- Frequency Range: The QN8066 operates over a wide frequency range, supporting FM band frequencies from 64 MHz to 108 MHz.
- High Sensitivity: The device is engineered to provide excellent sensitivity, allowing for clear reception of weak signals.
- Integrated Analog and Digital Functions: It includes both analog and digital components, ensuring compatibility with various audio formats and enhancing overall functionality.
- Stereo Decoder: The integrated stereo decoder ensures high-fidelity stereo audio output.
- Low Power Consumption: Designed with power efficiency in mind, the QN8066 is suitable for battery-powered devices, extending operational life.
- Digital Signal Processing (DSP): Advanced DSP capabilities improve signal quality and reduce noise and interference.
- Programmable Interface: The QN8066 offers a flexible, programmable interface, enabling easy integration and customization for specific applications.
- Operating Voltage: The device operates at a typical voltage range of 2.7V to 3.6V.
- Current Consumption: It features low current consumption, typically around 20mA during active operation.
- Output Power: The output power is adjustable, catering to different transmission requirements.
- Modulation Modes: Supports various modulation modes including mono, stereo, and digital audio formats.
- Interface: I2C interface for easy communication with microcontrollers and other digital systems.
- Portable Radios: Due to its compact size and low power consumption, the QN8066 is ideal for portable radio applications.
- Automotive Systems: The high sensitivity and DSP capabilities make it suitable for in-car entertainment systems.
- Multimedia Devices: Compatible with a variety of audio sources, the QN8066 can be integrated into multimedia devices requiring FM reception and transmission capabilities.
- RF Front-End: The RF front-end is designed to efficiently capture and process FM signals, ensuring minimal loss and high-quality signal reception.
- PLL Synthesizer: The phase-locked loop (PLL) synthesizer ensures stable frequency generation and accurate tuning.
- Audio Processing: Includes both analog and digital audio processing units to enhance sound quality and support various audio formats.
- Power Management: Advanced power management features optimize power consumption, making the QN8066 ideal for portable applications.
- The Logic signals level of the QN8066 device (CEN, SCL, SDA, to GND) works from 1.6V to 3.6V (see Datasheet, ELECTRICAL SPECIFICATIONS, section Recommended Operating Conditions). If you are using a 5V Arduino board, that Arduino will send 5V signals to the QN8066 device through the digital pins and the I2C bus. That configuration can make the system unstable or damage the QN8066 device. To fix this, use a logic shifter chip that converts between 3.3V and 5V logic.
SSOP16 PIN | NAME | DESCRIPTION |
---|---|---|
1 | SCL | Clock for I2C serial bus |
2 | SDA | Bi-directional data line for I2C serial bus |
3 | VCC | Voltage supply |
4 | ALO | Analog audio output – left channel |
5 | ARO | Analog audio output – right channel |
6 | GND | Ground |
7 | RFI | FM Receiver RF input |
8 | GND | Ground |
9 | ARI | Right channel audio input |
10 | ALI | Left channel audio input |
11 | GND | Ground |
12 | RFO | Transmitter RF output – connect to matched antenna |
13 | CEN | Chip enable with internal pull up: Chip power down if less than 0 |
14 | XCLK | External clock input |
15 | GND Ground | |
16 | INT | Interrupt output, active low, need pull-up externally |
REGISTER | NAME | USER CONTROL FUNCTIONS |
---|---|---|
00h | SYSTEM1 | Sets device modes |
01h | SYSTEM2 | Sets external clock type and CCA parameters |
02h | CCA | Sets CCA parameters |
03h | SNR | Estimate RF input CNR value |
04h | RSSISIG | In-band signal RSSI dBµ V value |
05h | CID1 | Device ID numbers |
06h | CID2 | Device ID numbers |
07h | XTAL_DIV0 | Frequency select of reference clock source |
08h | XTAL_DIV1 | Frequency select of reference clock source |
09h | XTAL_DIV2 | Frequency select of reference clock source |
0Ah | STATUS1 | System status |
0Bh | RX_CH | Lower 8 bit of 10-bit receiver channel index |
0Ch | CH_START | Lower 8 bits of 10-bit channel scan start channel index |
0Dh | CH_STOP | Lower 8 bits of 10-bit channel scan stop channel index |
0Eh | CH_STEP | Channel scan frequency step |
0Fh | RX_RDSD0 | RDS data byte 0 |
10h | RX_RDSD1 | RDS data byte 1 |
11h | RX_RDSD2 | RDS data byte 2 |
12h | RX_RDSD3 | RDS data byte 3 |
13h | RX_RDSD4 | RDS data byte 4 |
14h | RX_RDSD5 | RDS data byte 5 |
15h | RX_RDSD6 | RDS data byte 6 |
16h | RX_RDSD7 | RDS data byte 7 |
17h | STATUS2 | Receiver RDS status indicators |
18h | VOL_CTL | Audio volume control |
19h | INT_CTRL | Receiver RDS control |
1Ah | STATUS3 | Receiver audio peak level and AGC status |
1Bh | TXCH | Lower 8 bit of 10-bit transmitter channel index |
1Ch | TX_RDSD0 | Transmit RDS data byte0 |
1Dh | TX_RDSD1 | Transmit RDS data byte1 |
1Eh | TX_RDSD2 | Transmit RDS data byte2 |
1Fh | TX_RDSD3 | Transmit RDS data byte3 |
20h | TX_RDSD4 | Transmit RDS data byte4 |
21h | TX_RDSD5 | Transmit RDS data byte5 |
22h | TX_RDSD6 | Transmit RDS data byte6 |
23h | TX_RDSD7 | Transmit RDS data byte7 |
24h | PAC | PA output power target control |
25h | FDEV | Specify total TX frequency deviation |
26h | RDS | Specify transmit RDS frequency deviation |
27h | GPLT | Transmitter soft chip threshold, gain of TX pilot |
28h | REG_VGA | TX AGC gain |
It is possible to find Transceivers based on the QN8066 in kit form. With this library, you will also be able to control this kit, thereby expanding its original functionalities. Check AliExpress and others to check it out.
The images below show the DIY Kit 5W-7W FM Transceiver available on AliExpress.
The code below is a minimalist sketch example of using this library with the DIY Kit 5W-7W FM board.
Anduino Nano or Uno pin | Kit 5W-7W FM |
---|---|
GND | GND |
D9 | PWM (*1) |
A4 | SDA (*2) |
A5 | SCL (*2) |
During experiments, commands sent to the QN8066 via I2C often had no effect, such as switching from "Stereo" to "Mono" or changing the transmission frequency. To resolve this, disable the PWM (0% duty cycle) before sending commands and re-enable it afterward.
#include <QN8066.h>
QN8066 dv;
void setup() {
Serial.begin(9600);
while (!Serial);
pinMode(9, OUTPUT); // Pin use to PWM power control
dv.setup();
Serial.print("\nStarting the system...");
delay(1000);
dv.setTX(1067); // Set the transmitter to 106.9 MHz
dv.setTxStereo(true);
// Now you can start PWM
analogWrite(9, 50); // It is about 1/5 of the max power (5~7W). It is between 1 and 1,4 W
Serial.print("\nBroadcasting...");
// Turning the Stereo OFF
analogWrite(9, 0); // Disable PWM
dv.setTxStereo(false);
analogWrite(9, 50); // Enable PWM
}
void loop() {
}
The "DIY 5~7W FM Transmitter Kit" is designed for 3.3V controllers and has I2C pull-up resistors connected to its 3.3V power supply. However, the Arduino Nano operates at 5V, producing 5V signals on the I2C bus, which can cause communication instability. Additionally, the Nano cannot run stably on a 3.3V supply from the kit.
The simplest, but impractical, solution is to modify the Arduino Nano to run at 3.3V by changing its crystal to 8MHz and updating the bootloader. A better option is to use an Arduino Pro Mini 3.3V for direct compatibility.
In some examples using the Arduino Nano, a 3.3V to 5V voltage converter was added for power, along with two 150-ohm resistors in series with the I2C bus and two 10K resistors as pull-ups. While not ideal, this method works. A more appropriate solution would be to use a bidirectional I2C level shifter for compatibility.
The Arduino Nano is used in some examples in this library because it's popular among hobbyists, many of whom already have one or an Arduino Uno with the same architecture. Most other examples use 3.3V microcontrollers that do not require any modifications.
See also DIY Kit 5W-7W FM example
The following figure shows the "DIY Kit 5W-7W FM TRANSMITTER" connected to the Arduino Pro Mini. The following link provides more operational details. Click here to watch the video.
Click here to see the source code and schematic
Before presenting some observations that I consider important, it is worth highlighting that the following information may not reflect the reality in other environments or with other kits. The goal here is not to judge the quality of the kit or its architecture. However, these observations may explain some phenomena you might experience during the development of your project and help you mitigate these issues.
Based on several experiments I conducted with this kit, I observed instability in the communication between the microcontroller and the QN8066 via the I2C bus in the following situations:
-
PWM Line Interference: When the PWM line to control the transmitter's power is active, communication failures and even unavailability of the QN8066 to respond to new commands are common. One solution to this problem was to disable the PWM signal every time a command is sent to the system and re-enable the PWM signal afterward. It is important to note that this behavior hinders or limits, to some extent, a more dynamic use of RDS services.
-
High Power Transmission: When the transmitter is configured to transmit at higher power levels, approaching its upper limit of 7W, the communication also becomes unstable, and the QN8066 stops responding to the microcontroller, even though it continues to transmit.
-
Avoid touching: Touching certain points on the KIT board or the microcontroller with your hands can also cause system instability.
-
Wire-up organization: Shortening and organizing the I2C bus lines that connect the KIT to the microcontroller significantly improves system stability.
-
Good grounding: Through good grounding, it was possible to make the system stable. It was possible to transmit for several hours without interruption and without communication problems with the I2C.
It is important to highlight that this library was not developed exclusively to work with this kit. In fact, it was designed to work with any architecture involving the QN8066 via the I2C protocol. That said, it is crucial for the designer or experimenter to keep in mind the necessary precautions to provide a stable system. There are various literatures that can help follow the best design practices involving I2C communication.
In a new project involving the QN8066, I believe a more stable approach would be not to work with power levels above ½W on the same board. An additional amplification module could be added separately from the QN8066 circuit. The organization of the printed circuit board is also a determining factor in improving the stability of the system. Preferably, the communication circuit of the microcontroller with the QN8066 should be as far away as possible from the RF circuit. The appropriate values for the pull-up resistors for the I2C bus is a variable that deserves attention. These values may depend on the length of the bus and other I2C devices that may be connected to the circuit. In my experiments, I used 10K pull-up resistors. However, lower resistance values can be tested and may further improve the stability of the system. Consider shielding the Display and microcontroller circuit so that unwanted signals and interference do not propagate to the QN8066 circuit.
This library can be useful to develop cross-platform software.
The table below shows the some boards where this library has been successfully compiled.
Board | Need voltage converter | I²C Pins | Used Reset Pin | Features | |
---|---|---|---|---|---|
1 | Arduino Pro Mini 3.3V 8MHz | No | A4 and A5 | 12 | More... |
2 | Mega 2560 Pro | Yes | 20 and 21 | 12 | More... |
3 | ESP WEMOS LOLIN32 | No | GPIO21 and GPIO22 [4] | GPIO25 [5] | More... |
4 | ESP32 Dev Module | No | GPIO21 and GPIO22 [4] | GPIO25 [5] | More... |
5 | ESP32 Wrover Module | No | GPIO21 and GPIO22 [4] | GPIO25 [5] | More... |
6 | ESP8266 | No | GPIO4 and GPIO5 | GPIO2 | More... |
7 | Arduino UNO | Yes | A4 and A5 | 12 | More... |
8 | Arduino NANO ATmega 328 | Yes | A4 and A5 | 12 | More... |
9 | Arduino NANO ATmega 168 | Yes | A4 and A5 | 12 | More... |
10 | Arduino NANO 33 IoT | No [6] | A4 and A5 | 12 | More... |
11 | Arduino Yún / ATmega-32u4 | Yes | 2 and 3 | 12 | More... |
12 | ATtiny84 | No | 7 and 8 | 6 | More... |
13 | ATtiny85 | No | 5 and 7 | 2 (D3) | More... |
14 | Arduino DUE | No | 2 and 3 | 12 | More... |
15 | BlueDuino 3.3V (ATmega-32u4) | No | 2 and 3 | 10 | More... |
16 | Arduino Mini Pro 5V 16Mhz | Yes | 2 and 3 | 10 | More... |
17 | STM32F746G-DISCO | No | - | - | More... |
18 | STM32F103 Series | No | PB6 (SCL) and PB7(SDA) | PA12 | More... |
19 | STM32F411 Series | No | PB6 (SCL) and PB7(SDA) | PA12 | More... |
20 | Raspberry Pi Pico | No | GP0 (0) and GP1 (1) | GP16 (16) | More... |
21 | WeAct Studio RP2040 Pico | No | GP0 (0) and GP1 (1) | GP16 (16) | More... |
22 | Seeeduino XIAO | No | A4 and A5 | 3 | More... |
23 | Teensy 3.1 | No | A4 and A5 | 12 | More... |
24 | Teensy 4.1 | No | A4 and A5 | 12 | More... |
25 | Atmega8 | No | PC4 and PC5 | PD6 | More... |
26 | Atmega32 | No | PC1 and PC0 | PB2 | More... |
27 | Atmega128 | No | PC1 and PC0 | PB2 | More... |
28 | LGT8F328P | No | A4 and A5 | 12 | More... |
29 | LUATOS ESP32C3 | No | GPIO4 and GPIO5 | GPIO8 | More... |
If you find this project useful, consider making a donation so that the author of this library can purchase components and modules for improvements and testing of this library. Click here to donate or use the QR code below.
- Data Sheet - QUINTIC QN8066 Digital FM Transceiver for Portable Devices
- Radio Data System
- Best Practices for RDS Subcarrier Injection
- RDS Encoder Version 1.5 Implementation Manual
- Dynamic_RDS - FM Transmitter Plugin for Falcon Player
- Broadcasting Audio Processing
- UNIVERSITY COLLEGE LONDON Department of Electronics and Electrical Engineering
- NATIONAL RADIO SYSTEMS COMMITTEE NRSC-G300-A Radio Data System "RDS" Usage Guideline April 2014
- Ricardo Lima Caratti's Handy Arduino Library Delivers Easy QN8066-Powered FM Radio Projects
- Be Your Own DJ With QN8066 And An Arduino Library
- Old Version of this library - Source 1
- Old Version of this library - Source 2