Arduino Wiring


You can easily wire this breakout to any microcontroller, we'll be using an Arduino. For another kind of microcontroller, just make sure it has I2C, then port the code - once the low level i2c functions are adapted the rest should 'fall into place'

adafruit_products_wiring.jpg

  • Connect Vin to the power supply, 3-5V is fine. Use the same voltage that the microcontroller logic is based off of. For most Arduinos, that is 5V
  • Connect GND to common power/data ground
  • Connect the SCL pin to the I2C clock SCL pin on your Arduino. On an UNO & '328 based Arduino, this is also known as A5, on a Mega it is also known as digital 21 and on a Leonardo/Micro, digital 3
  • Connect the SDA pin to the I2C data SDA pin on your Arduino. On an UNO & '328 based Arduino, this is also known as A4, on a Mega it is also known as digital 20 and on a Leonardo/Micro, digital 2
  • Connect the RST pin to digital 12 - you can change this later but we want to match the tutorial for now
The Si4713 has a default I2C address of 0x63 - you can change it to 0x11 by connecting CS to ground but don't do that yet! Get the demo working first before making changes

Download Adafruit_Si4713

To begin reading sensor data, you will need to download the Adafruit si4713 library from the Arduino library manager.

Open up the Arduino library manager:

Search for the Adafruit Si4713 library and install it

We also have a great tutorial on Arduino library installation at:
http://learn.adafruit.com/adafruit-all-about-arduino-libraries-install-use

Load Demo

Open up File->Examples->Adafruit_Si4713->adaradio and upload to your Arduino wired up to the sensor

You may want to update the FM station transmission. By default the library transmits on 102.3MHz FM, but that might be 'taken' in your area.

Find this line
#define FMSTATION 10230 // 10230 == 102.30 MHz
And change it to an unused frequency. This number is in 10KHz so for example 88.1MHz is written as 8810

Upload it to your Arduino and open up the Serial console at 9600 baud
As long as you get to the RDS On! message that means everything works, pipe some audio into the 3.5mm jack and make sure you see the InLevel audio volume range from 0 to about -10 (dB)

The fastest way to test the RDS message sending is using an RTL-SDR (that's how we debugged the breakout!) or a phone/radio that can do RDS decoding

Using the RPS Scanning function


The Si4713 has the ability 'scan' the FM band and measure the input power. You can use the RPS functionality to locate a good unused station. Find this section in the adaradio demo and uncomment the for loop:
  // Uncomment below to scan power of entire range from 87.5 to 108.0 MHz
/*
  for (uint16_t f  = 8750; f<10800; f+=10) {
   radio.readTuneMeasure(f);
   Serial.print("Measuring "); Serial.print(f); Serial.print("...");
   radio.readTuneStatus();
   Serial.println(radio.currNoiseLevel);
   }
*/
Reupload and look at the serial console:
The larger the number the higher the transmission power. For example, 96.3MHz is a higher number than the others (FYI, its Univision 96.3 FM!) whereas 95.1 MHz is nice as low, that's not used for any transmission. Try to find a number that's also not surrounded by high numbers, since it can get 'drowned out' by the nearby frequencies.

Library Reference


Radio Transmitter control

Start out by initializing the Si4713 chipset with
begin()
This will return true if the radio initialized, and false if the radio was not found. Check your wiring if its not 'showing up'

Then you can turn on the radio transmitter with
setTXpower(txpwr)
the txpwr number is the dBμV transmission power. You can set this to 88-115dBμV or 0 (for off)

Of course, you'll want to tune the transmitter! Do that with
tuneFM(freq)
That will set the output frequency, in 10's of KHz. So if you want to tune to 101.9 the frequency value is 10190

You can check in on the radio with
readTuneStatus()
Whcih will set the currFreq currdBuV adnd currAntCap variables in the radio object. The first two are the frequency and power output, the third variable is the tuning antenna capacitor it set for the best output. This number will vary with antenna size and frequency.

RPS (Radio Power Sensing)

This function is used with two procedures.
readTuneMeasure(freq)
begins the measurement, freq is in units of 10KHz so 88.1MHz is written in as 8810
Then you have to call
readTuneStatus()
which will wait until the chip has measured the data and stick it into the currNoiseLevel variable

RDS/RBDS (Radio Data Broadcast)

The Si4713 has great support for sending RDS data and we made it real easy too. Initialize the subsystem with
beginRDS()
Then you can set the "station name" with
setRDSstation("AdaRadio")
The radio station name is up to 8 characters
You can also send the main buffer which usually contains the song name/artist.
setRDSbuffer( "Adafruit g0th Radio!")
You can send up to 32 characters, but you can continuously send new data, just wait a few seconds before each data rewrite so the listener's radio has received all the data

GPIO Control

There's two GPIO pins you can use to blink LEDs. They are GPIO1 and GPIO2 - GPIO3 is used for the oscillator. To set them to be outputs call
setGPIOctrl(bitmask)
where the bitmask has a 1 bit for each of the two pins. For example to set GPIO2 to be an output use setGPIOctrl((1<<2)) to set both outputs, use setGPIOctrl((1<<2) || (1<<1))

Then you can set the output with
setGPIO(bitmask)
same idea with the bitmask, to turn both on, use setGPIOctrl((1<<2) || (1<<1)). To turn GPIO2 on and GPIO1 off, setGPIOctrl(1<<2)

Advanced!


We, by default, use the built-in AGC (auto-gain control) system so the audio level is maxed out. This may be annoying to you if have a good quality line level and the volume is fluctuating (it should be quiet, but isnt)

in the Adafruit_Si4713.cpp file find these lines
//setProperty(SI4713_PROP_TX_ACOMP_ENABLE, 0x02); // turn on limiter, but no dynamic ranging
setProperty(SI4713_PROP_TX_ACOMP_ENABLE, 0x0); // turn on limiter and AGC
and uncomment the first one, and comment the second. This will turn off the AGC

This guide was first published on Jun 26, 2014. It was last updated on Mar 27, 2024.

This page (Arduino Code) was last updated on Mar 08, 2024.

Text editor powered by tinymce.