Skip to content

jonohayon/colu-smart-door

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

60 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Colu Smart Door

Disclaimer

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.

What is this thing?

The colu smart door project is literally, a smart door powered by the Colu platform.

What is Colu?

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.

Where do I sign up?

There's no need to sign up, just follow the tutorial!

Tutorial

Before we start...

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.

Requirments

  • 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.

First - the server

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).

Configuring the server

1. DB (Mongolab)

Click on the "GET 500MB FREE" button: Mogolab main screen

Signup to the service: Mongolab signup form

After signing up and verifying the email, click on the "Create New" button to create a new database: Mongolab after signup

Now there will be a page with a lot of options. This is what you need to do: Mongolab change DB options

Then, set the DB's name and submit the form: Mongolab set DB name and submit form

On the DB page, go to the "Users" tab and click on "Add databse user": Mongolab add new user #1

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):
Mongolab add new user #2

Then, get the DB url from the page: Mongolab get the DB url

Now let's add the admin user so we can access the control panel itself.

First, let's add the "users" MongoDB collection: Mongolab add collection step 1 Mongolab add collection step 2

Now, let's add the admin user to the collection. Click on the "Add document" button: Mongolab add admin step 1

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:

WIP - Admin sign up page

Now we can set up the server for our door!

Server (Heroku)

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:

Deploy

After the deployment has ended click on "manage app" to go to your app's dashboard and then choose the "Settings" tab: Heroku manage app button Heroku settings tab

Inside of the "Settings" tab, click on "Reveal config vars": enter image description here

Now we can see all of the config variables that our server needs to setup: Heroku config vars view

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. Heroku add config var step 1

Here is how you add a new config var + the names of the config vars that you need to add: Heroku config vars step 2

Then, to make the changes actually matter, you'll need to restart the server like this: Heroku restart instance

Done! The server is live now! You can now access your door's control panel like this: <your app's name here>.herokuapp.com

Second - the hardware (Raspberry Pi)

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.

The elec. schematic

RasPi Elec. Schematic

And now with marks of each part: RasPi Elec. Schematic w/Marks

FYI (and important) - this is a pushbutton representation (just the red lines, not the green ones):

Ignore the pushbutton

as for now, you can ignore it, there's no need for it at the moment.

What should I do with those schematics?

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!

Install the OS and setup internet connection

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!

Getting 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!

About

The colu smart door repository

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published