When bitcoin rise or fall hard 1sheeld will send an email to notify you.
/*
Internet Shield Example
This example shows an application on 1Sheeld's internet shield.
By using this example, you can get response of certain GET request and
print it all out on the terminal shield 64 bytes by 64 bytes.
OPTIONAL:
To reduce the library compiled size and limit its memory usage, you
can specify which shields you want to include in your sketch by
defining CUSTOM_SETTINGS and the shields respective INCLUDE_ define.
*/
#define CUSTOM_SETTINGS
#define INCLUDE_INTERNET_SHIELD
#define INCLUDE_TERMINAL_SHIELD
#define INCLUDE_EMAIL_SHIELD
/* Include 1Sheeld library. */
#include <OneSheeld.h>
HttpRequest request ("https://blockchain.info/stats?format=json");
static boolean isSent = false;
void setup() {
OneSheeld.begin();
request.getResponse().setOnJsonResponse(&onJson);
request.setOnFinish(&onFinish);
Internet.performGet(request);
}
void loop() {
}
void onFinish() {
request.getResponse()["market_price_usd"].query();
}
void onJson (JsonKeyChain & hell,char * res) {
Terminal.println(res);
int x=atoi(res);
if(x > 225){
if(!isSent){
Terminal.println("Bitcoin is high");
Email.send("example@example.com","Bitcoin !","Bitcoin is High");
isSent = true;
}
}else if(x < 200){
if(!isSent){
Terminal.println("Bitcoin is low");
Email.send("example@example.com","Bitcoin !","Bitcoin is Low");;
isSent = true;
}
}else{
isSent = false;
}
OneSheeld.delay(10000);
Internet.performGet(request);
}
Guest
Posted by Amr Saleh
Comments