Hello,
I have written a small piece of code to (for the moment) connect a DHT11 module to the Arduino IOT Cloud.
[ 11220][E][esp32-hal-adc.c:192] __analogRead(): GPIO0: ESP_ERR_TIMEOUT: ADC2 is in use by Wi-Fi. Please see https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-reference/peripherals/adc.html#adc-limitations for more info
I keep getting this error. I tried an empty code (just WiFi and Arduino Cloud connection (the basic sketch that Arduino provides)) and this error is still here. I tried using the Arduino IDE and with this one, I don’t get this error anymore.
main.cpp:
/*
Sketch generated by the Arduino IoT Cloud Thing "Untitled 2"
https://create.arduino.cc/cloud/things/5dc6e150-06bd-463d-802a-24e6ade1cc63
Arduino IoT Cloud Variables description
The following variables are automatically generated and updated when changes
are made to the Thing
int random_value;
bool led_switch;
Variables which are marked as READ/WRITE in the Cloud Thing will also have
functions which are called when their values are changed from the Dashboard.
These functions are generated with the Thing and added at the end of this
sketch.
*/
#include "devices.h"
#include "thing/thingProperties.h"
#include "thing/variables.h"
#include <Arduino.h>
#include <NexgenTimer.h>
#include <WiFi.h>
#define LED 2
bool led_switch;
NexgenTimer dht_timer = NexgenTimer();
void setup() {
/*
The following function allows you to obtain more information
related to the state of network and IoT Cloud connection and errors
the higher number the more granular information you’ll get.
The default is 0 (only errors).
Maximum is 4
*/
setDebugMessageLevel(2);
Serial.begin(9600);
// pinMode(LED, OUTPUT);
// Initialize serial and wait for port to open:
// This delay gives the chance to wait for a Serial Monitor without blocking
// if none is found
delay(1500);
// Defined in thingProperties.h
initProperties();
// Connect to Arduino IoT Cloud
ArduinoCloud.begin(ArduinoIoTPreferredConnection);
while (WiFi.status() != WL_CONNECTED) {
ArduinoCloud.update();
delay(1000);
Serial.println("Connecting to WiFi...");
}
ArduinoCloud.printDebugInfo();
setupDHT11_sensor();
dht_timer.expiredHandler(readDHT11_sensor);
dht_timer.setInterval(5000);
dht_timer.start();
}
void loop() {
ArduinoCloud.update();
if ((ArduinoCloud.connected() == 0)) {
Serial.println("Waiting for connection to Arduino Cloud ...");
} else {
dht_timer.run();
}
}
/*
Since LedSwitch is READ_WRITE variable, onLedSwitchChange() is
executed every time a new value is received from IoT Cloud.
*/
void onLedSwitchChange() {
// Add your code here to act upon LedSwitch change
if (led_switch) {
digitalWrite(LED, HIGH);
} else {
digitalWrite(LED, LOW);
}
}
devices.cpp:
#include "devices.h"
#include "thing/variables.h"
DHT_Unified dht(DHTPIN, DHTTYPE);
CloudTemperatureSensor temperature;
CloudRelativeHumidity humidity;
void setupDHT11_sensor() {
sensor_t sensor;
dht.begin();
dht.temperature().getSensor(&sensor);
dht.humidity().getSensor(&sensor);
}
void readDHT11_sensor(NexgenTimer &nt) {
Serial.println("[INFO] readDHT11_sensor() called.");
sensors_event_t event;
dht.temperature().getEvent(&event);
temperature = event.temperature; // Read temperature as Celsius
dht.humidity().getEvent(&event);
humidity = event.relative_humidity; // Read Humidity
// Check if any reads failed and exit early (to try again).
if (isnan(humidity) || isnan(temperature)) {
Serial.println("Failed to read from DHT sensor!");
return;
}
}
Or, here is the link to see the code on Arduino IDE : Arduino Cloud
Do you have any idea how I can stop having this error?
Thank you for your help!