As an example of how the Open Energy Playground can be used, we hosted an epic vacuum cleaner battle!
This page describes the details of how this was achieved.
- 2 Vacuum cleaners (any with a cord will do)
- 2 Yanzi smart plugs (for energy measurement)
- 1 Yanzi radio
- 2 Plugwise Circle plugs (for on/off control)
- 1 Plugwise Circle+ plug (Looks like a normal plugwise circle plug, but with a grey backside)
- 1 Plugwise USB-stick
- 2 Fibaro wall plugs
- 1 Raspberry Pi 2 (with power adapter, memory card and network cable)
- 1 Programmable LED strip
- 1 Photon to connect to the LED strip
- 1 HUGE red button
1 Photon to connect to the HUGE red button
- 1 Multiple socket power strip
- 1 Router, we used the RT-N66U
- 1 Computer to configure everything with :)
You should be able to achieve the same things with just one brand of smart plugs, but we used all three just to show that there are alternatives!
All the code is running on the Raspberry Pi, which is using parts of the Pi version of the Open Energy Playground.
A point is calculated like this:
Measurement is wirelessly transmitted to Raspberry Pi
Measurement is converted to an MQTT message and sent to broker, broker relayes message to all clients subscribed to the power measurement topic
Message comes in to node-RED script that compares is to previous messages, script determines that power has decreased significantly in the last measurements
**** Script awards point ****
Script constructs a new MQTT message with new score, message is sent to MQTT broker, broker relayes message to all clients subscribed to the score count topic
New score count message is wirelessly transmitted to Photon
Photon updates the number of LEDs lit up
Point visible to the roaring audience
Raspberry Pi setup
The Raspberry Pi server is running parts of the Open Energy Playground, all running inside Docker containers.
For details on running the Open Energy Playground on Raspberry pi see Open Energy on Raspberry Pi
All the code is running on the server is available on Github - Vacuuum Battle.
docker-compose.yml file, we can see the containers used.
- InfluxDB is a time-series database, where we store all the sensor data. For details on this see Store data in database
- Mosquitto is an MQTT message broker.
- Node-RED is a graphical programming environment. For an intro of how to use this together with Mosquitto, see This tutorial
- Omxplayer is a tiny image that we put together that listenes to an MQTT topic, and plays a sound when a message is received. op-en/rpi-omxplayer
Because IoT is still in it's infancy, the market hasn't stabilized on one way to transmit wireless data with minimal power.
Therefore, the smart plugs that we use all use a different network protocol. The protocols all have their different advantages and disadvantages, and which one comes out dominant in the end is anyones guess.
Setting up the battleground
Collect all the components needed in the list above.
Plug in the Circle+ in the main power outlet that you will use, so that it is never disconnected, and all power goes through the plug. This special type of Plugwise plug relayes messages from the normal Circle plugs to the USB-stick that we will connect to the Raspberry Pi. By making sure it is always connected to power, we stabilize the plugwise message pipe.
Find a place where you want the fight to happen. Tape a "fighting box" on the ground perhaps?
Make two stacks from the 3 types of smart plugs, so that they are connected:
Connect the HUGE red button to power.
Connect the LED power strip to power.
Power the Raspberry Pi, connect the network cable from the Pi to a LAN port on the router and plug in the Plugwise USB-Stick and Yanzi Radio.
Connect the Router to power.
Configure the router so that it sets up a local network (skip this step if you have used this router for battle before)
Optional. Connect the router to the internet. How you do this can vary depending on where you are, but you usually either: 1. Connect the WAN port to another ethernet port already connected to the internet, 2. Bridge the connection from your computer to the router. (Note. if you do this, you will require another computer that is connected only to the local router network to access the Raspberry Pi)
Connect to the local network with your computer.
Now we will access the Raspberry Pi over ssh so that we can control it. We start by figuring out the ip-adress of the raspberry pi. Run a network scan in the terminal of your computer:
nmap -sn 192.168.2.0/24
This will show something like:
Starting Nmap 7.00 ( https://nmap.org ) at 2016-08-26 10:34 CEST Nmap scan report for 192.168.2.1 Host is up (0.0026s latency). Nmap scan report for 192.168.2.172 Host is up (0.0037s latency). Nmap scan report for 192.168.2.235 Host is up (0.045s latency). Nmap done: 256 IP addresses (3 hosts up) scanned in 16.05 seconds
Based on experience, testing, luck and knowing your own IP adress, we figure out that the IP adress of the Pi is
Connect to the Pi over ssh:
Download the code to the vacuum battle, if you haven't already.
git clone https://github.com/op-en/vacuum-battle.git
Start all the programs running on the Raspberry Pi:
cd vacuum-battle docker-compose up -d
Start the Yanzi border router and device server (these instructions will be special for everyone so can't give much guidance here, sorry)
When everything is started, the control interface is available at
- The vacuum cleaners should always be on. The plugwise plug turns them off.
- We use a static IP to the router to simplify things. If you share internet to the router, you may encounter ip conflicts that have to be solved. If possible try to configure the network so that the router remains at
192.168.2.235. If you cannot achieve this, some parts of the system may not work as expected. If a part is not connected to the network, it may have a hard coded ip adress somewhere in it's code.
- Theoretically, everything except the Photons work on a local network that is not connected to the internet. The photons are the only thing that require an internet connection to start. (note: replace with something that doesn't require internet? like an arduino)