Skip to content

Commit 2192062

Browse files
committed
Improved Debug Code.
Added support for LinkIt ONE board. Added support for ENC28J60 ethernet module. Added ESP8266 Web based configuration. Improved ESP8266 SmartConfig code.
1 parent fffd36a commit 2192062

30 files changed

+517
-184
lines changed

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,11 @@ It supports multiple network interfaces like Ethernet, Wifi, and GSM. So you can
55
* Arduino + Ethernet
66
* Arduino + Wifi
77
* Arduino + Adafruit CC3000
8+
* Arduino + ENC28J60
89
* Arduino Yun
9-
* ESP8266/NodeMCU
10+
* Any ESP8266 variant like NodeMCU
1011
* Texas Instruments CC3200
12+
* SeeedStudio LinkIt ONE
1113

1214
It requires modern Arduino IDE version, starting at 1.6.3.
1315

examples/AdafruitCC3000/AdafruitCC3000.ino

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,20 +13,18 @@
1313
ThingerCC3000 thing(USERNAME, DEVICE_ID, DEVICE_CREDENTIAL);
1414

1515
void setup() {
16-
// configure wifi network
17-
thing.add_wifi(SSID, SSID_PASSWORD);
16+
// configure wifi network
17+
thing.add_wifi(SSID, SSID_PASSWORD);
1818

19-
// resource input example (i.e. turning on/off a light, a relay, configuring a parameter, etc)
20-
thing["led"] << [](pson& in){ bool on = in; };
19+
pinMode(2, OUTPUT);
2120

22-
// resource output example (i.e. reading a sensor value)
23-
thing["millis"] >> [](pson& out){ out = millis(); };
21+
// pin control example (i.e. turning on/off a light, a relay, etc)
22+
thing["led"] << digitalPin(2);
2423

25-
// resource input/output example (i.e. passing input values and generate a result)
26-
thing["in_out"] = [](pson& in, pson& out){
27-
out["sum"] = (long)in["value1"] + (long)in["value2"];
28-
out["mult"] = (long)in["value1"] * (long)in["value2"];
29-
};
24+
// resource output example (i.e. reading a sensor value, a variable, etc)
25+
thing["millis"] >> outputValue(millis());
26+
27+
// more details at http://docs.thinger.io/arduino/
3028
}
3129

3230
void loop() {
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
// UIPEthernet for ENC28J60: https://github.com/ntruchsess/arduino_uip
2+
#include <UIPEthernet.h>
3+
#include <ThingerENC28J60.h>
4+
5+
#define USERNAME "your_username"
6+
#define DEVICE_ID "your_device_id"
7+
#define DEVICE_CREDENTIAL "your_device_credential"
8+
9+
ThingerENC28J60 thing(USERNAME, DEVICE_ID, DEVICE_CREDENTIAL);
10+
11+
void setup() {
12+
// ENC28J60 using fixed IP Address. DHCP is too big for the sketch.
13+
uint8_t mac[6] = {0x00, 0x01, 0x02, 0x03, 0x04, 0x05};
14+
Ethernet.begin(mac, IPAddress(192, 168, 1, 125));
15+
16+
pinMode(2, OUTPUT);
17+
18+
// pin control example (i.e. turning on/off a light, a relay, etc)
19+
thing["led"] << digitalPin(2);
20+
21+
// resource output example (i.e. reading a sensor value)
22+
thing["millis"] >> outputValue(millis());
23+
24+
// more details at http://docs.thinger.io/arduino/
25+
}
26+
27+
void loop() {
28+
thing.handle();
29+
}

examples/ArduinoEthernet/ArduinoEthernet.ino

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,15 @@
99
ThingerEthernet thing(USERNAME, DEVICE_ID, DEVICE_CREDENTIAL);
1010

1111
void setup() {
12-
// resource input example (i.e. turning on/off a light, a relay, configuring a parameter, etc)
13-
thing["led"] << [](pson& in){ bool on = in; };
12+
pinMode(2, OUTPUT);
1413

15-
// resource output example (i.e. reading a sensor value)
16-
thing["millis"] >> [](pson& out){ out = millis(); };
14+
// pin control example (i.e. turning on/off a light, a relay, etc)
15+
thing["led"] << digitalPin(2);
1716

18-
// resource input/output example (i.e. passing input values and do some calculations)
19-
thing["in_out"] = [](pson& in, pson& out){
20-
out["sum"] = (long)in["value1"] + (long)in["value2"];
21-
out["mult"] = (long)in["value1"] * (long)in["value2"];
22-
};
17+
// resource output example (i.e. reading a sensor value, a variable, etc)
18+
thing["millis"] >> outputValue(millis());
19+
20+
// more details at http://docs.thinger.io/arduino/
2321
}
2422

2523
void loop() {

examples/ArduinoWifi/ArduinoWifi.ino

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,20 +12,18 @@
1212
ThingerWifi thing(USERNAME, DEVICE_ID, DEVICE_CREDENTIAL);
1313

1414
void setup() {
15-
// configure wifi network
16-
thing.add_wifi(SSID, SSID_PASSWORD);
15+
// configure wifi network
16+
thing.add_wifi(SSID, SSID_PASSWORD);
1717

18-
// resource input example (i.e. turning on/off a light, a relay, configuring a parameter, etc)
19-
thing["led"] << [](pson& in){ bool on = in; };
18+
pinMode(2, OUTPUT);
2019

21-
// resource output example (i.e. reading a sensor value)
22-
thing["millis"] >> [](pson& out){ out = millis(); };
20+
// pin control example (i.e. turning on/off a light, a relay, etc)
21+
thing["led"] << digitalPin(2);
2322

24-
// resource input/output example (i.e. passing input values and do some calculations)
25-
thing["in_out"] = [](pson& in, pson& out){
26-
out["sum"] = (long)in["value1"] + (long)in["value2"];
27-
out["mult"] = (long)in["value1"] * (long)in["value2"];
28-
};
23+
// resource output example (i.e. reading a sensor value, a variable, etc)
24+
thing["millis"] >> outputValue(millis());
25+
26+
// more details at http://docs.thinger.io/arduino/
2927
}
3028

3129
void loop() {

examples/ArduinoYun/ArduinoYun.ino

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,24 +9,20 @@ ThingerYun thing(USERNAME, DEVICE_ID, DEVICE_CREDENTIAL);
99
const int ledPin = 13;
1010

1111
void setup() {
12-
pinMode(ledPin, OUTPUT);
12+
pinMode(ledPin, OUTPUT);
1313

14-
// initialize bridge
15-
Bridge.begin();
14+
// initialize bridge
15+
Bridge.begin();
1616

17-
// resource input example (i.e. turning on/off a light, a relay, configuring a parameter, etc)
18-
thing["led"] << [](pson& in){ digitalWrite(ledPin, in ? HIGH : LOW); };
17+
// pin control example (i.e. turning on/off a light, a relay, etc)
18+
thing["led"] << digitalPin(ledPin);
1919

20-
// resource output example (i.e. reading a sensor value)
21-
thing["millis"] >> [](pson& out){ out = millis(); };
20+
// resource output example (i.e. reading a sensor value, a variable, etc)
21+
thing["millis"] >> outputValue(millis());
2222

23-
// resource input/output example (i.e. passing input values and do some calculations)
24-
thing["in_out"] = [](pson& in, pson& out){
25-
out["sum"] = (long)in["value1"] + (long)in["value2"];
26-
out["mult"] = (long)in["value1"] * (long)in["value2"];
27-
};
23+
// more details at http://docs.thinger.io/arduino/
2824
}
2925

3026
void loop() {
31-
thing.handle();
27+
thing.handle();
3228
}

examples/ESP8266/ESP8266.ino

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,13 @@ void setup() {
1515

1616
thing.add_wifi(SSID, SSID_PASSWORD);
1717

18-
// resource input example (i.e. turning on/off a light, a relay, configuring a parameter, etc)
19-
thing["led"] << [](pson& in){ digitalWrite(BUILTIN_LED, in ? LOW : HIGH); };
18+
// digital pin control example (i.e. turning on/off a light, a relay, configuring a parameter, etc)
19+
thing["led"] << digitalPin(BUILTIN_LED);
2020

2121
// resource output example (i.e. reading a sensor value)
22-
thing["millis"] >> [](pson& out){ out = millis(); };
22+
thing["millis"] >> outputValue(millis());
2323

24-
// resource input/output example (i.e. passing input values and do some calculations)
25-
thing["in_out"] = [](pson& in, pson& out){
26-
out["sum"] = (long)in["value1"] + (long)in["value2"];
27-
out["mult"] = (long)in["value1"] * (long)in["value2"];
28-
};
24+
// more details at http://docs.thinger.io/arduino/
2925
}
3026

3127
void loop() {

examples/ESP8266SmartConfig/ESP8266SmartConfig.ino

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,15 @@
88
ThingerSmartConfig thing(USERNAME, DEVICE_ID, DEVICE_CREDENTIAL);
99

1010
void setup() {
11-
// resource input example (i.e. turning on/off a light, a relay, configuring a parameter, etc)
12-
thing["led"] << [](pson& in){ digitalWrite(BUILTIN_LED, in ? LOW : HIGH); };
11+
pinMode(BUILTIN_LED, OUTPUT);
12+
13+
// digital pin control example (i.e. turning on/off a light, a relay, configuring a parameter, etc)
14+
thing["led"] << digitalPin(BUILTIN_LED);
1315

1416
// resource output example (i.e. reading a sensor value)
15-
thing["millis"] >> [](pson& out){ out = millis(); };
17+
thing["millis"] >> outputValue(millis());
1618

17-
// resource input/output example (i.e. passing input values and do some calculations)
18-
thing["in_out"] = [](pson& in, pson& out){
19-
out["sum"] = (long)in["value1"] + (long)in["value2"];
20-
out["mult"] = (long)in["value1"] * (long)in["value2"];
21-
};
19+
// more details at http://docs.thinger.io/arduino/
2220
}
2321

2422
void loop() {
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#include <FS.h>
2+
#include <ESP8266WiFi.h>
3+
#include <DNSServer.h>
4+
#include <ESP8266WebServer.h>
5+
// Can be installed from Library Manager or https://github.com/tzapu/WiFiManager
6+
#include <WiFiManager.h>
7+
#include <ThingerWebConfig.h>
8+
9+
ThingerWebConfig thing;
10+
11+
void setup() {
12+
pinMode(BUILTIN_LED, OUTPUT);
13+
14+
// digital pin control example (i.e. turning on/off a light, a relay, configuring a parameter, etc)
15+
thing["led"] << digitalPin(BUILTIN_LED);
16+
17+
// resource output example (i.e. reading a sensor value)
18+
thing["millis"] >> outputValue(millis());
19+
20+
/*
21+
Steps for getting the ESP8266 WebConfig working:
22+
1. Connect to Thinger-Device WiFi with your computer or phone, using thinger.io as WiFi password
23+
2. Wait for the configuration window, or navigate to http://192.168.4.1 if it does not appear
24+
3. Configure the wifi where the ESP8266 will be connected, and your thinger.io device credentials
25+
4. Your device should be now connected to the platform.
26+
More details at http://docs.thinger.io/arduino/
27+
*/
28+
}
29+
30+
void loop() {
31+
thing.handle();
32+
}

examples/EnergiaCC3200/EnergiaCC3200.ino

Lines changed: 17 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -11,27 +11,23 @@
1111
ThingerWifi thing(USERNAME, DEVICE_ID, DEVICE_CREDENTIAL);
1212

1313
void setup() {
14-
// set the boards led to output
15-
pinMode(RED_LED, OUTPUT);
16-
pinMode(GREEN_LED, OUTPUT);
17-
pinMode(YELLOW_LED, OUTPUT);
18-
19-
// configure wifi network
20-
thing.add_wifi(SSID, SSID_PASSWORD);
21-
22-
// resource input example (i.e. turning on/off a light, a relay, configuring a parameter, etc)
23-
thing["led"]["green"] << [](pson& in){ digitalWrite(GREEN_LED, in ? HIGH : LOW); };
24-
thing["led"]["yellow"] << [](pson& in){ digitalWrite(YELLOW_LED, in ? HIGH : LOW); };
25-
thing["led"]["red"] << [](pson& in){ digitalWrite(RED_LED, in ? HIGH : LOW); };
26-
27-
// resource output example (i.e. reading a sensor value)
28-
thing["millis"] >> [](pson& out){ out = millis(); };
29-
30-
// resource input/output example (i.e. passing input values and do some calculations)
31-
thing["in_out"] = [](pson& in, pson& out){
32-
out["sum"] = (long)in["value1"] + (long)in["value2"];
33-
out["mult"] = (long)in["value1"] * (long)in["value2"];
34-
};
14+
// set the boards led to output
15+
pinMode(RED_LED, OUTPUT);
16+
pinMode(GREEN_LED, OUTPUT);
17+
pinMode(YELLOW_LED, OUTPUT);
18+
19+
// configure wifi network
20+
thing.add_wifi(SSID, SSID_PASSWORD);
21+
22+
// pin control example (i.e. turning on/off a light, a relay, etc)
23+
thing["led"]["green"] << digitalPin(GREEN_LED);
24+
thing["led"]["yellow"] << digitalPin(YELLOW_LED);
25+
thing["led"]["red"] << digitalPin(RED_LED);
26+
27+
// resource output example (i.e. reading a sensor value, a variable, etc)
28+
thing["millis"] >> outputValue(millis());
29+
30+
// more details at http://docs.thinger.io/arduino/
3531
}
3632

3733
void loop() {

0 commit comments

Comments
 (0)