It always seems to amaze people when we pull out our phone, sigh a breath of relief, and say something like “Oh Good, My Dog’s not Dead!” Being able to remotely check in our perrito while hiking a Piramide brings a little extra comfort knowing doggo is okay.
The topic of automation is something I get asked about a lot in YouTube comments. Unfortunately it goes something like “How do you do all that automation stuff?” It’s a broad question, quite outside the scope of a reply to a comment. Even in a single video it would be tough to lay it all out. So in this post I hope to outline one aspect of the automation, and that is remote monitoring various vitals of the truck.
I’ve often received compliments for “Inventing” this or that, But I don’t feel I’ve invented something so much as mixed the mortar that locks all the building blocks together to build a great Piramide. 😊
But first a preface: being able to access this stuff remotely depends on the truck having a data connection to the outside world, We use a MoFi LTE Router that has a Sim Card with a basic data package. I won’t go into a ton of detail here, suffice to say that our truck has a WiFi hotspot around it at all times. We made a terrible video on it here:
The next building block is a Raspberry Pi 3, a credit card sized computer that runs off of 5 volt USB, has built in WiFi, Bluetooth, 4 USB’s, HDMI Video and cost $35. We have a few of them scattered around the truck, doing various tasks. There are newer faster versions out now, But even the $10 Raspberry Pi Zero would work fine for this very light duty task.
While this post can’t go into step by step details, of the full installation, it will give you the right search terms to Google to find the answers you need. That being said, you’ll need to download the latest version of Raspbian and flash it to a Micro SD Card. Boot it up and join your WiFi network. Ya got’r’done? Great, Now you have a micro computer waiting to do your bidding.
The next building block is a Smartphone App called Blynk, it’s available for Android and iOS and it is the “LEGO” of smartphone apps. You can switch it to edit mode, add or move displays, graphs, buttons and other controls. This was a Kickstarter project back in the day and we’re proud to have brought this to life. Anyway, get that installed and play around a bit, they give you credits to “buy” more buttons and graphs, but the free included amount is plenty for a basic project.
Then the mortar that glues it all together – the Raspberry Pi to the Blynk App – “Python”, it’s a scripting language that may seem daunting at first, but fear not, it’s built into Raspbian and it is very popular so there are plenty of free resources and example snippets of code online to get most things done. A very basic Python Script may look like this.
!/usr/bin/python import RPi.GPIO as GPIO //Setup the IO GPIO.setmode(GPIO.BCM) LIGHTS = 16 GPIO.setup(LIGHTS, GPIO.OUT) GPIO.output(LIGHTS, True) exit()
This is a simple script to turn on the lights and it’s triggered when we press F2 on our little wireless keyboard, we can also call it with a webhook via a Google Assistant Request.
“Okay Google, Turn on the Lights”
Back to the task at hand, you’ll need to install the Blynk libraries and then set up a cron job to run your script as often as you see fit, but here is an example of a temperature logging script that uses a DS1820 to sense the temperature in the room and then upload that to Blynk’s servers where you can later retrieve it with the Blink App.
#!/usr/bin/python #!/usr/bin/env python import os import glob import BlynkLib BLYNK_AUTH = '12cbe0' #from the Blynk App # Initialize Blynk blynk = BlynkLib.Blynk(BLYNK_AUTH) os.system('modprobe w1-gpio') os.system('modprobe w1-therm') #base_dir = '/sys/bus/w1/devices/' #device_folder = glob.glob(base_dir + '28*') # Hard coded to below device_file = '/sys/bus/w1/devices/28-011215515/w1_slave' #this is the Unique SN on the DS1820 def read_temp_raw(): f = open(device_file, 'r') lines = f.readlines() f.close() return lines def read_temp(): lines = read_temp_raw() while lines.strip()[-3:] != 'YES': time.sleep(0.2) lines = read_temp_raw() equals_pos = lines.find('t=') if equals_pos != -1: temp_string = lines[equals_pos+2:] temp_c = float(temp_string) / 1000.0 #temp_f = temp_c * 9.0 / 5.0 + 32.0 #For my American Homies return temp_c print "Room Temp ",(read_temp()) blynk.virtual_write(120,read_temp()) blynk.run()
I know this post glosses over a lot of the details, so you’re going to have to do your homework. But I’ve shown you the books you have to read. If there is enough interest and supporting channel members, perhaps I can do a more in depth video in the future.
I will leave you with a Photo Montage of some of the screens of data I get access to right on our phones.