Skip to content

Commit

Permalink
Added new sensors sleep mode, remain battery and I2C secure begin.
Browse files Browse the repository at this point in the history
  • Loading branch information
JorgeTrincado committed Jun 5, 2017
1 parent b362fc6 commit 0da0536
Show file tree
Hide file tree
Showing 5 changed files with 133 additions and 1 deletion.
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 examples/Thinger_CallDevice_Sender/Thinger_CallDevice_Sender.ino
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 examples/Thinger_Email_Endpoint/Thinger_Email_Endpoint.ino
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);
}

}
28 changes: 28 additions & 0 deletions examples/Thinger_Write_Bucket/Thinger_Write_Bucket.ino
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();

}
2 changes: 1 addition & 1 deletion library.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name=ClimaStick
version=1.2.0
version=1.2.1
author=Jorge Trincado Castan <jorge.trincadoc@gmail.com>
maintainer=Thinger.io <admin@thinger.io>
sentence=Arduino ClimaStick library for the Thinger.io Internet of Things Platform.
Expand Down

0 comments on commit 0da0536

Please sign in to comment.