I don’t know why but for some reason, the sensors on my devices that I used to be able to activate/deactivate through the web console and mobile app now doesn’t work:
Well, it is quite a straight forward setup and it connects to the internet without any problem.
#include <ThingerESP8266.h>
#include <ESP8266WiFi.h>
#define USERNAME "my_account_name"
#define DEVICE_ID "my_device_id"
#define DEVICE_CREDENTIAL "my_device_cred"
ThingerESP8266 thing(USERNAME, DEVICE_ID, DEVICE_CREDENTIAL);
void setup() {
/// ...
}
#define analogPin A0
int adcValue = 0; /* Variable to store Output of ADC */
void loop() {
thing.handle();
thing[EXTERNALLY_CONTROLLABLE_RESOURCE_ID] << [](pson& in){
if((bool)in)
// do stuff
};
adcValue = analogRead(analogPin); /* Read the Analog Input value */
//Serial.println(adcValue);
/* Print the output in the Serial Monitor */
if(adcValue >= 160 && adcValue <= 1025) {
// do stuff
}
}
I have a 5V relay connected to this controller/device (ESP8266) and I try to open it as you can see here:
thing[EXTERNALLY_CONTROLLABLE_RESOURCE_ID] << [](pson& in){
if((bool)in)
// do stuff
};
In general, I could open the relay by bypassing the whole workflow and directly go to thinger.io console/devices/API and then turn on and off my relay.
But the issue is that it doesn’t show me the relay at all.
SIDE NOTE: If I remove the code for analogue reading from pin A0, it seems to work and the relay is opening.
ANOTHER OBSERVATION: It seems like what causes the issue is this line in the loop:
adcValue = analogRead(analogPin); /* Read the Analog Input value */
How can I work around this? For some reason, this is blocking Thinger.io to understand what are my peripherals.
If you dont share your code it is so dificult for us to imagine what is it happening, so I can do nothing in this situation.
I have had no issues using ADC or other peripheral with those uC, I recognize that I use most the ESP32.
I understand that maybe your code could have intelectual property that you dont want to make public, in this case I recommend you to contact official technical support → Technical Support | Thinger.io
I think you solved your issue with the last snippet of code. It is actually not an issue with Thinger.io’s console.
Even though it should not be necessary to configure the pinMode for an analog pin, in some cases, setting the pin mode explicitly as INPUT can help ensure proper behavior, especially if the pin has been used previously as an OUTPUT. This is because the pin state can get “stuck” in a certain mode and need to be reset. Additionally, some code libraries or third-party hardware may change the pin mode and not reset it to the default, so explicitly setting the pin mode in your code can ensure the proper behavior in these cases.