Although most of it is finished, this guide is still WIP, so it's not complete yet and there might be some broken links. If you find any mistakes in code / english / anything else, please open an issue about it.
The colu smart door project is literally, a smart door powered by the Colu platform.
Colu is an Israel-based startup aimed at digitizing the ownership of all your things through the blockchain — the public feed of Bitcoin transactions. The service provides an easy way to use the blockchain technology, originally meant for Bitcoin transactions, for anything, from cars, to art, to concert tickets.
There's no need to sign up, just follow the tutorial!
The code for the Raspberry Pi is written in Python and the server code is written in NodeJS. There's no need to install neither of them (if you deploy to Heroku and not to your VPS or something else) because Heroku will install Node for you and Python is already on the Pi.
- Colu API key (you can get one here)
- Raspberry Pi
- SD Card for the Raspberry Pi (a regular one, not microSD)
- 1x P2N2222A Transistor
- 1x Relay (something like this one)
- 1x Electric door strike
- A few jumper wires
- Soldering Iron and Soldering Wire
- A bit of technical sense.
So the server is written in NodeJS, which is in one of Heroku's native supported languages (which means that there's no need to install Node at all, which can sometimes be a pain in the ass). Deploying the server to Heroku is easy as clicking a button which will let you deploy the script to a new Heroku app. The only parts that are needed configuration are some environment variables (read more here) for the database (MongoDB, btw), called DB_URI, DB_USER and DB_PASS. Some other environment variables that needs to be declared are the API_KEY and the PRIVATE_SEED (an optional one), for the Colu Access module.
For the database, I would recommend using Mongolab, since it gives you free 500MB of DB storage for your needs (it's good for about 10 users I guess, but for more than that I would recommend to buy a bigger DB).
Click on the "GET 500MB FREE" button:
After signing up and verifying the email, click on the "Create New" button to create a new database:
Now there will be a page with a lot of options. This is what you need to do:
Then, set the DB's name and submit the form:
On the DB page, go to the "Users" tab and click on "Add databse user":
Then, fill the form with the desired user credentials and click on the "Create" button (save the credentials for later use, you will need them):
Then, get the DB url from the page:
Now let's add the admin user so we can access the control panel itself.
First, let's add the "users" MongoDB collection:
Now, let's add the admin user to the collection. Click on the "Add document" button:
This will redirect you to a new page with a big textfield. Inside of it, put the next text portion after you change it to your needs:
{
"firstName": "<your name here",
"lastName": "<your name here>",
"type": "admin",
"phone": "<your phone here>",
"username": "coluadmin",
"email": "<your email here>"
"assetId": null
}
Then, click on the "Create and go back" button to create the document:
Now we can set up the server for our door!
For this part, you will need an Heroku account. You can sign up here.
After you've signed up, click on this button to deploy the newest version of the server scripts to a new Heroku instance:
After the deployment has ended click on "manage app" to go to your app's dashboard and then choose the "Settings" tab:
Inside of the "Settings" tab, click on "Reveal config vars":
Now we can see all of the config variables that our server needs to setup:
But there are no config vars at the moment... so let's add them! For this step you'll need the DB URL, Username and Password, as well as your Colu API Key.
Here is how you add a new config var + the names of the config vars that you need to add:
Then, to make the changes actually matter, you'll need to restart the server like this:
Done! The server is live now! You can now access your door's control panel like this: <your app's name here>.herokuapp.com
So the Pi's software is very very very easy to use. Since there's an installer script on your server, the hardest part is the connection of the hardware.
And now with marks of each part:
FYI (and important) - this is a pushbutton representation (just the red lines, not the green ones):
as for now, you can ignore it, there's no need for it at the moment.
Basically, after you've gathered all of the required parts, just solder them together accroding to the green lines in the shcematic (those are representations of wires).
After you've done this, we're now ready to install all of the software!
For installing the OS - Adafruit has a great article here.
For internet - I would recommend using WiFi (a tutorial on how to set it up here, again from the great Adafriut), but you can use Ethernet as well from model B and above (just plug the cable :P)
After setting both of these up, we're ready to get started with the code!
All of the code is hosted on your repository, so let's get it from there and install it onto the Pi!
Now, if you've booted to the desktop, open the terminal. If not / you are using SSH, you're already in the terminal!
From within the terminal, type: curl -o install.sh http://smartdoor-colu.elasticbeanstalk.com/pi/installer
After it has been completed, type sudo sh install.sh
and follow the instructions on screen. What the script is doing is basically downloading the needed python scripts from your server and adding them to the Pi's queue for starting the scripts on every startup, asking for your Heroku appname (the part between http://
and .herokuapp.com
) for the python script, and reboots the pi. After you've ran the script, you're done! Now you have a fully-working smart door powered by the Blockchain!