The Bolt APIs are used to connect the Bolt based hardware and the Bolt Cloud to any third party system. In this instructable, we will use Virtual Private Server (Digital Ocean) for using Bolt API and we can use Bolt remote API to control and monitor your bolt hardware unit using the Python programming language and C language.
Digital Ocean: DigitalOcean is a cloud infrastructure provider focused on simplifying web infrastructure for software developers. It provides developers cloud services applications that help to deploy and scale applications that run simultaneously on multiple computers. All DigitalOcean servers are live and configurable in less than one minute.
Step 1: Create Account on Digital Ocean
When you successfully create your account on Digital Ocean you can see the homepage of your account. For creating your droplet on Digital Ocean, follow the steps give below.
Step 2: Create Droplet
Click on create droplet button.
Step 3: Select Operating System
You can select any OS for the operation according to the requirement. I have selected Ubuntu version 16.0401*64 for the operation.
Step 4: Choose Size
You can choose the size according to your requirement. For normal operations, we can choose the $5/month subscription.
Step 5: Choose Datacenter Region
You can choose any country datacenter. It's good if you choose the server which is near to you. If you are facing issue with low speed on a server then you can change your server with other country's server.
Step 6: Choose Droplet Number
Choose droplet number according to your requirement. We can select 1 if we want to create only 1 droplet. If you want to create more than 1 you can set number according to that.
Step 7: Hostname
Write a hostname. A hostname is your digital ocean server name. You can give any name to your server. After that, Click on creates so your server will create.
Step 8: Dashboard
You can see your server on a home page of your DigitalOcean account. You can see DigitalOcean IP address which will use for accessing your digital ocean server.
Now you have successfully created a server on the digital ocean.
Check your mail for user id and password for your digital ocean account which is sent by digital ocean team.
Step 9: Steps for the Operation
1.) Open putty
2.) Type IP address of your DigitalOcean account, select SSH and click on OK.
3.) login to digital ocean server through user id and password which is sent by mail.
4.) You can change your digital Ocean password.
5.) Create python file. for eg- sudo touch filename.py
6.) Write code for LED Blink/Analog read. for eg- sudo nano filename.py
7.) Save python file.
8.) Run python file. for eg- sudo python Filename.py
9.) Check Output.
Check python code for LED blink and Analog read in next step.
Step 10: Python and C Code
/* LED Blink using python*/
r = requests.get('http://184.108.40.206/remote/xxxxxxxx-xxxx-xxxx-xxxx-xxxxx-xxxxxxxxxx/digitalWrite?pin=0&state=HIGH&deviceName=BOLTxxxxxxxx')
// xxxxxxxx-xxxx-xxxx-xxxx-xxxxx-xxxxxxxxxx- This is API key which you have generated while doing normal operations with Bolt API. This is different for every user.
//BOLTxxxxxxxx - This is your device name which is different for every user.
r = requests.get('http://220.127.116.11/remote/xxxxxxxx-xxxx-xxxx-xxxx-xxxxx-xxxxxxxxxx/digitalWrite?pin=0&state=LOW&deviceName=BOLTxxxxxxxx')
time.sleep(1) // Its is a time dalay of 1 second
/* Analog read using python*/
r = requests.get('http://18.104.22.168/remote/xxxxxxxx-xxxx-xxxx-xxxx-xxxxx-xxxxxxxxxx/analogRead?pin=A0&deviceName=BOLTxxxxxxxx')
data = json.loads(r.text)
/* C Code for all functions on Bolt */
You can check the GitHub link given below for C Code. It will explain how you can code in C language using Bolt API.