Introduction: The Bitcoin Watcher

Picture of The Bitcoin Watcher

We already saw in the instructabe "Scroll a Message on a LED Matrix" how to get the up-to-date Bitcoin value through the paymium API.

We'll see here how to go a step further, and create alerts.

Step 1: Get the Bitcoin Value

Picture of Get the Bitcoin Value

The paymium API proposes to get the Bitcoin value through the command

https://paymium.com/api/v1/data/eur/ticker

It results in the string :

{"high":371.99,"low":347.3,"volume":132.34887801,"bid":360.0,"ask":363.45,"midpoint":361.725,"vwap":356.8826159,"at":1457231721,"price":360.97,"open":368.99,"variation":-2.1735,"currency":"EUR","trade_id":"379f16ea-372b-4088-86dc-fd61e6e11136","size":0.00013851}

The interesting part here is ask, that gives the last known Bitcoin value. It will be stored in msg.payload.ask.

Step 2: Display the Value

Picture of Display the Value

In order to display the value, we just have to put the msg.payload.ask value in a string stored in msg.payload :

msg.payload=(msg.payload.ask+"€");

Step 3: When to Display?

Picture of When to Display?

We can decide when to display the Bitcoin value on the LED panel through the Inject node. In this example, we decide to display the value every 5 minutes.

Step 4: Create Alerts and Notifications

Picture of Create Alerts and Notifications

What is interesting with Bitcoin is certainly to create alerts and notifications. We can imagine for example to play a sound, to send a mail or a SMS, but there are plenty of different ways to notify.

Let's take an example: we'll here send a sms if the running value goes above 400 euros, and display the value with different colors.

We first test the value with the following function:

if (msg.payload.ask >= 400) {
return [ msg, null ]; } else { return [ null, msg ]; }

And we launch the two different actions depending on the result of the test.

If condition is verified, we write the value in green, and send a sms with the value, and if not, we display the value in red.

Step 5: Learn More!

Picture of Learn More!

Comments

About This Instructable

263views

9favorites

License:

Bio: The ThingBox Project - A ready to flash Raspberry Pi image that contains Node-RED and Internet Of Things software for non developers.
More by thethingbox:Telegram Bot and TimeSquAir: the BedrockInstall Zwave Soft Remote on TimeSquAirInstall Zwave LED Bulb on TimeSquAir
Add instructable to: