Arduino WifiShield


#1

Hi sorry if this is a double posting. I have seen similar on the forum with no resolution.
I am trying to connect an Arduino Uno using the WifiShield. I have added a device etc to the console and I am using the example WifiShield program that comes with the Thinger Arduino Library. The device connects to the Wifi network but is failing to connect to iot.thinger.io. When I debug I get the following multiple times

[_SOCKET] Connect[_SOCKET] Connecting to iot.thinger.io:25200
[_SOCKET] Using secure TLS/SSL connection: no

I have checked connectivity from my network to iot.thinger.io port 25200 by telneting to that port and it works fine. My initial thought was that I had an error in the credentials I was sending but I have checked username, device ID and device credential multiple times. I have also deleted and re-added the device multiple times. Any ideas, the debug of the connection gives no clues as to what is failing at the server.
thanks
Ivan


Arduino + Wifi - Shield socket problem
#2

Hi,

we are aware that Arduino Wifi shield has some problems with the stock libraries. We need more testing, but it seems that the Wifi shield library is doing some strange things with the memory and corrupts data. We need more digging on that.

Meanwhile, you can try to manually install the latest thinger library version by downloading it from master. After manual install, it should appear as version 2.8.0 in the library manager. Then, try this code to force thinger libraries to use static allocated data (where the Wifi Shield library does not corrupt the information). Basically defining the THINGER_USE_STATIC_MEMORY before any other include.

#define _DEBUG_
#define THINGER_USE_STATIC_MEMORY
#define THINGER_STATIC_MEMORY_SIZE 512

#include <WiFi.h>
#include <ThingerWifi.h>

#define USERNAME "**********"
#define DEVICE_ID "**********"
#define DEVICE_CREDENTIAL "**********"

#define SSID "**********"
#define SSID_PASSWORD "**********"

ThingerWifi thing(USERNAME, DEVICE_ID, DEVICE_CREDENTIAL);

void setup() {
  Serial.begin(115200);
  
  // configure wifi network
  thing.add_wifi(SSID, SSID_PASSWORD);
}

void loop() {
  thing.handle();
}

With this code I got it working! :slight_smile:

[NETWORK] Starting connection...
[NETWORK] Connecting to network Meeble
[NETWORK] Connected to WiFi!
[NETWORK] Getting IP Address...
[NETWORK] Got IP Address: 192.168.1.117
[NETWORK] Connected!
[_SOCKET] Connecting to iot.thinger.io:25200...
[_SOCKET] Using secure TLS/SSL connection: no
[_SOCKET] Connected!
[THINGER] Authenticating. User: alvarolb Device: arduino_wifi
[THINGER] Writing bytes: 45 [OK]
[THINGER] Authenticated
[THINGER] Writing bytes: 2 [OK]
[THINGER] Available bytes: 2

If it dos not work, you many need to update the firmware of the shield, as described here.


#3

Thanks Alvaro – updated Library and used static mem. Worked fine.