Hello all, I am making an FM transmitter for my car using an Arduino micro, Si4713 and Nokia 5110 display. I have the display and the transmitter talking to each other just fine. The only thing left to do is to have the Arduino pick the best station to use on its own. The Adafruit library for the Si4713 includes a way to have the transmitter scan every station and assign it a noise level. I am not sure how to pick the lowest noise level and its corresponding station.
You could use the Adafruit code as a starting point.
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);
}
Declare a couple of variables to record the lowest noise level you find and the frequency it was on.
uint16_t lowestNoiseFrequency = 8750;
uint8_t lowestNoiseLevel = 255; // start with the highest possible noise level
Then change the loop code to compare the noise level on the current frequency with the lowest noise level found so far. (I've dropped the print statements).
for (uint16_t f = 8750; f < 10800; f += 10) {
radio.readTuneMeasure(f);
radio.readTuneStatus();
uint16_t noiseLevel = radio.currNoiseLevel;
if (noiseLevel < lowestNoiseLevel)
{
lowestNoiseLevel = noiseLevel;
lowestNoiseFrequency = f;
}
}
After the loop, you can use lowestNoiseFrequency to tune the radio.
This approach does not address this comment on the Adafruit website:
Try to find a number that's also not surrounded by high numbers, since it can get 'drowned out' by the nearby frequencies.