Introduction: Bitcoin Price Alert

I made this project because I'm very interested in the Bitcoin value. This simple and little device tells me, with the color of an LED, if the price from Bitcoin went down or went up. What does it exactly do? The NodeMCU checks the price of one Bitcoin on Coindesk and stores this price in variable. After one minute the NodeMCU checks the price again and then compares it with the previous Bitcoin price. Did the price go up? Then the LED will flash twice a green color. Did the price go down? Then the LED will flash twice red.

Materials needed:

  • NodeMCU (installed and working with your computer)
  • WiFi connection
  • RGB LED
  • Some wires

Step 1: Downloading the Libraries

Download the following libraries in Arduino:

  • ArduinoJson.h
  • ESP8266WiFi.h
  • ESP8266HTTPClient.h

Step 2: Beginning a New Sketch in Arduino

Open a new sketch in Arduino and start including the libraries from step 1.

After that, paste the following code in your sketch. Beneath the three libraries that are included.

const char* ssid = "placeherethenameofyourwifinetwork;
const char* password = "placeherethepasswordofyourwifinetwork";

const char* host = "api.coindesk.com";

float previousValue = 0.0; float threshold = 0.05;

Change the value of ssid to your wifi network, and also the password, by changing the text after const char* ssid and const char* password. Just write between the "".

Step 3: Void Setup(){}

Copy + paste the following code beneath the previously written code.

void setup() {
pinMode(D1, OUTPUT); //Price down

pinMode(D2, OUTPUT); //Price up

Serial.begin(115200);

delay(10);

WiFi.begin(ssid, password);

Serial.println();

Serial.println();

Serial.print("Connecting to ");

Serial.println(ssid);

WiFi.begin(ssid, password);

while (WiFi.status() != WL_CONNECTED) {

delay(500);

Serial.print(".");

}

Serial.println("");

Serial.println("WiFi connected");

}

void loop() {

}

I attached the code that we have at this point in case it doesn't work properly. Go ahead now and upload your code! After the code has been uploaded to your NodeMCU open the Serial Monitor (SHIFT+CMD+M). It should look like the image I attached!

Congrats, your NodeMCU is now connected to the world wide web!

Step 4: Void Loop(){} Where All the Magic Happens

In the void loop, everything happens when it comes to checking the price on the internet. This part of the code will connect to the API and request the current Bitcoin price. This means that the NodeMCU will receive a JSON file with all the information that we need. Out of this JSON file we will pick only the USD price and store it in a variable value.

Go ahead and upload the code I attached to this step! After you uploaded the file to your NodeMCU, check your Serial Monitor again and see what happens ;)

Step 5: What Happens in the Serial Monitor, Stays in the Serial Monitor

Take a look at the image, this is a print screen of the serial monitor. You can see that we receive lots of information but the only thing we need is the price in USD (don't cry about the low price when you read this instructable in 2018 or later).

Step 6: Hooking Up the Hardware

In this step we will be connecting the hardware. In the code I set pin D1 for when the price goes down (red) and pin D2 for when the price goes up. I reccommend using a breadboard for easy testing your prototypes.

Go ahead and take your RGB LED out and let's connect them!

In the attached image you'll find the RGB LED pinout mapping.

Step 7: HODL!!!1!

Now enjoy your Bitcoin price alert machine! I hope you enjoyed this instructable and that it will give you way to create new projects with this. You could use all kind of outputs! How about a servo which moves? A sound when the price rises? A cool effect with a digital LED strip?

Cheers!

This project is based on a project from GitHub made by marcoschwartz

source: https://github.com/openhardwarelabs/bitcoin-ticker/blob/master/bitcoin_ticker_alert/bitcoin_ticker_alert.ino