Hello all,
This is my second library question in a very short time span, but I was using Adafruit IO, and I needed to use the libraries. However, no matter how hard I try, there is always a does not name a type
error for AdafruitIO_Wifi
. And indeed, I cannot find where it is! It was not in AdafruitIO.h
, where it presumably should be, and there is no cpp file to match AdafruitIO_Wifi.h
. Where did it go?? As a result of this, I have 4 more errors. Please help! I will put my code below:
#include <Arduino.h>
#include <Arduino_MKRENV.h>
#include "AdafruitIO_WiFi.h"
#include "AdafruitIO.h"
#include <Adafruit_Sensor.h>
#define IO_USERNAME " "
#define IO_KEY " "
#define WIFI_SSID " "
#define WIFI_PASS " "
#if defined(USE_AIRLIFT) || defined(ADAFRUIT_METRO_M4_AIRLIFT_LITE) || \
defined(ADAFRUIT_PYPORTAL)
// Configure the pins used for the ESP32 connection
#if !defined(SPIWIFI_SS) // if the wifi definition isnt in the board variant
// Don't change the names of these #define's! they match the variant ones
#define SPIWIFI SPI
#define SPIWIFI_SS 10 // Chip select pin
#define NINA_ACK 9 // a.k.a BUSY or READY pin
#define NINA_RESETN 6 // Reset pin
#define NINA_GPIO0 -1 // Not connected
#endif
AdafruitIO_WiFi io(IO_USERNAME, IO_KEY, WIFI_SSID, WIFI_PASS, SPIWIFI_SS,
NINA_ACK, NINA_RESETN, NINA_GPIO0, &SPIWIFI);
#else
AdafruitIO_WiFi io(IO_USERNAME, IO_KEY, WIFI_SSID, WIFI_PASS);
#endif
const char SSID[] = "NETGEAR10";
const char PASS[] = "basicearth863";
int airPressure;
int humidity;
int light;
int uVIndex;
int temperature;
AdafruitIO_Feed *temperaturefeed = io.feed("temperaturefeed");
AdafruitIO_Feed *humidityfeed = io.feed("humidityfeed");
void setup()
{
Serial.begin(9600);
delay(1500);
if (!ENV.begin())
{
Serial.println("Failed to initialize MKR ENV shield!");
while (1)
;
pinMode(LED_BUILTIN, OUTPUT);
}
Serial.print("Connecting to Adafruit IO");
io.connect();
while (io.status() < AIO_CONNECTED)
{
Serial.print(".");
delay(500);
}
// we are connected
Serial.println();
Serial.println(io.statusText());
}
void loop()
{
io.run();
temperature = ENV.readTemperature(FAHRENHEIT);
temperaturefeed->save(temperature);
humidity = ENV.readHumidity();
humidityfeed->save(humidity);
airPressure = ENV.readPressure(PSI);
light = ENV.readIlluminance(LUX);
uVIndex = ENV.readUVIndex();
Serial.print("Temperature: ");
Serial.println(temperature);
Serial.print("Humidity: ");
Serial.println(humidity);
Serial.print("Air pressure: ");
Serial.println(airPressure);
Serial.print("Light: ");
Serial.println(light);
Serial.print("UV: ");
Serial.println(uVIndex);
Serial.println(' ');
digitalWrite(LED_BUILTIN, LOW);
delay(250);
digitalWrite(LED_BUILTIN, HIGH);
delay(250);
}
Thanks in advance for any help!
Also, I left the 4 fields for the username, password, and WiFi creds blank in the code I posted for privacy, but in the real code, it is filled in.