Amr Saleh
Published © MIT

Bitcoin Email notifier

When bitcoin rise or fall than certain amounts sends email.

AdvancedShowcase (no instructions)1,450
Bitcoin Email notifier

Things used in this project

Story

Read more

Schematics

Circuit

Code

Code

C/C++
replace every "example@example.com" with your destination email.
/*

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);
}

Credits

Guest

Posted by Amr Saleh

Comments