Arduino+enc28j60


#1

Hi thinger community! I’m new here and this is my firt post.
At this moment I’m trying to debug the ethernet connection with thinger using UIPethernet library. The device connects but I can´t see API resources in plattform.
heres is my sketch:

#include <UIPEthernet.h>

#define MACADDRESS 0x00,0x01,0x02,0x03,0x04,0x05
#define MYIPADDR 192,168,0,247
#define MYIPMASK 255,255,255,0
#define MYDNS 8,8,4,4 //google dns servers
#define MYGW 192,168,0,3

uint8_t mac[6] = {MACADDRESS};
uint8_t myIP[4] = {MYIPADDR};
uint8_t myMASK[4] = {MYIPMASK};
uint8_t myDNS[4] = {MYDNS};
uint8_t myGW[4] = {MYGW};

//#define DISABLE_TLS
#define DEBUG
#include <ThingerENC28J60.h>
#include <ThingerClient.h>
#define username “HerGonEne”
#define device_id “MEG_PM10_02”
#define device_credentials “*****”

ThingerENC28J60 thing(username, device_id, device_credentials);

void setup() {
Serial.begin(115200);
UIPEthernet.begin(mac,myIP,myDNS,myGW,myMASK);

pinMode(4, OUTPUT);

// pin control example (i.e. turning on/off a light, a relay, etc)
thing[“led”] << digitalPin(4);

// resource output example (i.e. reading a sensor value)
thing[“millis”] >> outputValue(millis());

}

void loop() {

thing.handle();
}

Debug output:
09:59:07.348 -> [_SOCKET] Connecting to iot.thinger.io:25200
09:59:07.348 -> [_SOCKET] Using secure TLS/SSL connection: no
09:59:10.156 -> [_SOCKET] Connected!
09:59:10.156 -> [THINGER] Authenticating. User: HerGonEne Device: MEG_PM10_02
09:59:10.219 -> [THINGER] Writing bytes: 42 [OK]
09:59:10.453 -> [THINGER] Authenticated
09:59:10.453 -> [THINGER] Writing bytes: 2 [OK]
09:59:10.780 -> [THINGER] Available bytes: 2
10:00:10.484 -> [THINGER] Writing bytes: 2 [OK]
10:00:50.453 -> [THINGER] Available bytes: 2
10:01:10.501 -> [THINGER] Writing bytes: 2 [OK]
10:01:50.517 -> [THINGER] Available bytes: 2
10:02:10.548 -> [THINGER] Writing bytes: 2 [OK]
10:02:13.731 -> [THINGER] Available bytes: 2
10:03:10.533 -> [THINGER] Writing bytes: 2 [OK]
10:04:10.565 -> [_SOCKET] Timeout!
10:04:10.565 -> [_SOCKET] Is now closed!
10:04:10.565 -> [_SOCKET] Connecting to iot.thinger.io:25200
10:04:10.565 -> [_SOCKET] Using secure TLS/SSL connection: no
10:04:12.578 -> [_SOCKET] Connected!
10:04:12.578 -> [THINGER] Authenticating. User: HerGonEne Device: MEG_PM10_02
10:04:12.578 -> [THINGER] Writing bytes: 42 [OK]
10:04:12.858 -> [THINGER] Authenticated
10:04:12.858 -> [THINGER] Writing bytes: 2 [OK]
10:04:13.186 -> [THINGER] Available bytes: 2
10:05:12.877 -> [THINGER] Writing bytes: 2 [OK]
10:06:12.909 -> [_SOCKET] Timeout!
10:06:12.909 -> [_SOCKET] Is now closed!
10:06:12.909 -> [_SOCKET] Connecting to iot.thinger.io:25200
10:06:12.909 -> [_SOCKET] Using secure TLS/SSL connection: no
10:06:38.165 -> [_SOCKET] Error while connecting!
10:06:43.173 -> [_SOCKET] Connecting to iot.thinger.io:25200
10:06:43.173 -> [_SOCKET] Using secure TLS/SSL connection: no
10:07:08.713 -> [_SOCKET] Error while connecting!
10:07:13.674 -> [_SOCKET] Connecting to iot.thinger.io:25200
10:07:13.721 -> [_SOCKET] Using secure TLS/SSL connection: no
10:07:17.511 -> [_SOCKET] Connected!
10:07:17.511 -> [THINGER] Authenticating. User: HerGonEne Device: MEG_PM10_02
10:07:17.511 -> [THINGER] Writing bytes: 42 [OK]
10:07:17.792 -> [THINGER] Authenticated
10:07:17.792 -> [THINGER] Writing bytes: 2 [OK]
10:07:18.120 -> [THINGER] Available bytes: 2
10:08:17.825 -> [THINGER] Writing bytes: 2 [OK]


#2

Thinger resourcer need quite a lot RAM … I have only succeded streaming 1 resouce on Arduino Uno or nano like:

thing[“led”] << digitalPin(4);

On the other hand on Arduino Mega or ESP 8266 i haven’t had problems streaming over 40 resources with ENC28J60, eventhough it seems unreasonable to use ESP 8266 with ethernet it works more reliably than over wifi and it is cheaper than Mega.

Here is the library for uip ethernet on esp8266 https://github.com/kissste/esp8266-enc28j60-UIP-Ethernet


#3

Matej,thanks for your reply! You hit the nail on the head!
I used DEBUG_MEMORY to check ram usage on serial monitor and got “Output Memory Buffer Exhausted!” messajes so I had to disable serial monitor and DEBUG to release some Ram to get it working.
Thank you for the library too!