Bitcoin price alert using an Arduino Nano
Youtube Video
Creating a Bitcoin price alert using an Arduino Nano and a Python script can be a useful project for monitoring the value of Bitcoin.
Parts Required:
– OLED LCD Led-display-module 0,96 “IIC SPI
– 10 Karat ohm Trim Potentiometer
– Buzzer / piezo speaker
– on/off Switch
– Arduino NANO v3.0
– Breadboard
– Wires to connect it all together
Wiring your BTC Price Alert:
required library:
– SPI
– Wire
– Adafruit_GFX
– Adafruit_SSD1306
Arduino Code:
// Hisham Marzouk
// Officialhrm.com
#include <SPI.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#define OLED_RESET 4
Adafruit_SSD1306 display(OLED_RESET);
#define NUMFLAKES 10
#define XPOS 0
#define YPOS 1
#define DELTAY 2
#if (SSD1306_LCDHEIGHT != 64)
#error(“Height incorrect, please fix Adafruit_SSD1306.h!”);
#endif
int Buzzer = 2;
int sensorPin = A0;
int Switch = A2;
int Value =0;
float sensorValue = 0;
void setup() {
Serial.begin(9600);
.
.
.
}
Download to get the full code.
Python Code USD:
# Hisham Marzouk
# Officialhrm.com
import urllib2
import serial
import re
import time
ser = serial.Serial(port='COM5', baudrate=57600)
ser.close()
opener = urllib2.build_opener()
opener.addheaders = [('User-agent', 'Mozilla/5.0')]
url = ('https://blockchain.info/ticker')
if ser.isOpen()== False:
ser.open()
time.sleep(1.1)
while (ser.isOpen() == True):
oururl = opener.open(url).read()
spl = oururl.split("USD")
spl2 = (spl[1])
spl3 = spl2.split('"last" : ')
spl4 = (spl3[1])
spl5 = spl4.split(', "buy"')
spl6 = (spl5[0])
spl7= (spl6)
time.sleep(1)
print(spl7)
ser.write(spl7)
to change the currency from USD to Euro change this Line.
from spl = oururl.split("USD")
to spl = oururl.split("EUR")