When programming the DOIT ESP32 DEVKIT V3 board in the Arduino Web Editor for IoT application there is a problem. I declare an integer variable whose value depends on the variation of an analogue input. I link this variable to a thing and a dashboard. The purpose is to display in a gauge widget the value of the analog input. However, when manually modifying the analogue input on the ESP32 board, the variable does not change, it remains at zero.
What could be happening?
Why are the changes not displayed on either the serial monitor or the gauge widget?
When programming the DOIT ESP32 DEVKIT V3 board directly with the Arduino Web Editor without network functions, the change in the variable is recorded normally when displayed on the serial monitor.
It seems to be a bug in the editor.
show sketch plz
Sorry, here's the information.
#include "thingProperties.h"
const int pinLec = 4;
void setup() {
Serial.begin(9600);
delay(1500);
initProperties();
ArduinoCloud.begin(ArduinoIoTPreferredConnection);
setDebugMessageLevel(2);
ArduinoCloud.printDebugInfo();
}
void loop() {
ArduinoCloud.update();
valor = analogRead(pinLec);
Serial.print("Valor = ");
Serial.println(valor);
}
'valor' is a variable of type integer previously declared on "Create thing" stage. Variable permission: Read Only, Send Values: Every 1s.
Here's the "thingProperties.h" file:
#include <ArduinoIoTCloud.h>
#include <Arduino_ConnectionHandler.h>
const char DEVICE_LOGIN_NAME[] = "9a833531-9d7b-4175-9f05-d1bd10161fe1";
const char SSID[] = SECRET_SSID; // Network SSID (name)
const char PASS[] = SECRET_PASS; // Network password (use for WPA, or use as key for WEP)
const char DEVICE_KEY[] = SECRET_DEVICE_KEY; // Secret device password
int valor;
void initProperties(){
ArduinoCloud.setBoardId(DEVICE_LOGIN_NAME);
ArduinoCloud.setSecretDeviceKey(DEVICE_KEY);
ArduinoCloud.addProperty(valor, READ, 1 * SECONDS, NULL);
}
WiFiConnectionHandler ArduinoIoTPreferredConnection(SSID, PASS);
When doing something like web interfacing and you have a problem, drop back to a simple sketch to ensure your hardware is performing correctly. With known good hardware, everything else is software.
I found the answer and the solution to the problem,
When using libraries to connect the ESP32 board to the Internet the pins associated with ADC2 are disabled for other applications.
The solution is to use a GPIO terminal associated with ADC1 to connect the analogue inputs (See the ESP32 pinout).
Thank you for your contribution,
Indeed, in the link you quote is the solution but I found it before in another source.
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.