-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added new sensors sleep mode, remain battery and I2C secure begin.
- Loading branch information
1 parent
b362fc6
commit 0da0536
Showing
5 changed files
with
133 additions
and
1 deletion.
There are no files selected for viewing
35 changes: 35 additions & 0 deletions
35
examples/Thinger_CallDevice_Receiver/Thinger_CallDevice_Receiver.ino
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/*This example is ready to receive a PSON with all environmental data, sended by an other climaStick though a | ||
* Thinger.io call_device() instruction. After receive this data we will be able to use it for different purposes | ||
*/ | ||
|
||
#include <ClimaStick.h> | ||
|
||
#define USERNAME "your_user_name" | ||
#define DEVICE_ID "receiverDevice" //DEVICE_ID should be the same as we used in the call_device instruction | ||
#define DEVICE_CREDENTIAL "your_device_credential" | ||
|
||
#define SSID "your_wifi_ssid" | ||
#define SSID_PASSWORD "your_wifi_ssid_password" | ||
|
||
ClimaStick thing(USERNAME, DEVICE_ID, DEVICE_CREDENTIAL); | ||
|
||
void setup() { | ||
// configure board wifi | ||
thing.add_wifi(SSID, SSID_PASSWORD); | ||
|
||
thing[“externalEnvironment”] << [](pson& in){ //resource name should be the same as we used in the call_device instruction | ||
float received_temperature = in["temperature"]; | ||
float received_temperature = in["humidity"]; | ||
float received_temperature = in["altitude"]; | ||
float received_temperature = in["pressure"]; | ||
float received_temperature = in["lux"]; | ||
}; | ||
} | ||
|
||
|
||
} | ||
|
||
void loop() { | ||
thing.handle(); | ||
|
||
} |
33 changes: 33 additions & 0 deletions
33
examples/Thinger_CallDevice_Sender/Thinger_CallDevice_Sender.ino
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/*This example will read some variables from enviromental sensors of ClimaStick and send it to | ||
* another device using Thinger.io call_device feature. you will need to create two different devices: | ||
* An emitter (this) and a receiver one (the other device) with the code that we have included into | ||
* "Thinger_CallDevice_receiver.ino" example. | ||
*/ | ||
|
||
#include <ClimaStick.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" | ||
|
||
ClimaStick thing(USERNAME, DEVICE_ID, DEVICE_CREDENTIAL); | ||
|
||
void setup() { | ||
// configure board wifi | ||
thing.add_wifi(SSID, SSID_PASSWORD); | ||
// initialize board sensors | ||
thing.init_sensors(); | ||
// define the "environment" resource | ||
thing.init_environment_resource(); | ||
} | ||
|
||
void loop() { | ||
thing.handle(); | ||
// Call to "receiverDevice" and send "environment" resource data to "externalEnvironment" resource of destinyDevice | ||
thing.call_device("receiverDevice", "externalEnvironment", thing["environment"]); | ||
// sleep the device 60 seconds | ||
thing.sleep(60); | ||
} |
36 changes: 36 additions & 0 deletions
36
examples/Thinger_Email_Endpoint/Thinger_Email_Endpoint.ino
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#include <ClimaStick.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" | ||
|
||
ClimaStick thing(USERNAME, DEVICE_ID, DEVICE_CREDENTIAL); | ||
|
||
int timer=0; | ||
|
||
void setup(){ | ||
// configure board wifi | ||
thing.add_wifi(SSID, SSID_PASSWORD); | ||
// initialize board sensors | ||
thing.init_sensors(); | ||
// define the "environment" resource | ||
thing.init_environment_resource(); | ||
} | ||
|
||
void loop() { | ||
thing.handle(); | ||
|
||
if(millis()>timer+(60000*10)){ //email will be sended each 10 minutes | ||
//create a pson with some data | ||
pson data; | ||
data["temperature"] = thing.get_temperature(); | ||
data["humidity"] = thing.get_humidity(); | ||
|
||
//call thinger.io endpoint function and attacht the pson | ||
thing.call_endpoint("ExampleMail", data); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#define _DEBUG_ | ||
#include <ClimaStick.h> | ||
|
||
#define USERNAME "jt" | ||
#define DEVICE_ID "climaMove" | ||
#define DEVICE_CREDENTIAL "climaMove" | ||
|
||
#define SSID "Trincado04" | ||
#define SSID_PASSWORD "trincadoK7" | ||
|
||
ClimaStick thing(USERNAME, DEVICE_ID, DEVICE_CREDENTIAL); | ||
long rssi; | ||
void setup() { | ||
Serial.begin(115200); | ||
// configure board wifi | ||
thing.add_wifi(SSID, SSID_PASSWORD); | ||
// initialize board sensors | ||
thing.init_sensors(); | ||
// define the "environment" resource | ||
thing.init_environment_resource(); | ||
thing["RSSI"]>>outputValue(rssi); | ||
} | ||
|
||
void loop() { | ||
thing.handle(); | ||
rssi = WiFi.RSSI(); | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters