Radio Scanning works on Uno, but not Nano Every

Forgive me for obvious omissions, this is my first forum post but I'll do my best. Right now I'm following Bill Chappel's guide on building a basic "spirit box" radio scanner, using (originally) an Uno, a TEA5767 radio module, and a microphone module to listen for questions before starting a radio scan.

#include <TEA5767.h>
#include <radio.h>
#include <Wire.h>

/*

*/
TEA5767 radio;        // define radio model

int LED1 = 13;        // create a name for led1

int hold = 20;        // hold is the delay time
int inc = 10;         // how far to move when tunning
int start_FM = 8790;  // US FM band start **87.7 excluded
int stop_FM = 10790;   // US FM band stop
int breadboard = 12;  // power pin to breadboard
int mic = 11;         // microphone signal
int AntIn = 0;        // antenna energy value 1 count = 1.1 / 1024 = 0.0010V

void setup() {
  pinMode(LED1, OUTPUT);    // on board led
  pinMode(breadboard, OUTPUT); // define breadboard power
  Wire.begin();                // start IC2 communication
  digitalWrite(breadboard, HIGH); // power ON breadboard
  radio.init();                // start radio
  radio.setMute(1);            // mute ON radio sound off
  delay(100);                  // give breadboard chance to power on
}

void loop() {
  delay (10); // allow analog time to settle
  AntIn = analogRead(A0);  // read energy on antenna
  radio.setMute(1);  // radio mute ON
  int a = digitalRead(mic);  // read mic to a

  // to talk or not to talk
  if ((AntIn > 340) or (a == 0)) { // if AntIn is greater than 340 or a = 1 mic on then scan
    while (a == 0) {  // while mic = 1 wait here
      delay(5);  //delay 5 ms
      a = digitalRead(mic);  // read mic to a
    }
    delay(500);  // wait 1.5 seconds before responding
    radio.setMute(0);  // un-mute radio and allow it to scan
    // for loop and scanning from start-FM to stop-FM stepping by inc value (In MHz)
    for (int r = start_FM; r <= stop_FM; r = r + inc) {
      digitalWrite(LED1, HIGH);  // led ON
      radio.setFrequency(r);  // set radio to new frequency
      delay(hold/2);  // wait here for 1/2 hold time
      digitalWrite(LED1, LOW);  // led OFF
      delay(hold/2);  // wait here again
    }

    // for loop to scan backwards from stop_FM to start_FM with same stepping
    for (int r = stop_FM-inc; r >= start_FM+inc; r = r - inc) {  // +/- inc to prevent repeat stations
      digitalWrite(LED1, HIGH);  // led ON
      radio.setFrequency(r);  // change station
      delay(hold/2);
      digitalWrite(LED1, LOW);
      delay(hold/2);
    }
  }
}

It works without issue on the Uno, but when trying to minimize the physical size and build up a strip board version of the circuit to run from a Nano Every instead, I'm getting an error that logs as "Multiple libraries found for wire.h" in the Web/Cloud IDE, and just as a "compilation error: exit status 1" in the program IDE. The verbose error log keeps mentioning issues with an "SI4703.h" in the Radio library. I'll add it here since it's not too long of an error log:

In file included from c:\users\nathan\appdata\local\arduino15\packages\arduino\tools\avr-gcc\7.3.0-atmel3.6.1-arduino5\avr\include\avr\io.h:99:0,
                 from c:\users\nathan\appdata\local\arduino15\packages\arduino\tools\avr-gcc\7.3.0-atmel3.6.1-arduino5\avr\include\avr\pgmspace.h:90,
                 from C:\Users\Nathan\AppData\Local\Arduino15\packages\arduino\hardware\megaavr\1.8.8\cores\arduino/api/String.h:31,
                 from C:\Users\Nathan\AppData\Local\Arduino15\packages\arduino\hardware\megaavr\1.8.8\cores\arduino/api/IPAddress.h:24,
                 from C:\Users\Nathan\AppData\Local\Arduino15\packages\arduino\hardware\megaavr\1.8.8\cores\arduino/api/ArduinoAPI.h:30,
                 from C:\Users\Nathan\AppData\Local\Arduino15\packages\arduino\hardware\megaavr\1.8.8\cores\arduino/Arduino.h:23,
                 from C:\Users\Nathan\OneDrive\Documents\Arduino\libraries\Radio\src\SI4703.cpp:17:
C:\Users\Nathan\OneDrive\Documents\Arduino\libraries\Radio\src/SI4703.h:32:22: error: expected unqualified-id before 'volatile'
 static const uint8_t GPIO1 = 0;  // GPIO1
                      ^
C:\Users\Nathan\OneDrive\Documents\Arduino\libraries\Radio\src/SI4703.h:32:22: error: expected ')' before 'volatile'
C:\Users\Nathan\OneDrive\Documents\Arduino\libraries\Radio\src/SI4703.h:32:22: error: expected ')' before 'volatile'
C:\Users\Nathan\OneDrive\Documents\Arduino\libraries\Radio\src/SI4703.h:33:22: error: expected unqualified-id before 'volatile'
 static const uint8_t GPIO2 = 2;  // GPIO2
                      ^
C:\Users\Nathan\OneDrive\Documents\Arduino\libraries\Radio\src/SI4703.h:33:22: error: expected ')' before 'volatile'
C:\Users\Nathan\OneDrive\Documents\Arduino\libraries\Radio\src/SI4703.h:33:22: error: expected ')' before 'volatile'
C:\Users\Nathan\OneDrive\Documents\Arduino\libraries\Radio\src/SI4703.h:34:22: error: expected unqualified-id before 'volatile'
 static const uint8_t GPIO3 = 4;  // GPIO3
                      ^
C:\Users\Nathan\OneDrive\Documents\Arduino\libraries\Radio\src/SI4703.h:34:22: error: expected ')' before 'volatile'
C:\Users\Nathan\OneDrive\Documents\Arduino\libraries\Radio\src/SI4703.h:34:22: error: expected ')' before 'volatile'
C:\Users\Nathan\OneDrive\Documents\Arduino\libraries\Radio\src\SI4703.cpp: In member function 'void SI4703::writeGPIO(int, int)':
C:\Users\Nathan\OneDrive\Documents\Arduino\libraries\Radio\src\SI4703.cpp:447:10: error: expression '*(volatile uint8_t*)29' has side-effects
     case GPIO1:
          ^
C:\Users\Nathan\OneDrive\Documents\Arduino\libraries\Radio\src\SI4703.cpp:447:10: error: 'reinterpret_cast<volatile uint8_t* {aka volatile unsigned char*}>(29)' is not a constant expression
     case GPIO1:
          ^
C:\Users\Nathan\OneDrive\Documents\Arduino\libraries\Radio\src\SI4703.cpp:451:10: error: expression '*(volatile uint8_t*)30' has side-effects
     case GPIO2:
          ^
C:\Users\Nathan\OneDrive\Documents\Arduino\libraries\Radio\src\SI4703.cpp:451:10: error: 'reinterpret_cast<volatile uint8_t* {aka volatile unsigned char*}>(30)' is not a constant expression
     case GPIO2:
          ^
C:\Users\Nathan\OneDrive\Documents\Arduino\libraries\Radio\src\SI4703.cpp:455:10: error: expression '*(volatile uint8_t*)31' has side-effects
     case GPIO3:
          ^
C:\Users\Nathan\OneDrive\Documents\Arduino\libraries\Radio\src\SI4703.cpp:455:10: error: 'reinterpret_cast<volatile uint8_t* {aka volatile unsigned char*}>(31)' is not a constant expression
     case GPIO3:
          ^

exit status 1

Compilation error: exit status 1

I've tried looking up every way I can think of to search for to find any similar issues, but none of them are close enough and the solutions I've tried anyway don't work.

It looks like that library may not be compatible with Nano Every. If there is a GitHub repository for the library, you could check to see if this problem has already been raised as an issue against the library. Maybe a workaround is suggested there.

If you can switch to a classic Nano V3 instead of the Every, that might be easier, because it is much more similar to an Uno (assuming you meant Uno R3). Does your code compile if you select Nano V3?

I only have the Uno (not sure what version, bought it 5+ years ago at this point), and the Nano Every that I purchased very recently. I'll check any repository for any suggested workarounds.

But yes, switching to "Arduino Nano" instead of "Arduino Nano Every" fixes the issue. That's a little annoying but I'll see what workarounds there might be out there. Thanks!

It appears that GPIO0, GPIO1, and GPIO2 are already defined in the board package for the Nano Every. Changing the names of those constants in the SI4703.h and SI4703.cpp files within the library will allow the code to compile.

You will still see a few errors related to this:

/home/user/Arduino/libraries/Radio/src/SI47xx.cpp: In member function 'ASQ_STATUS SI47xx::getASQ()':
/home/user/Arduino/libraries/Radio/src/SI47xx.cpp:724:54: warning: ISO C++ says that these are ambiguous, even though the worst conversion for the first is better than the worst conversion for the second:
   _i2cPort->requestFrom((uint8_t)_i2caddr, (uint8_t)5);
                                                      ^

But that generally does not cause a problem because the two overloads of requestFrom() both feed into a single function. The only difference in the overloads is that one expects an uint8_t and size_t as arguments, and the other two int arguments, and the compiler cannot decide which is better when called with two uint8_t.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.