Sketching with Hardware 2012 5/6 – PEO – Personal Energy Orb

In August, our workshop “Sketching with Hardware” took place for the 6th time. In 7 days, 12 students learnt to use electronic components, to create new creative user interactions and realized their own physical computing projects. The overarching topic for this course was ”Outdoor Electronics”. Again, at the final presentation the crowd had the chance to experience six extraordinary experience prototypes. During the following days, all projects will be presented on this blog. Today: Part 5, PEO – Personal Energy Orb! Have fun 🙂

PEO is a little energy device that limits your computer usage time to a value generated from the distance you traveled with your bicycle in advance. It raises awareness for the amount of time spent in front of computers nowadays and forces its users to seek physical exercise in compensation for their „screen hours“.

The Idea

the concept poster

The excessive use of computers is a common problem in todays connected world. Many jobs require the use of personal computers throughout the work day and also our spare time is frequently spent at home in front of computers or similar technical devices, whereas our time spent on physical activities decreases. This can lead to a lack of social interaction and can ultimately cause health problems.

While it is not possible to simply reduce the time of computer use for anyone, e.g. computer scientists, a way of mitigating this problem is to find the right balance between computer use and physical exercise. However, as is generally known, regular sportive activities require a certain level of self-control, therefore our idea was to create something that supports people with keeping that balance between computer use and being outside and doing sports.

The Scope

Following the topic of the course „outdoor electronics“, PEO is mobile and even encourages its users to go outside and rewards exercise with a raising energy level. Furthermore, PEO combines the two subtopics „distance“ and „energy awareness“:

  • Distance: The distance you travel with your bike has a direct impact as it increases your virtual energy level
  • Energy Awareness: The virtual energy level serves as a metaphor for time as a limited resource that is wasted in front of a computer which should rather be used more consciously.

The Interaction

PEO allows no direct interaction, but can be influenced in two ways:

  • By using the computer with PEO connected, PEO’s energy level is constantly decreased
  • When riding your bicycle with PEO attached, its energy level can be increased again

Trough color and luminosity change, PEO provides visual feedback about its energy level as well as the mode it currently is in (for a detailed explanation, see next paragraph “Technical realization“). A more precise feedback on the energy level change can be achieved by using the PC application. When PEO’s energy decreases, it slows down the mouse speed of the computer it is connected to. At zero percent, the mouse speed is set to the slowest possible mouse speed on Windows computers. While at this speed it is not entirely impossible to work, operating your PC becomes so annoying that you will want to stop using your computer and recharge your PEO again.

PEO’s color represents its current energy level (red = low energy).

The PC software shows the exact energy level.

Technical realization

PEO contains an Arduino (Uno) programmed to be in one of three states:

    1. Connected to the bike:PEO knows that it is connected to the bike thanks to a reed switch in its base plate. The bike mount holds three magnets that serve two purposes:
      • They hold the PEO in place when attached to the mount
      • They activate the reed switch connected to an input pin of the Arduino, so that it knows that the orb is connected to the bike.

When connected to the bike, PEO keeps glowing all the time. That serves as feedback that it is connected correctly and shows the current energy level so that changes can be seen without delay. Only in bike mode, the Arduino will listen to input from the revolution counter on the bike. The internal energy level is increased with every revolution of the wheel and PEO changes its color to represent the current energy level.

  1. Connected to the PC: When connected to the PC, PEO is powered by current from the USB port instead of its built-in battery. On the PC a little python program pings the Arduino in a short time interval over a serial connection. The Arduino checks for incoming messages and sends an answer back when it receives a ping. This ensures that Arduino and PC know that they are connected to each other. Both will switch to the “disconnected” state when they don’t receive messages for more than a few seconds. While the PEO is connected to the PC, the lights stay on all the time. The PC program sends a message to the Arduino every few seconds to decrease its energy level. The Arduino then sends back its updated energy level so that it can be shown in the energy level monitor application on the PC.
  2. Idle: PEO changes to this state when it’s neither connected to the bike nor to the PC. To save energy, the lights inside won’t stay on all the time, but will flash every few seconds to show the energy level.

To prevent a loss of your current energy level when the battery runs empty, PEO automatically saves its energy level to the non-volatile EEPROM of its integrated Arduino and restores it on restart.

The Circuit

PEO’s circuit (made with Fritzing)

The Code

Arduino Sketch

Python Program

Problems encountered

In its first draft, PEO was intended to consist of two orbs instead of one. One smaller orb should be kept attached to the bike and the bigger one to the PC at home. The idea was to only carry the smaller one to your PC to recharge the bigger one. Therefore we built two orbs at first, the first one with the bike logic integrated and the second one with the PC logic. We were looking into ways to transfer the data between both orbs without wires. That is why we chose to use XBees because they seemed like a good compromise between complexity and possibilities. Both Arduinos inside the orbs had XBee wireless transmitters connected to them to exchange the energy level.

While we were able to get the XBees and the energy level transmission working, it turned out to be impossible to use the serial connection of the Arduino for both the XBee transmission and the transmission to the python program on the PC at the same time, because the XBee constantly interfered with the serial communication to the PC. After over one day of trying we decided to drop the wireless aspect and put everything into one orb.

At the day of the final presentation, we got everything running right on time, but realized that two minutes before the presentation, PEO’s battery ran empty, although we exchanged it with a new one two hours before. Apparently the Arduino needs at least 7V when connected to the external power supply. Fortunately we could power it over USB instead, but still that was a pity, because we therefore needed to keep it close to the laptop and people could not drive around and try the recharging process as we intended.


Prototypes & Project Progress

Final Project


Good looking Web interfaces for Arduino with Python

Designing a GUI for a project is always problematic. There are hundreds of different toolkits to create GUIs but learning them takes a lot of time. A very simple way to quickly create a nice looking interface to your Arduino project is pybottle.

Pybottle is a micro web-framework that simplifies creating a small website. Combined with pyserial to read Arduino output from the COM port this is a good way to prototype your GUI. We used it for PEO’s energy level monitor application in the PC.

import bottle
from bottle import static_file

def index():
return open('./html/index.html','r')

This small peace of code already serves you the index.html file. The standard pybottle server starts on port 8080 so this page is accessible on http://localhost:8080/.

If your site contains images and other resources you should define a static_filepath:

def static(filepath):
return static_file(filepath, root='./html/')

@bottle.route also allows you to directly return JSON like objects by adding key, value pairs to a dictionary.

def getArduino():
dic = {}
dic['sensor1'] = sensor1
return dic

Now for the tricky bit. The Pybottle server is running in an endless loop this means that if we want to continuously read the sensor values from an Arduino we need
a separate thread.

First we need additional modules:

import sys, threading, time, os, signal, operator

And a little helper class:

class MyThread(threading.Thread):
def __init__(self, target, *args):
threading.Thread.__init__(self, target=target, args=args)

In this thread we have another endless loop that reads from the COM port and updates the sensor values.

def arduino_serial_connection():
global credits

while running:
serial_connection = serial.Serial(mySerialPort,9600)
line = serial_connection.readline()
print line
except SerialException, e:
print e


To update the value on the HTML page we can use a simple jquery javascript function.

<script type="text/javascript">// <![CDATA[
var allVals = []; function getArduinoValue(){ $.getJSON('/arduino/', function(data){ if(data.credits >=0) {

// ]]></script>

Just add your favorite HTML-Template a little bit CSS magic and presto you have a nice looking web interface for your Arduino.

A complete example can be found here.


Kommentar verfassen

Trage deine Daten unten ein oder klicke ein Icon um dich einzuloggen:

Du kommentierst mit Deinem Abmelden / Ändern )


Du kommentierst mit Deinem Twitter-Konto. Abmelden / Ändern )


Du kommentierst mit Deinem Facebook-Konto. Abmelden / Ändern )

Google+ Foto

Du kommentierst mit Deinem Google+-Konto. Abmelden / Ändern )

Verbinde mit %s