Figure 1: Pi-Days Hotel aka The Bunker, Salt Lake City, UT
Figure 1: Pi-Days Hotel aka The Bunker, Salt Lake City, UT

 

As part of our annual team building events the Cireson Development team decided to undertake a fun, yet educational – and as it happens to be very practical event called Cireson Pi Days.  Pi Days was held in Salt Lake City, UT in early February.  The goal of this event is your standard team building with a twist… develop on some cool platforms; the Raspberry Pi with the Windows 10 IoT operating system.  Lance Wynn is quoted as saying “We are working to get everything together so we have a fun, educational, and exciting (and hopefully first of many annual Pi Day type Developer conferences)!!”

While the main goal is to be able to take a breath from writing code, and focus on team building, there is a darker side to Pi Day: We are actually going to write code!

All of us attending will have our own dev machines, however, some of our developers brought their own as well.  More Pi equals more power, right? We can pair program, group program, or do breakouts, but if you plan on using your own machine, you should prepare it to be able to develop IOT applications.  This process is pretty straight forward, but does have a few steps.  Thankfully they are already outlined by M$ aka M$FT here:

http://ms-iot.github.io/content/en-US/GetStarted.htm

If you can’t, or don’t have time to get your system setup before-hand, don’t worry, there will be plenty of googling errrr Binging to be done, and we can do pair programming on systems that are prepared. Pretty relaxed environment all-in-all walking into the events.

Upon arriving we were given our assignments and broken down into teams.  The assignment my team selected was entitled “Project: Consumable Scale”

Here’s a short synopsis of what we are trying to accomplish by creating a Consumable Scale: This project is basically a scale (measuring weight) that auto counts and syncs consumable assets.  What’s a consumable asset you may ask?  Well a consumable can be many things; toner, paper, office supplies – really anything is consumed over time and would require someone staying diligent to the level or quantity remaining to ensure timely ordering and tracking for future consumption.  Further to this, we wanted a scale was smart-errr… think of a scale that automatically adjust consumable asset counts based on a per unit weight and submits a service request to order more when a minimal threshold is hit. No more manual reorders!  Wow, that’s what IoT is all about!

Team Honey Badger

Team Honey Badger (yes that’s the name we chose) is comprised of the following individuals;

The majestic honey badger
Figure 2: The majestic honey badger

 

  • Lance Wynn
  • Montane Hamilton
  • David Stanley
  • Chris Ross
  • James Kleinschnitz
  • Clayton Farr (shared UI/UX SME)
  • Don Kleinschnitz (honorary Cireson developer)

 

Kicking off the event.

Lance was kind enough to prepare everyone’s rPi’s with fresh software (Windows 10 IoT) and some extra top-secret software that we will be using to build our solutions on top of.  Here (Figure 3) you see the boot-up splash plus the actual IoT interface (Figure 4) with the custom background. I personally love the Cireson logo with the raspberry touch!

 

Booting our example Raspberry Pi with Cireson Top Secret Software
Figure 3: Booting our example Raspberry Pi with Cireson Top Secret Software

 

Figure 4: The welcome screen - ready to Pi!
Figure 4: The welcome screen – ready to Pi!

Pre Work

Building the scale…

We started off with the idea to build our scale with components that were easily source-able and a bit of information we dug up through some other projects (https://www.hackster.io/team-arduinotronics/arduino-scale-b821ae) by the way, if you haven’t checked out Hackster.io we highly recommend it for getting your own Pi projects off the ground. Now obviously we didn’t want to distract from the objective of our event, programming for Win 10 IoT, so this component was completed (assembled) prior to the event kicking off.  That left us with some questions;

  1. Will the device work based on us manually assembling the components?
  2. How will we interface the scale to the rPi?

To answer those questions, we had to get our hands dirty.  Our honorary team member, the legendary Don Kleinschnitz (James’ dad) stepped in and helped us interface our scale using an Arduino! Arduino is the popular open-source electronics prototyping platform based on easy-to-use hardware and software. It’s intended for artists, designers, hobbyists, and anyone interested in creating interactive objects or environments and is designed to be as flexible as possible to fit your project’s needs. Looking at Figure 5 below, you can see each of the individual components

  1. Our homemade scale (components/parts can be found in the article referenced above)
  2. The Arduino (check out https://www.adafruit.com/products/50 for more info)
  3. RPi GPIO T-Cobbler Plus Breakout Board Kit (http://www.amazon.com/gp/product/B00OJHF8WU?colid=3E7A1AXF2CIFZ&coliid=I9GF70SKJ150N&ref_=wl_it_dp_o_pC_nS_ttl)
  4. Raspberry Pi 2B (check out https://www.adafruit.com/products/2358 for more info)

 

Figure 5: Scale with Arduino Interface
Figure 5: Scale with Arduino Interface

Planning our Features and Functionality

Like all good development teams, we took the opportunity to sit down and fully discuss what our Consumable Scale was really going to do; i.e. what features and functionality the program will implement to reach our overarching goals.  Taking advantage of the tools within reach, we scribbled out our ideas on Post-It notes found within our bunker and lined the bunker’s china cabinet with our ideas, moving our thoughts around real-time as we debated each one’s merits and argued over the amount of time it will take to develop.  This process was streamlined greatly through the help of our UX/UI guru Clayton Farr.

Figure 6: Planning board sorted (left to right) progression (top to bottom) prioirity
Figure 6: Planning board sorted (left to right) progression (top to bottom) priority

 

Now that we got our requirement defined and our project play roughed out in front of us, it’s time to start the coding.  First step, let’s fire up that scale and interface it to our PI!

Scale integration

The following code was adapted from the scale example and made to interface with the Arduino, which in turn interfaces with the Raspberry Pi to complete the integration.  Hint: The trickiest setting was figuring out the proper delay.

/* sample for digital weight scale of hx711

* library design: Weihong Guan (@aguegu)

* library host on

*https://github.com/aguegu/ardulibs/tree/3cdb78f3727d9682f7fd22156604fc1e4edd75d1/hx711

*/

// Hx711.DOUT - pin #A2

// Hx711.SCK - pin #A3

#include <Hx711.h>

Hx711 scale(A2, A3);

void setup() {

Serial.begin(9600);

}

void loop() {

Serial.println(scale.getGram(), 1);

//Serial.write(scale.getGram(),1);

//Serial.print(" g");

//Serial.write(255);

delay(200);

}

 

 

 Figure 7: You are probably like this right now... hang tight, we'll fix that!

Figure 7: You are probably like this right now… hang tight, we’ll fix that!

 

The beautiful thing about this scale is that it will self-calibrate: automatically calibrates to zero when plugged in with nothing on it.  That’s a beautiful thing!  I bet you didn’t know that 1 liter of water = 1kg of weight… I sure as heck didn’t – but Lance Winn did!  Believe me, if you want to ensure the calculations coming across the scale are being interpreted correctly you have to really get creative with what you weigh to ensure you are getting a precise result.  If you want to jump down the rabbit hole and get into this subject, check out why other liquids don’t behave this way I suggest you read all about it here: https://www.quora.com/Why-is-it-that-1-litre-of-water-weighs-1-kg-while-this-doesnt-apply-for-other-liquidsThe whole purpose of integrating through the Arduino is for the critical aspect of resistance to gram conversion, basically an analog to digital converter, or serial to gram converter.

Wow what a start, stay tuned for part 2 and learn more about what happened at PiDay & how we finished off the Consumable Scale.