HELP PLEASE: avrdude: WARNING: invalid value for unused bits in fuse "fuse5"

Hi, I am using a Arduino UNO WIFI to make a weather station and I am currently unable to get it to work.

I get this error/ warning
avrdude: WARNING: invalid value for unused bits in fuse "fuse5", should be set to 1 according to datasheet

Below is my code. I have blanked out passwords to WiFi and Thingspeak but have checked them multiple times


#include <SPI.h>
#include <WiFiNINA.h>
#include <ThingSpeak.h>
#include <LiquidCrystal.h>

// wifi details
char ssid[] = "********";
const char password[] = "********";
int status = WL_IDLE_STATUS; 

// ThingSpeak details
const unsigned long channel_id = ********;
const char write_api_key[] = "********";
WiFiClient client;

// LCD screen set up
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

byte degree_symbol[8] =
  {
    0b00111,
    0b00101,
    0b00111,
    0b00000,
    0b00000,
    0b00000,
    0b00000,
    0b00000
  };

int gate=11;
volatile unsigned long duration=0;
unsigned char i[5];
unsigned int j[40];
unsigned char value=0;
unsigned answer=0;
int z=0;
int b=1;

void setup() 
{
  // connecting to wifi and ThingSpeak
  Serial.begin(9600);
  delay(100);
  Serial.print("Connecting to ");
  Serial.print(ssid);
  WiFi.begin(ssid, password);
  while ( WiFi.status() != WL_CONNECTED ) 
  {
    delay(500);
    Serial.print(".");
  }
  Serial.println();
  Serial.println("Connected!");
  ThingSpeak.begin(client);

  // initialize screen
  lcd.begin(16, 2);
  lcd.print("Temp = ");
  lcd.setCursor(0,1);
  lcd.print("Humidity = ");
  lcd.createChar(1, degree_symbol);
  lcd. setCursor(9,0);
  lcd.write(1);
  lcd.print("C");
  lcd.setCursor(13,1);
  lcd.print("%");
} 

void loop() 
{
  delay(1000);

  while(1)
  {
    delay(1000);
    pinMode(gate,OUTPUT);
    digitalWrite(gate,LOW);
    delay(20);
    digitalWrite(gate,HIGH);
    pinMode(gate,INPUT_PULLUP);

    duration=pulseIn(gate, LOW);
    if(duration <= 84 && duration >= 72)
    {
      while(1)
      {
        duration=pulseIn(gate, HIGH);
        if(duration <= 26 && duration >= 20)
        {
          value=0;
        }
        else if(duration <= 74 && duration >= 65)
        {
          value=1;
        }
        else if(z==40)
        {
          break;
        }
        i[z/8]|=value<<(7- (z%8));
        j[z]=value;
        z++;      
      }
    }

    answer=i[0]+i[1]+i[2]+i[3];

    if(answer==i[4] && answer!=0)
    {
      lcd.setCursor(7,0);
      lcd.print(i[2]);
      lcd.setCursor(11,1);
      lcd.print(i[0]);

      Serial.println("Temp = ");
      Serial.print(i[2]);
      Serial.println("Humidity = ");
      Serial.print(i[0]);

      ThingSpeak.setField(1, i[2]);
      ThingSpeak.setField(2, i[0]);
      ThingSpeak.writeFields(channel_id, write_api_key);
    }
  
    z=0;
    i[0]=i[1]=i[2]=i[3]=i[4]=0;

  }
}

Any helps much appreciated

Please follow the advice given in the link below when posting code, in particular the section entitled 'Posting code and common code problems'

Use code tags (the </> icon above the compose window) to make it easier to read and copy for examination

Hi

I have done this now. thanks for telling me

Thank you for adding the code tags

I actually doubt that the problem is anything to do with your sketch, but as you can probably see, using the code tags makes it easier to see and copy for examination should it be necessary

Can you upload a simple sketch such as Blink to your Arduino ?

I have tried using the blink program for the Arduino tutorial and I have no result using mine on the Arduino Uno WIFI rev 2.

I was trying to use digital pin 13 like it suggested

Can you upload the Blink program with no errors even if it does not blink the LED after the upload ?

What I am trying to establish is whether you have a problem with uploading code or running code

From your original post

You are getting a warning that is probably unrelated to the code

Did you get the warning about the fuse setting when uploading the blink sketch? Use LED_BUILTIN instead of 13 for the pin number, the led is on a different pin on that board.

From what I can find, that fuse5 warning is normal and can be ignored.

There is a vast difference between an Arduino UNO WiFi and an Arduino UNO WiFi Rev 2. The rev 2 uses an atmega4809, and there are a lot of libraries that are incompatible with that processor.

yes I did get the same fuse warning



// the setup function runs once when you press reset or power the board
void setup() {
  // initialize digital pin LED_BUILTIN as an output.
  pinMode(LED_BUILTIN, OUTPUT);
}

// the loop function runs over and over again forever
void loop() {
  digitalWrite(LED_BUILTIN, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(1000);                       // wait for a second
  digitalWrite(LED_BUILTIN, LOW);    // turn the LED off by making the voltage LOW
  delay(1000);                       // wait for a second
}

This is the code I used. It works perfect on my normal arduino uno but that wont work for my initial program

Please provide a detailed description of what you mean by "wont work".

Does the LED marked "L" on the Uno WiFi Rev2 blink after you upload that sketch to it?

Unfortunately the megaavr architecture generates tons of compiler warnings, mostly related to the WiFi and Ethernet libs and of course the “fuse5” thing. Upon inspection, the warnings are generated from use of untyped macros that don’t expand properly, improperly typed values, duplicate definitions and other issues all related to the poor programming practices of the developers.

The gcc compiler bundled with the Arduino IDE is fully ISO C++ compliant, yet most of the API looks like it was written by a fifth-grader. That’s what happens when you use macros and ints for everything or change type declarations Willy-Nilly.

That’s just my opinion, I could be wrong, but I doubt it.

Cheers!

Really? I tried the sketch here, and the only warning generated by the compile was the one about register emulation, and that's quite intentional.

Also, the OP's reported problem (the FUSE issue) has nothing to do with the compiler, and more to do with avrdude and the platform/boards definitions.

OTOH, I think that's pretty much a red herring - the FUSE warning is just a warning, and shouldn't interfere with actual operation. Unfortunately, they seem to have ghosted before resolving their issues.
Obviously, most people are able to get Blink working on an Uno WiFi 2, in spite of avrdude warnings and core code deficiencies.

Hi,

Here’s a pic of the output window when compiling anything that uses the WiFiNINA or megaavr Ethernet libs - and that’s just what fits on one screen! It’s full of duplicate definitions, overflows, bad type conversions and more. The type of stuff that no professional developer would ever let out the door. But then again ….

I’ve spoken to several maintainers of the avr libs on Git and they’ve all kind of had it up to here with all the warnings, the redefinition of data types with no documentation or even a heads-up from Arduino.

I’m a few decades past writing “Blink” sketches, so maybe you can understand our frustration. Lab Automation

Hopefully there will be fixes soon.

Pictures of error messages? Really? Sigh.

But that looks like you've included both WiFi and Ethernet libraries in the same sketch. While I guess that that should theoretically be possible, I'm not at all surprised that it doesn't work right.

And why exactly would that not be possible? My comms objects need to support both. Who writes libs that aren’t interoperable? I expect things to work, or documentation clearly stating otherwise.

I’m done here. Have a nice day!

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