#include <SPI.h>
#include <ESP8266WiFi.h>
#include <ThingerWifi.h>
#define USERNAME "IronhideRobotics"
#define DEVICE_ID "esp8266"
#define DEVICE_CREDENTIAL "0123456789"
#define SSID "IronhideRobotics"
#define SSID_PASSWORD "0123456789"
ThingerWifi thing(USERNAME, DEVICE_ID, DEVICE_CREDENTIAL);
void setup() {
thing.add_wifi("SSID", "SSID_PASSWORD");
}
void loop() {
thing.handle();
}
Hello @IronhideRobotics,
Everything appears well in your code, but to make sure about the connection problem, include a serial port and write this in the top of your sketch:
#define _DEBUG_
Then you should be able to watch in the Serial monitor the network trace, similar to this one:
If there is any problem in the WiFi ssid, key or in the device credentials it will appear there.
Then, it is important to say that the “devices” interface do not actualize the status automatically, you have to refresh the web or enter in the “device dashboard” to see if it is actually connected.
hope it helps!
@JorgeTrincado I already done add #define _DEBUG_
in my sketch, but still not working. Is there any setting that I need to change?
#include <SPI.h>
#include <ESP8266WiFi.h>
#include <ThingerWifi.h>
#define _DEBUG_
#define USERNAME "IronhideRobotics"
#define DEVICE_ID "esp8266"
#define DEVICE_CREDENTIAL "0123456789"
#define SSID "IronhideRobotics"
#define SSID_PASSWORD "0123456789"
ThingerWifi thing("USERNAME", "DEVICE_ID", "DEVICE_CREDENTIAL");
void setup() {
thing.add_wifi("SSID", "SSID_PASSWORD");
}
void loop() {
thing.handle();
}
Ok but what is not working out? please flash this sketch and then attach a Serial monitor capture. Be sure to select the right baudrate in the monitor:
#define _DEBUG_
#include <ESP8266WiFi.h>
#include <ThingerESP8266.h>
#define USERNAME "your_user_name"
#define DEVICE_ID "your_device_id"
#define DEVICE_CREDENTIAL "your_device_credential"
#define SSID "your_wifi_ssid"
#define SSID_PASSWORD "your_wifi_ssid_password"
ThingerESP8266 thing(USERNAME, DEVICE_ID, DEVICE_CREDENTIAL);
void setup() {
Serial.begin(115200);
pinMode(BUILTIN_LED, OUTPUT);
thing.add_wifi(SSID, SSID_PASSWORD);
// digital pin control example (i.e. turning on/off a light, a relay, configuring a parameter, etc)
thing["led"] << digitalPin(BUILTIN_LED);
// resource output example (i.e. reading a sensor value)
thing["millis"] >> outputValue(millis());
// more details at http://docs.thinger.io/arduino/
}
void loop() {
thing.handle();
}
You have forgotten to write the “Serial.begin(115200);” insctruction in the setup…
@JorgeTrincado Output on the serial monitor is the same as the picture above… I don’t know what is the problem…
It could be any problem on your hardware. have you tried any basic example like “analogReadSerial” ? just to know if you are able to flash properly the pcb.
Since I upgraded to the Arduino Thinger Library 2.9.1 I also cannot connect my ESP8266 anymore. This was without code change only by updating the library. It used to work without any problem before.
If I disable SSL (#define DISABLE_TLS) it all works. Also my other devices still on the old version can connect.
I’m not sure howto use older versions with platformio otherwise I’d go back to the previous Thinger.io version.
Hi @nikwest, we have tested client libraries with NodeMCU, and everything seems to work fine both with and without SSL. Can you post your device DEBUG output?
here is with TLS disabled, everything works:
[NETWORK] Starting connection…
[NETWORK] Connecting to network nikwest
[NETWORK] Connected to WiFi!
[NETWORK] Getting IP Address…
[NETWORK] Got IP Address: 10.0.1.129
[NETWORK] Connected!
[_SOCKET] Connecting to [removed otherwise I cannot post]…
[_SOCKET] Using secure TLS/SSL connection: no
[_SOCKET] Connected!
[THINGER] Authenticating. User: nikwest Device: sensor_node
[THINGER] Writing bytes: 43 [OK]
[THINGER] Authenticated
[THINGER] Writing bytes: 31 [OK]
and here is with TLS:
[NETWORK] Starting connection…
[NETWORK] Connecting to network nikwest
[NETWORK] Connected to WiFi!
[NETWORK] Getting IP Address…
[NETWORK] Got IP Address: 10.0.1.129
[NETWORK] Connected!
[_SOCKET] Connecting to [removed otherwise I cannot post]…
[_SOCKET] Using secure TLS/SSL connection: yes
[_SOCKET] Connected!
[THINGER] Authenticating. User: nikwest Device: sensor_node
[THINGER] Writing bytes: 43 [OK]
[_SOCKET] Cannot read from socket!
[THINGER] Auth Failed! Check username, device id, or device credentials.
[_SOCKET] Is now closed!
[THINGER] Writing bytes: 31 [FAIL]
[THINGER] Expected:31
[THINGER] Wrote:0
[_SOCKET] Connecting to [removed otherwise I cannot post]…
[_SOCKET] Using secure TLS/SSL connection: yes
[_SOCKET] Connected!
[THINGER] Authenticating. User: nikwest Device: sensor_node
[THINGER] Writing bytes: 43 [OK]
[_SOCKET] Cannot read from socket!
[THINGER] Auth Failed! Check username, device id, or device credentials.
[_SOCKET] Is now closed!
[THINGER] Writing bytes: 31 [FAIL]
[THINGER] Expected:31
[THINGER] Wrote:0
What is the port while using https connection?
Do you have the ESP8266 board library updated to the latest version? I cannot reproduce the issue!
yes, I am using platformio and everything is up to date.
Do I see it correctly, that the previous version (2.7.2) did not support TLS or it wasn’t enabled by default on ESP8266?
If that’s the case then TLS does not seem to work in my environment. I don’t understand why, but that helps to narrow down the problem.
After several tests, we cannot reproduce this issue. TLS was enabled also by default in previous library versions.
Tested with NodeMCU, Thinger.io Libraries (2.9.1), ESP8266 (2.4.1). Are you using the ESP8266 via AT commands, or just as a standalone microcontroller?
Hey!
i have the same Problem! i testet for some days. I have already the newest library 2.9.1 testet to 2.5.x and nothing happen…
watch my Picture…
the ports are open and the credentials are correct!
Hi! the headers for ESP8266 should be:
#include <ESP8266WiFi.h>
#include <ThingerESP8266.h>
and use ThingerESP8266
instead of ThingerWifi
when declaring the thing
instance.
In the other side, if you want to disable TLS, you must set #define _DISABLE_TLS_
on top of file, like the _DEBUG_
definition. Hope it helps!
Best.
Thank you for Your fast reply.
I do anything, but nothing works… what i am doing wrong?
The TLS does not disable… why?
I Am using Unbuntu in VM. But i check the Ports…
please help me
Just to clarify… You are using your own server, or just the cloud server? If you are using your own server (in a VM, i.e.,), yo need to point the ESP8266 to your own server. Check the manual.
The TLS is not disabled as it is _DISABLE_TLS_
. Test with that! Hope it helps.