Software apps and online services
If you are a blade smith who enjoys creating all of their own products or just wants to save some money on expensive hardware, this is the tutorial for you. This tutorial will give an overview on how to program a beagle bone to control the temperature of your DIY oven while also being controlled entirely from your phone! So once you have everything set up, you can just pop a blade in the oven and sit back and watch TV while the beagle does all of the hard work for you.Getting Started
Before we start programming the Beagle to make our life easier, we need to start by creating the oven and setting up the Beagle Bone Black with an operating system. There are already tutorials for these that do a fantastic job explaining how to get everything set up if you don't have it already. I will link these below with a small description of each link. Typically you want your host computer to also run linux so it is a good idea to install a VM for linux on your windows/macOS machine if you are not already running linux. If your new to linux here are some instructions on how to install an ubuntu VM. You will also need your micro SD cards at this point to flash the kernel for the Beagle.
Directions how to build your own blade smithing oven.
Here is how to flash the debian OS onto the micro SD card for the beagle.
Once the Beagle is successfully booted up, here are some instructions on how to partition the SD card and SSH into it. This scheme uses ethernet over USB so you will only need the USB cable connected to your host computer.Installing Blynk and Setting It Up for the Example Code
This project uses the Blynk app to interface the beagle with your phone. This way you can control the PID controller from your phone instead of changing the code on the Beagle. To do this install the legacy Blynk app and sign in with your Facebook account. The new Blynk IoT app is not quite developed enough to interface with the Beagle so you have to use the old Blynk app.
Blynk uses a unique authorization token to communicate with a device that is connected to the internet. For our Heat Treating Oven we will be using Blynk to control and read the internal temperature of the oven. Our application has a master on/off switch as well as the ability to set the oven to hold a certain temperature. Temperature holds and reading is done in Celsius since most bladesmithing and metallurgy temperatures are given in Celsius.
Our Blynk app uses 5 virtual pins to communicate signals such as the on/off signal or the hold temperature. The virtual pins are similar to the standard GPIO pins of the Beagle but they do not have a physical interface. Instead they are read by the Beagle using interrupts to set data in the Oven’s program.
Wiring up the parts for the Beagle
Now that the Beagle is running and Blynk is installed on your phone. It is time to wire up the extra parts to make this project work. Thankfully this part is pretty easy. All you need is your MAX31855 thermocouple breakout board wired to your thermocouple and the power switch tail ii. Any relay similar to the powerswitch will work fine if you can't get your hands on one. The Fritzing schematic is shown below but here is a picture of the whole system.
Now we are at the point that we can actually run the code. Cd to your home directory and clone the attached repository.
git clone https:/github.com/giambajt/ECE434-FinalProject
Before we run the python script, there is a setup script that will make sure that you have the correct libraries installed first
From there it should be easy as changing to the new directory and executing the python script
Plotting the temperature on Google Sheets
Different ovens heat up at different rates so it might be a good idea to plot the temperatures over time to be able to tweak the code slightly control the oven better. To do this we will use Google sheets and Crontab to continually check the temperature and log it.
The first thing to do is create a new Google sheet and fill A1 with "Time" and A2 with "Temperature (F)"
Next we will need the unique sheet ID which is in the URL. An example is shown below
Now Cd to the repository for this project and go to "SheetsExample". Modify demo.py to use your unique sheet ID and run the scrip
If you get a message like this:
Please visit this URL to authorize this application: https://accounts.google.com/o/oauth2/auth?response_type=code&client_id=834314057708-q7dsgi6i0eeef4ap6gh3d6k2qu64g5k.apps.googleusercontent.com&redirect_uri=urn%3Aietf%3Awg%3Aoauth%3A2.0%3Aoob&scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fspreadsheets&state=mNbw6E6ZIbpHqU2j6mrxPamewzcbUE&prompt=consent&access_type=offline&code_challenge=AV-yuItiICbH9KjdudKbLCwg1KDJ-vvCzUUzotDNijE&code_challenge_method=S256
Click the link, if you are on chrome, it will say the website is unsafe. Click the "Go to Logging Data (unsafe)" and there will be a string that the web page gives you. Paste that string into the terminal and you should be good to go! On Google sheets you will want to change the format of the "Time" column to be "Date Time" by clicking on the Format tab, hovering over Number and the selecting Date Time. Now that your data is in the right format you can make a line graph of the data over time using Insert chart and it should update automatically
Now we want to do this script to run every minute so that we can log the temperature at regular intervals. We will do this use crontab. Crontab is a scheduling service that Linux uses to run certain things at very long intervals. Minutes, Hours, Days, Months, whatever. We have made it easy for you though. All you have to do is modify InstallCron.sh and change the path in that file to the exact directory where your demo.py script is and then run it.
Starting the Program on Bootup
If you want this program to start on bootup of the Beagle, here is a link that shows you how to use systemd to achieve this