Introduction: KaSTAN - Your Friendly Beer Box
kaSTAN is a beer box... that is also your friend! Though it might insult you from time to time, it'll always inform you about what's going on inside of him honestly and immediately. Even when you're not home, you can keep in touch with him via twitter or a website.
kaSTAN-WebUI: http://kastan-web.azurewebsites.net/
Blog: http://kastan.azurewebsites.net/
What you will need in advance to rebuild this awesome project:
- Raspberry Pi 3
- with charger
- Arduino Uno
- Breadboard
- 4 Force Sensors
- 1 Thermistor
- 1 Button
- Speakers
- 1 computer fan
- power strip with at least 3 free spots
- a lot of cables, make sure that you have the possibility to solder
- 2 31cm x 45cm wooden plates
- 2 20cm x 31cm wooden plates
- 1x 18cm x 45cm wooden plate
- 1x 18cm x 30cm wooden plate
- 1x 14cm x 18cm wooden plate
- 1x 18cm x 30cm acrylic glass
- screws and paint as you want
- a hot glue gun
- tubes etc. as decoration for your box
- some time :)
Here is, how you build it:
Step 1: Prepare the Cloud-Apps
First of all, you need to sign up on Microsoft Azure. In order to do this, go to azure.microsoft.com and register a free account. You need to enter your credit card number, but as we are just using free services in this instructable, there is nothing which you need to pay.
After your account is created successful, go to portal.azure.com and log in with your credentials.
Create a resource group for the new project in order to keep up the tidiness. In the Azure Portal, click on Ressource Groups > Add and create a new resource group.
- Enter a preferred name with which you are able to recognize the project.
- As a subscription, choose your preferred subscription.
- For the resource group location, choose one which is near to the place you are living in order to reduce latency.
Step 2: Prepare the Cloud-Apps
After the resource group is created, we create a MySQL database. Click on New and search for MySQL. Choose MySQL Database from the Publisher ClearDB and click on create.
Step 3: Prepare the Cloud-Apps
Configure the settings as below. Make sure that you choose the Mercury Pricing Tier, as this is the only pricing tier which is completely for free.
It takes a while until the database is created completely. In the meanwhile, we create our web app which is the base for our web interface of the KaSTAN.
Step 4: Prepare the Cloud-Apps
Click on New > Web + Mobile > Web App. Choose a name you like (take care, the app name will be in the link to the page!), choose a subscription and add it also to the existing Resource Group. We also need to create a new App Service Plan. An App service plan contains everything which is needed for the Web App.
- Click on Create new
- Choose a name for the App service plan and the right location and click on Pricing tier > View All. Scroll down until you see the plan F1 Free, choose it and confirm with select and create the new app service plan.
Step 5: Prepare the Cloud-Apps
Now, the Web App is configured completely and you can click on create. Make sure, that you pin it to the dashboard in order to get back to it easily.
In the meanwhile, our database should be created. Go to your dashboard and click on the database. Go to All settings > Properties.
Scroll down until you see the field Connection String and copy it. Save it local. You need this later.
Step 6: Prepare the Cloud-Apps
Go back to the dashboard and select the Web App we just created. Go to All Settings (just like before) and click on Application Settings. Set the PHP version to 5.6. Additionally, we need to connect the MySQL Database to our Web App. Scroll down till you see the category Connection Strings, enter a preferred name and the connection string you copied as the value. After, set the category to MySQL and save everything.
Step 7: Prepare the Cloud-Apps
Now, click on Tools in your Web App overview and click on Kudu and confirm with Go. You will be redirected to the Site Content Manager (SCM) of your web app.
Step 8: Prepare the Cloud-Apps
In the SCM, click on Site Extensions and search for phpMyAdmin (case sensitive) in the Gallery. Click on the plus-icon. Confirm with Install.
phpMyAdmin will be installed in the background. After the installation is finished, restart your site.
Step 9: Prepare the Cloud-Apps
Now we need to configure phpMyAdmin on which database it needs to connect. In order to do this, click on the Debug Console and choose CMD.
We do not need the console itself, so you can minimize it.
Now navigate to SiteExtensions > phpmyadmin and search for the file config.inc.php and edit it.
Step 10: Prepare the Cloud-Apps
Search in the file for the comment // Servers not found. Now, take your connection string. You can find ours with alle relevant data marked up below: Database=kastan_tutorial_db;Data Source=eu-cdbr-azure-west-d.cloudapp.net;User Id=baf4f09f4a3b24;Password=1f68bbd0
Now, modify the code in the file as below (remember the ‘’ before and after the resource you’re adding.
Save the file and restart your web app.
Step 11: Prepare the Cloud-Apps
After the restart, launch the phpMyAdmin Extension. A new site will open with the phpMyAdmin UI.
We can now start setting up our database. Click on your database in the left column and create a table with 5 columns and confirm with Go.
Step 12: Prepare the Cloud-Apps
Configure the columns as below. Save it and your database is created.
Let’s test if we are able to add entries to the database. Switch to the Insert Tab and enter some data. You should see the entry directly after you entered it. Congratulations, the database is set up completely and ready to work with.
Now we need to set up our web interface to get access in a more common way than connecting to phpMyAdmin all the time. If you’re a pro in creating full responsive web designs, feel free to create an own. We searched for a template on a site called www.html5up.net and modified it for our purposes.
When you are finished with your design, we need to upload it to our web app. For this, download a FTP client (e.g. Filezilla) and get the connection details from Azure. To do this, click on your Web App and click on Get Publish Profile. Save the .PublishSettings file locally.
Step 13: Prepare the Cloud-Apps
Now open the .PublishSettings file and search for the publishUrl, username and userPWD.
Now, connect to your Web App via FTP with this data and upload your web page. To get a view on your database, take a look at the code snippet in the attachment (php_snippets.php). We provided you a lot of snippets to fullfil your needs. Make sure, that you save the file as a php-file.
To get a visual view on the data, we visualized it with JS Charts by amCharts. In the attachment, you find the file bigdata.html and plot_json.php. Edit the needed data in plot_json.php and upload it to your webserver. Now, the data will be visualized based on your database.
Now we’re finished with configuring our web-UI. Now we need to make our Raspberry Pi 3 intelligent.
Step 14: Configure RasPi
- Download Raspbian Wheezy and mount it on a SD card. After, boot your Raspberry Pi.
- Update &Upgrade everything.
- sudo apt-get update
- sudo apt-get upgrade
- Make sure, Python is installed properly.
- Download Festival Text To Speech Software.
- sudo apt-get install festival
- Test if it's working
- echo "This is a test." | festival --tts
Step 15: Configure RasPi
- Load the attached Scripts to your Raspberry in the directory /home/pi/Desktop/
- Create a folder called "logs" on your Desktop.
- Open the crontable
- sudo crontab -echo
- Add the two lines below in it:
# Scripts after Reboot@reboot sh /home/pi/Desktop/launcher.sh > /home/pi/Desktop/logs/cronlog 2>&1
# Update every hour
23 * * * * sh /home/pi/Desktop/do_update.sh > /home/pi/Desktop/logs/updatelog 2$ You're done. Reboot your Raspberry Pi and it should welcome you with a warm voice.
An update of the sensors is done every hour at '23.
Attachments
Step 16: Prepare the Arduino Uno
We combined a temperature sensor and for every bottle slot one force sensor. Everything is controlled by the arduino and sent to its serial output. The raspberry, as configured above, reads those JSON-formatted data and is doing the rest.
Copy the attached script onto your Arduino and you're done. Now, prepare a breadboard like the attached sketch. Make sure you connect it exactly as it is sketeched on the example. Connect the Raspberry Pi via Serial USB to your Arduino and you're done.
Attachments
Step 17: Build It!
Follow the steps in the instructions to build kaSTAN (see pdf file below).
You are best equipped with:
- a drill
- a jigsaw
- a folding rule
- loads of bolts and nuts
- a hinge
- a PC cooler
- wood
- acrylic glass
- wood glue
- a laser cutter
- hot glue
- a LOT of creative energy