I'm using an Arduino r4 uno wifi board along with the MQ-135 gas sensor and DHT-11 sensor. I'm trying to transmit the data collected on the sensors into a channel on ThingSpeak whilst simultaneously projecting the data on an oled display. The code for displaying the data on the oled works fine separately, but freezes up when paired with the code for ThingSpeak. The code for transmitting the data to the channel of ThingSpeak isn't working at all.
This is the code:
#include <WiFiNINA.h>
#include <ThingSpeak.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#include <DHT.h>
#define DHTPIN 13
#define DHTTYPE DHT11
#define smokeGaz A0
#define SCREEN_WIDTH 128
#define SCREEN_HEIGHT 64
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT);
DHT dht(DHTPIN, DHTTYPE);
char ssid[] = "Coco";
char pass[] = "852%tofuti";
unsigned long channelID = 2583477;
const char* writeAPIKey = "NFJAJ95W65IQ3OMB";
WiFiClient client;
void setup() {
dht.begin();
display.begin(SSD1306_SWITCHCAPVCC, 0x3C);
ThingSpeak.begin(client);
delay(2000);
display.clearDisplay();
display.setTextColor(SSD1306_WHITE);
Serial.begin(9600);
}
void loop() {
int sg = analogRead(smokeGaz);
float t = dht.readTemperature();
float h = dht.readHumidity();
display.clearDisplay();
display.setTextSize(.4);
display.setCursor(60, 7);
display.print("Smoke & Gas");
display.setTextSize(1);
display.setCursor(66, 16);
display.print(sg);
display.print(" ");
display.setTextSize(1);
display.print("DN");
display.setCursor(0, 37);
display.print("Temp: ");
display.print(t);
display.print((char)247);
display.print("C");
display.setCursor(0, 47);
display.print("Humidity: ");
display.print(h);
display.print(" %");
display.display();
// Send data to ThingSpeak
ThingSpeak.setField(1, h); // Humidity
ThingSpeak.setField(2, t); // Temperature
ThingSpeak.setField(3, sg); // Smoke & Gas
int httpCode = ThingSpeak.writeFields(channelID, writeAPIKey);
delay(10000); // Wait for 10 seconds before sending data again
}
This is the error message:
WARNING: library ThingSpeak claims to run on avr, esp8266, sam, samd, esp32, samd_beta, megaavr architecture(s) and may be incompatible with your current board which runs on renesas_uno architecture(s).
/Users/cylvia/Documents/Arduino/libraries/WiFiNINA/src/utility/spi_drv.cpp: In static member function 'static void SpiDrv::begin()':
/Users/cylvia/Documents/Arduino/libraries/WiFiNINA/src/utility/spi_drv.cpp:103:15: error: 'NINA_GPIO0' was not declared in this scope
pinMode(NINA_GPIO0, OUTPUT);
^~~~~~~~~~
/Users/cylvia/Documents/Arduino/libraries/WiFiNINA/src/utility/spi_drv.cpp:103:15: note: suggested alternative: 'NINA_GPIOIRQ'
pinMode(NINA_GPIO0, OUTPUT);
^~~~~~~~~~
NINA_GPIOIRQ
/Users/cylvia/Documents/Arduino/libraries/WiFiNINA/src/utility/spi_drv.cpp: In static member function 'static int SpiDrv::available()':
/Users/cylvia/Documents/Arduino/libraries/WiFiNINA/src/utility/spi_drv.cpp:66:25: error: 'NINA_GPIO0' was not declared in this scope
#define NINA_GPIOIRQ NINA_GPIO0
^
/Users/cylvia/Documents/Arduino/libraries/WiFiNINA/src/utility/spi_drv.cpp:597:25: note: in expansion of macro 'NINA_GPIOIRQ'
return (digitalRead(NINA_GPIOIRQ) != LOW);
^~~~~~~~~~~~
/Users/cylvia/Documents/Arduino/libraries/WiFiNINA/src/utility/spi_drv.cpp:66:25: note: suggested alternative: 'NINA_GPIOIRQ'
#define NINA_GPIOIRQ NINA_GPIO0
^
/Users/cylvia/Documents/Arduino/libraries/WiFiNINA/src/utility/spi_drv.cpp:597:25: note: in expansion of macro 'NINA_GPIOIRQ'
return (digitalRead(NINA_GPIOIRQ) != LOW);
^~~~~~~~~~~~
exit status 1
Compilation error: exit status 1