Introduction: Quality of Life Meter Mk.2 - Smarter and Connected
A while ago I created a Quality of Life Meter, based on a running joke where I work. Essentially it was just a LED version of the whiteboard version we started with. When working on that first iteration I knew there were a lot of ways to improve and add to the functionality and now, thanks to Intel and Instructables, I present the QoL Meter Mk.2.
Using the new Intel Edison platform and a Seeed Studio Grove Internet of Things (IoT) Starter Kit the Mk.2 is designed as a jumping-off point for group based meters. The Mk.1 was controlled off of one input so to truly capture the status of a group there would have to be some sort of outside agreement or calculation. The Mk.2 by contrast allows for any number of individuals, or factors, to set their own value which in turn allows an accurate group average to be displayed.
The large LED thermometer was also a bit much for a shared work area, particularly one with dim lighting. While the Mk.2 can absolutely be wired to the display from the Mk.1 if that suits your needs, I instead have chosen to display the output using the backlight color on Grove RGB Backlight LCD and a simple numerical readout on said LCD.
The final major improvement is using the Edison's built in WiFi and Intel's free IoT Analytics Dashboard web tools to capture how the various inputs are changing. For our office, where this is all a bit of a joke, this functionality isn't of much real use to us but the ability to have it is cool and shows some of the benefits of Edison and potential of the meter as a platform for more practical applications.
Since this is my first Edison project this guide is really half Quality of Life Meter, half Edison setup and explanation and as such probably gets a bit verbose in places. I considered separate guides for each but I really feel that it's much easier to get everything involved with the Edison working when there's a clear purpose and reason, so break out the reading glasses and remember to blink, or, you know, just skip the extra details if they bore you.
As with Mk.1 there are a lot of different, actually useful, ways that this project could be implemented. Also as always, if you do come up with a clever use, or just recreate it step-by-step, I love seeing photos of your build in the comments. If you're a seasoned Edison vet the beginning few steps are all setup and you'd probably be safe skipping them.
Step 1: Materials & Tools
- Intel Edison w/ Arduino Breakout Board ($100) - Conceivably you could just use a regular Arduino UNO but you would lose the WiFi and data tracking functionality.
- Seeed Studio Grove Starter Kit Plus ($80)
- If you want to source the parts separately you will need:
- RGB Backlight 16x2 LCD
- 2x Momentary Switches
- 10k Rotary Potentiometer
- If you want to source the parts separately you will need:
- 4x #10-24 Screws - Holds the lid on.
- 10x #2 Screws - Used to hold the components in place.
- Electrical Tape
- 2x Micro USB Cables - These are the ones that charge your cell phone (non-Apple). One is included if you get the Grove kit. Not needed if you've already setup your Edison.
- Drill and Bits
- Glue or Epoxy
Step 2: Edison Setup
Currently perhapse the biggest downfall of Edison is the spotty documentation, particularly troubleshooting for setup problems. If you have your Edison up and running smoothly or are using a vanilla Arduino feel free to skip this step.
(Note: There was a several month gap between writing and publishing this because we were moving. It appears that setup guide is a little more user friendly. I can't comment on if it works better but at least they're trying.)
Once you've attached the Edison to the breakout board, begin setup by following Intel's guide to flashing your Edison for your OS. It covers the necessary steps to load the Yocto Linux image. After that is one of the places the documentation gets weird.
On the Getting Started guide go to the last page, "Connect Intel Edison device to WiFi", and follow the steps. After this point, if you're like a large number of Edison users, you'll notice that you can't connect to your device by putting in it's IP in your browser window. The solution to this is to simply enter 'configure_edison --server' from the root in PuTTY. After running this command try the IP again and it should bring up the information page shown in the guide. If it's still not working, make sure that your computer and Edison are on the same network, try running 'configure_edison --wifi' and reconnecting, and if nothing else works simply start over and re-flash the image.
We aren't quite out of the woods yet though because another issue seen by many Edison users is that when the Edison restarts or reboots it doesn't connect to the WiFi or start the server automatically. In my two first person experiences this was solved after doing a complete wipe (using both the method in the flashing guide and manually deleting the files out of the drive in windows) and a re-flash of the Yocto image, several times. Before doing this there are a couple of other methods scattered around the forums that you can try.
1. Run 'systemctl enable wpa_supplicant' from the Edison's root in PuTTY. This will solve the problem if the issue was the --setup didn't turn on the supplicant like it was supposed to. The supplicant is responsible for launching and auto-connecting the WiFi on boot.
2. Reboot, make sure the WiFi is connected and the server is running. From the Edison's root run 'ifconfig usb0 down', 'ifconfig wlan0 down', and 'ifconfig wlan0 up'. Try connecting to the server without rebooting and if it now works then you will have to edit '/etc/systemd/system/basic.target.wants/network-gadget-init.service' and change both lines that have 192.168.2.15 to something in a different ip range so that it doesn't just reset them on reboot.
If you've just started setting up your Edison I honestly would just suggest re-flashing and trying again as I tried all these things, and more, without success and ended up having everything work after a 3rd flash.
I've learned a lot of random stuff about the Edison, setting it up, running it, and interfacing with it that really isn't fit to be dumped here but if you're having trouble or just have questions, post them. If I can't answer them I probably can get you pointed to where they can be.
Step 3: Edison Arduino IDE Setup
With the Edison up and running, hopefully without much fuss, we need a way to write and upload our Arduino sketches. Helpfully Intel has provided a customized version of the vanilla Arduino IDE which you can find HERE. The reason that something seemingly so simple has it's own step is because there is a weird caveat when installing it. That being: if you install it in a directory that contains a space (i.e. Program Files) it errors out and won't upload sketches. It's a strange bug that the vanilla IDE doesn't have and can get you going in circles, even if you're already an Arduino user. Depending on the user name on your computer, the user folder can be a good location or the root level of C:\.
NOTE: I've been told the Windows 8 file structure uses folders with names like "Programs" and "Documents" instead of "Program Files" and "My Documents" meaning you'll have a lot more options when it comes to install directories with that OS.
If you're running an Edison and you want the IoT Analytics capabilities then you'll need the iotkit libraries, which can be found HERE. The library your looking for is IoTkit.zip in the Arduino folder.
If you're using a Grove LCD then the you can find the library for running it HERE.
Install any necessary libraries to the Edison version of the Arduino IDE the same way you do with the vanilla IDE. Under Sketch... Import Library... Add Library... navigate to the .zip folder that contains the library and select it. Restart the IDE and you should be ready to use the library.
Step 4: Hardware
Using the Grove kit really takes the sweat out of setting up a project like this. Instead of hunching over a soldering iron, fiddling with tiny wires, and trying to troubleshoot both physical and software bugs, you grab some wires, pick your components, wire them all up, and your done.
First your Edison should already be attached to the breakout board. Installing the standoffs is entirely a preference thing.
Now put the Grove shield onto your Edison breakout board or Arduino, depending on which you're using. The button and touch senor are plugged into the first two digital slots (D2 & D3 respectively), the angle senor occupies the analog slot A0, and the screen is attached to one of the IC2 pin-outs(it doesn't matter which) and you're done. It's really that easy.
When it's time to break the tether and release your project into the wild the battery pack simply plugs into the micro USB slot closest to the full size USB or into the barrel plug.
Step 5: Software
Now we're at the heart of the Mk.2. Where the Mk.1 was a hardware dominate build, the Mk.2 is much more a feat of it's code (thanks to the Grove kit). There are several specific tasks we need the code to perform:
- Display and cycle through the individual QoL readings.
- Allow the individual QoL's to be edited and saved.
- Calculate and display the average group QoL.
- Change the LCD's backlight color based on the displayed QoL value.
- Transmit the individual and group QoL values to the IoT Analyitics Dashboard.
If you're familiar with Arduino code then the sketch is decently commented (I think) and you'll probably be able to follow it simply by reading it. For those that aren't as comfortable with the code or want a little deeper explanation read on. If you don't chose to read on, just note thatyou will need to edit the names and number of names in the beginning of the sketch (see the first photo). You can view the code by opening the attached code below in a new tab which should display it as plaintext in your browser.
It starts by calling libraries and setting constants, inputs, and input debounce (this prevents single pushes from being interpreted as multiple pushes, which is caused by science) as most other sketches do. Next are the variables that you will need to change for your use. Replace, add, and/or remove the names in the names array and set the numOfNames, size of qolValues, and i looping variable to the number of entries in the names array.
The setup() function begins like most others as well with input/output initialization. After that it fills the qolValues array and call the first function, welcomeScreen(). This function simply sets the backlight color blue and displays a startup message. Returning from the function it waits a few seconds, then changes to display the average quality of life page and calls a function, ColorSet(int), to set the backlight color appropriately.
ColorSet takes an integer input from 0-100 and then chooses a backlight color ranging from red to green respectively. The red and green values for each step are stored in separate arrays (blue is always 0 so it doesnt require an array). After that a large if..else-if loop handles that actual selection and setting of the backlight. We will see this function called a lot more through out the code.
Now it enters the main loop() function and after starting to debounce inputs it begins watching for the button (D2) and touch sensor (D3) to be pressed. When the button is pressed (you have to hold for a split second due to the debounce) it increments the counter ( i ) if it's not on the last page and resets it to 0 if it is, then checks where in the menu it's at. After that it displays the page for the new i value. If the touch sensor is pressed, again give it a beat to debounce, and it's displaying any page other than the average it calls NewQoLValue(int) to allow that person to adjust their current QoL value.
Upon reading the integer passed, NewQoLValue adds "-Set" to the first line of the display for the appropriate person, reads the input from the potentiometer, normalizes it to a value between 0 and 10, and calls ColorSet. This process loops until the button is pushed and then the potentiometer reading at that point is saved (and transmitted to the IoT dashboard if it's enabled for that person) and the individuals main page is displayed again.
Every time the last page, which shows the average, is displayed it calls the qolAverage() function, displays the new average, and then transmits the new average to the IoT Dashboard with IoTTransmit(). qolAverage() is a simple function that adds all the values from qolValues and divides by the number of names to produce a group average. IoTTransmit uses a Switch..Case to transmit the correct value, individual or average, to the matching component on the IoT Dashboard.
The syntax on iotkit.send is important and was incorrect in the examples when I downloaded them. The first argument is the name of the component you are sending data to. This is put in quotes and can be found in the catalog on your IoT Dashboard account page (more on that in the next step). The second argument is simply the data being sent. In the examples included with the library, at time of writing but I think it's been corrected since, the send command shows a component name that doesn't match the name on the website, but I'll expound in the next step.
Step 6: Intel IoT Analytics Dashboard Setup
The IoT Dashboard is a website that allows for tracking and controlling internet connected devices, specifically the Intel Galileo and Edison chips, but it takes a little bit of setting up. You can start by creating an account HERE.
Once you have an account you need to register your device. From the side bar menu (three vertical lines, top-left) select Devices... Add a New Device. Now you need to access your devices command line via PuTTY, or alternative. From the devices root enter: 'iotkit-admin set-device-id <new device id>' for example 'iotkit-admin set-device-id qol-one' would set the devices IoT Kit ID to 'qol-one'. This step isn't necessary but otherwise the id is some unreadable string of values. Once you've set the ID go back to the dashboard and put the new ID into both the ID and Gateway fields. Finish by giving the device a name and saving it.
With the device registered it now needs activated. Go to the My Account page on the dashboard by clicking on your user name in the header. The third field down is Activation Code. It will say its expired and will be hidden. Select the refresh button and then the eye button to the right of the field to generate and revel a new activation code. Return to your devices command line and enter 'iotkit-admin activate <activation code>'. This will link the device to your account and your dashboard should now read "1 Active, 1 in Total".
The way the dashboard works is with what they call Components. These are simply collectors for the data that your device gathers. Each time you transmit data you have to specify which component the reading is for, so lets create a couple of components specific to our project. We'll need one for the average and one for each individual you want to track.
On the My Account page of your dashboard select the Catalog tab. You'll see there are several default components already in place but at the bottom of the page you can select Add a New Catalog Item. For the name of the component try to avoid spaces as they can easily confuse command lines. Camel-case (e.g. ThisIsCamelCase) doesn't work either so stick with an _ or - if you need word separation. Next, the type is Sensor, the Data Type is Number, Format is Integer, put '%' for Unit of Measure, and your only Display Option is Time Series. Min and Max are optional and I haven't noticed any difference with or without it (It may be that it discards any readings outside that range if set but I can't confirm that). Repeat this until you have a unique component for every individual you want to track and one for the average.
With our components in the catalog it's time to head back to the command line and register the components on the board. Run the command 'iotkit-admin catalog' which will display all the components names and IDs you've created in the Dashboard. Now for each component you want to use run the command 'iotkit-admin register <component name> ' where the component name and ID come from the catalog. For example, to register the default temperature component you would write 'iotkit-admin register temperature temperature.v1.0'. Watch the readout and if everything works repeat for each component you wish to register. You can verify that the components registered by looking under the Components drop down in your devices info page on the Dashboard.
A final, optional, feature is the ability to setup alerts based on the data being provided by the device, called rules. I set one up that sends a notification when the group average drops below 40% but the ability to add several conditions to each rule means you can make much more sophisticated systems. Setting one up is pretty straight forward, simply give it a name and description and choose your email from the drop down (you can add more emails under the Users tab on the My Account page). On the next page select the device that will be sending the data, and then on the final page add the conditions under which you are alerted. Select the component you want to monitor, choose the type of trigger you want (Basic Condition contains the mathematical and logical operators), and finally input the actual trigger value.
To verify that everything is working as designed you can send a test observation form the Edison's root command line. Send 'iotkit-admin observation <component_name> ' which would look like the following with the default temperature component: 'iotkit-admin observation temperature 55'. Once you've sent some data check the Charts page on the Dashboard. Select your device, pick the components you want to see, and it will draw a graph of the data.
Step 7: Enclosure
The bulky wood case I built for the Mk. 1 was all well and fine for a first go but this is the Mk.2. It should be better in every way. Since my CAD modelling skills far surpass my woodworking ones I decided to use additive manufacturing this time around. In this case, fused deposition modeling (FDM), colloquially known as 3D printing. This also provided an opportunity to tryout a relatively new service for crowd-sourcing additive manufacturing, 3D Hubs. I'll talk more about that service and my experience with it on the last step wrap-up but suffice it to say, the cost and lead time was substantially lower than using one of the many company based services available.
You may notice there aren't any places for the buttons and knob in the models. This is due to the design of the Grove components (more on this later as well). You will need to match drill the mount holes (undersized so the screws can cut threads) and a pass through hole for the wires. In hindsight I should have modeled the pass-throughs in, at the very least. The LCD attaches to the small lid piece which is glued into the larger lid. Due to a conceptual mistake in the model (hopefully corrected in the attached files) my LCD is held in place with electrical tape, which seems to be working fine and may be an option if drilling on the small cover seems problematic to you. You will also have to match drill the main lid to the base (again, under-sizing the the holes so the screws can tap the hole).
With everything drilled and the lid assembled, simply stuff the Edison and battery pack into the box and attach the lid to the base. If you want to secure the Edison I would suggest attaching the included standoffs and then gluing them to the box. At that point you can remove the Edison if necessary by simply unscrewing the board from the standoffs. If you're not going to use a battery pack then don't forget to drill a hole for that somewhere as well.
I've included the .stl files, which most 3D printers accept, and .stp files in case there is anyone who wants to make modifications before printing (if you have CATIA and want .CATPart files shoot me a message). The units on the stl's are mm and on the stp's are inches, just to make it confusing.
Step 8: Conclusions & Moving Forward
Below are some musings and wrap-ups about the tech I used for the first time in this build and some thoughts on the QoL Meter as a platform and my aspirations for a future iteration.
The Mk.2 and Beyond
While this was definitely just a step and not a bound away from the Mk.1, I feel that the Mk.2 shows that there could actually be useful implementations of the platform. With obvious small tweaks it could be used to track where you're spending you're time, total team donations in school food drive competition, the sales by individuals in a small company, or any number of other examples. A lot of this hinges on the IoT Dashboard's functionality which should only improve as time goes on.
I still envision a meter that autonomously collects data from the user and their environment to build a more complete snapshot that's not as dependent on direct user input which isn't always terribly accurate. The existing capabilities of the Dashboard already would allow a network of these devices to provide a comprehensive look at a workforce, group of students, locations, or whatever you fancy. Or it can just become and even more elaborate joke, which I'm totally down with.
As first experiences go I have to admit this wasn't the smoothest. Support is improving all the time but it almost feels like a beta release of sorts. The help forums are manned by a few Intel employees that seem to be learning by experimenting, the documentation you can find seems to be cobbled together from the old Galileo chip, and, for what is being marketed towards the sort of DIY folks and makers you find around Instructables, there is quite a lot of assumed specific technical knowledge, particularly on the Linux front.
There is a lot of potential wrapped up in the Edison but currently you have to be a bit more hardcore to really make use of it. Also the price point, $80 w/ the Arduino breakout board, exceeds something like an Arduino UNO w/ a WiFi shield so while it's nice to have the cross compatibility it's future really lies with it's more computer-like features. I'll be very interested to see how I fare trying to use it outside the Arduino environment, so stay tuned for more projects soon (hopefully).
Grove Starter Kit
I was really impressed with this kit. It is a bit pricy but you get a lot of modules for that money and the ease of use can't be overstated. Wiring most 16x2 LCDs requires around ten wires and a big chunk of your available digital pins. The Grove LCD is four wires bundled with connectors and only requires plugging in both ends of said wire.
The one real issue I had with the kit is that it's only really useful as a prototyping platform. For one it would be expensive to replace the components, particularly the shield, with every project but the biggest problem is the way the components are assembled. Each one is assembled on a PCB that has built in mounting holes but no consideration was taken for how you could use them in a presentable way. The switch for example has the switch and wire plug on the same side of the board meaning there's really no way to mount it into a project while hiding the wiring and plug. The seemingly small change of putting the component and plug on opposite sides would increase the usefulness tenfold.
IoT Analytics Dashboard
While clearly in beta (v0.11 I believe), you can't easily delete components or clear data at all, this is still a really powerful tool and is easy to use, relative to setting something like this up on your own. Real-time data tracking, remote notifications, and, a feature I'm very interested in trying, the ability to use the gathered data as part of a feedback loop that can actually control the device.
Similar to the Edison, the documentation is spotty and mostly adapted from the Galileo and it seems like it's a bit of a side project for the employee's involved. I'd be interested to see if Intel or the community open this tool to other platforms because that would really be a step forward for the Internet of Things.
This essentially is a marketplace for people or hacker-spaces with additive manufacturing capabilities to rent the usage of their machines to local makers.This was my first time using the service and your mileage may vary based on a number of factors but I couldn't have been happier with the process or results. Models were easy to upload, although you may need to coordinate with your chosen hub on the units they should be exported in, and if you need to add, remove, or replace files before the job is started it's simple. Each order has a message area, almost like a chat, attached and you can even tie in support with a click of a button.
The downsides are are all what you'd expect from something relying entirely on community sourcing. Process, prices, materials, quality, and lead-times all vary wildly hub-to-hub and may not even be consistent over time. Living in a suburb of a major metro city means I was spoiled for choice and got a great deal that wasn't too far away but I imagine that is not the case everywhere. All hope is not lost if you live in the sticks as most hubs will ship, at a price of course. My international friends need not worry either as the service lists hubs worldwide.
Overall this is the first place I'll be looking for quick, 3rd party additive manufacturing in the future and if I ever make the leap into the tech myself I will probably look into starting a hub as well.
We have a be nice policy.
Please be positive and constructive.