Fatal error: avr/io.h: No such file or directory

Hello,

I’m new to both Sparkfun and Arduino, be gentle with me :slight_smile:

So I’m trying to set up the Soil Moisture sensor with Sparkfun ESP32-C3 Micro Pro board, following this guide:

As the title says, I run into this error and simply can’t figure the cause.
Well, I’m missing a library, obviously.

I’ve read somewhere else that it might be avr-libc, but that doesn’t seem to be in the Library Manager (Arduino IDE 2.3.6).

The sketch I’m trying to compile is here:

/******************************************************************************
  Zio Qwiic Soil Moisture Sensor Example 1 - Basic Reading
  Harry
  September 25, 2018

  Default address is 0x28.

******************************************************************************/
#include "SparkFun_Soil_Moisture_Sensor.h" 

#define COMMAND_LED_OFF     0x00
#define COMMAND_LED_ON      0x01
#define COMMAND_GET_VALUE        0x05
#define COMMAND_NOTHING_NEW   0x99

const byte qwiicAddress = 0x28;     //Default Address
uint16_t ADC_VALUE=0;
void setup() {
  Serial.begin(9600);
  Serial.println("Zio Qwiic Soil Moisture Sensor Master Awake");

  Wire.begin();
  testForConnectivity();
  ledOn();
  delay(1000);
}

void loop() {
  get_value();
  ledOn();
  delay(1000);
  ledOff();
  delay(1000);
}

// LED is off, and a -1 if an error occurred.
void get_value() {
  Wire.beginTransmission(qwiicAddress);
  Wire.write(COMMAND_GET_VALUE); // command for status
  Wire.endTransmission();    // stop transmitting //this looks like it was essential.

  Wire.requestFrom(qwiicAddress, 2);    // request 1 bytes from slave device qwiicAddress

  while (Wire.available()) { // slave may send less than requested
  uint8_t ADC_VALUE_L = Wire.read(); 
//  Serial.print("ADC_VALUE_L:  ");
//  Serial.println(ADC_VALUE_L,DEC);
  uint8_t ADC_VALUE_H = Wire.read();
//  Serial.print("ADC_VALUE_H:  ");
//  Serial.println(ADC_VALUE_H,DEC);
  ADC_VALUE=ADC_VALUE_H;
  ADC_VALUE<<=8;
  ADC_VALUE|=ADC_VALUE_L;
  Serial.print("ADC_VALUE:  ");
  Serial.println(ADC_VALUE,DEC);
  }
  uint16_t x=Wire.read(); 
}

void ledOn() {
  Wire.beginTransmission(qwiicAddress);
  Wire.write(COMMAND_LED_ON);
  Wire.endTransmission();
}

void ledOff() {
  Wire.beginTransmission(qwiicAddress);
  Wire.write(COMMAND_LED_OFF);
  Wire.endTransmission();
}


// testForConnectivity() checks for an ACK from an Sensor. If no ACK
// program freezes and notifies user.
void testForConnectivity() {
  Wire.beginTransmission(qwiicAddress);
  //check here for an ACK from the slave, if no ACK don't allow change?
  if (Wire.endTransmission() != 0) {
    Serial.println("Check connections. No slave attached.");
    while (1);
  }
}

The only thing I can really think of, is that I’m running this Sketch from my downloads folder. I tried moving it to some proper Arduino folder, but the install isn’t where the documentation says it should be - and where it actually is installed, it doesn’t have the suggested folder structure :-/

I’m on a mac, btw.

Any and all suggestions would be very welcome. Thanks :slight_smile:

Where is this code from? That sensor doesn’t use a library, it interfaces directly using Wire (you don’t need the "#include “SparkFun_Soil_Moisture_Sensor.h” "

Try running the code here Zio-Qwiic-Soil-Moisture-Sensor/Firmware/Qwiic Soil Moisture Sensor Examples/Example1-Basic_Reading/Example1-Basic_Reading.ino at master · sparkfun/Zio-Qwiic-Soil-Moisture-Sensor · GitHub or trying the guide Soil Moisture Sensor Hookup Guide - SparkFun Learn