I’m trying to bring a simple use case into the Thinger.io, but the below code crashes the esp8266 dev boards (I’ve confirmed both with NodeMCU and WeMos boards, similar crash).
There’s nothing special about the setup, the vanilla one connected to a mac’s usb. Using the latest Arduino client libs from the github.
Can’t seem to enable the Thinger.io debug output either, it simply doesn’t get to a point where it can run. Anything I’m missing?
//#include <SPI.h>
#include <ESP8266WiFi.h>
#include <Arduino.h>
#include <ESP.h>
#include <ThingerSmartConfig.h>
#define _DEBUG_
// TODO extract into an external config
#define USERNAME "andrew"
#define DEVICE_ID "some_device_id"
#define DEVICE_CREDENTIAL "xxxxx"
#define INTERVAL_MS 10000
#define SENSOR_PIN A0 // analog pin
#define VAL_LOW_LIMIT 446 // based on sensor calibration results
#define VAL_HIGH_LIMIT 830 // based on sensor calibration results
ThingerSmartConfig thing(USERNAME, DEVICE_ID, DEVICE_CREDENTIAL);
void setup() {
Serial.begin(115200);
pinMode(SENSOR_PIN, INPUT);
thing["soil"] >> [] (pson& out) {
int value = analogRead(SENSOR_PIN);
int conValue = constrain(value, VAL_LOW_LIMIT, VAL_HIGH_LIMIT);
int mapped = map(conValue, VAL_LOW_LIMIT, VAL_HIGH_LIMIT, 100, 0);
Serial.print("Reading raw: ");
Serial.println(value);
Serial.print("Reading: ");
Serial.println(mapped);
out = mapped;
};
}
void loop() {
thing.handle();
// ESP.deepSleep(INTERVAL_MS * 1000);
}
Thanks for the tip, Alvaro! Once I moved the _DEBUG_ definition to the top, I got the output, and, surprisingly, everything went through to connect both to WiFi and the service. Go figure, but I’m glad we have a simple solution. Maybe worth mentioning it in the docs for others?
Hmm, sorry to revive it. I took a clean board (which didn’t have old WiFi info saved). It does look like Thinger’s SmartConfig code needs to ESP.wdtFeed()
Take a look at the output below. The reset cause 2 is a watchdog timer reset. Might take a look at the Thinger library code later, but for now wanted to flag this. The reason it worked above was only due to me doing a regular wifi sketch, then SmartConfig (it reused saved WiFi credentials). Doesn’t work on a clean board.
Well, I think I have some good news for this. I have been working to disable the blinking led for SmartConfig. Now you can pass another parameter to false to disable the BUILTIN_LED. Like this:
I have been testing also the SmartConfig method under different cases, like the device does not have a WiFi connection established yet (thanks for the Wifi.disconnect() tip!! ), or the SmartConfig configuration is bad, and so on. Now all seems to be working like a charm!. Also I have improved the debug information for the SmartConfig.
You can try the fix replacing ThingerSmartConfig.h header, meanwhile I upload it as a new version for the Arduino Library Manager:
Will work now on the disconnect method, and will test the sleep feature to see how it affects to the client library.