how to use opendata, firefox os and a raspberry pi to build a better washing machine
TRANSCRIPT
![Page 1: How to use OpenData, Firefox OS and a Raspberry Pi to build a better Washing Machine](https://reader033.vdocuments.mx/reader033/viewer/2022042819/55c52882bb61ebdc158b465c/html5/thumbnails/1.jpg)
HOW TO USE OPENDATA, FIREFOXOS AND A RASPBERRY PI TO BUILD ABETTER WASHING MACHINE
André Fiedlermozillians.org/en-US/u/SunboX 2015-04-06
![Page 2: How to use OpenData, Firefox OS and a Raspberry Pi to build a better Washing Machine](https://reader033.vdocuments.mx/reader033/viewer/2022042819/55c52882bb61ebdc158b465c/html5/thumbnails/2.jpg)
Why a better washing machine?First, I wanted to learn a bit more about the current state of OpenData in Germany.
Second, I wanted to check out Firefox OS (FxOS) on Raspberry Pi (RPi) and running aweb server in pure JavaScript.
And last, current washing machines suck and are very inefficient.
2/27#FirefoxOSAndIoT
![Page 3: How to use OpenData, Firefox OS and a Raspberry Pi to build a better Washing Machine](https://reader033.vdocuments.mx/reader033/viewer/2022042819/55c52882bb61ebdc158b465c/html5/thumbnails/3.jpg)
How current washing works.Washing machines have to clean your laundry. If it’s dirty after washing no one would ever buy this machine again. To achieve this, washing machines
…and they don’t inform you when they did finish.
consume too much waterconsume too much energy / timeconsume too much detergent
···
3/27#FirefoxOSAndIoT
![Page 4: How to use OpenData, Firefox OS and a Raspberry Pi to build a better Washing Machine](https://reader033.vdocuments.mx/reader033/viewer/2022042819/55c52882bb61ebdc158b465c/html5/thumbnails/4.jpg)
Why do they use too much of all?(most) machines don’t know the weight of your laundrythey don’t know the water hardnessthey don’t know the type of detergent to usedetergent manufacturer trick you to overdose their detergents
····
4/27#FirefoxOSAndIoT
![Page 5: How to use OpenData, Firefox OS and a Raspberry Pi to build a better Washing Machine](https://reader033.vdocuments.mx/reader033/viewer/2022042819/55c52882bb61ebdc158b465c/html5/thumbnails/5.jpg)
How to fix this?using more data — OpenDatasmarter washing machines — Internet of Things (IoT)
··
5/27#FirefoxOSAndIoT
![Page 6: How to use OpenData, Firefox OS and a Raspberry Pi to build a better Washing Machine](https://reader033.vdocuments.mx/reader033/viewer/2022042819/55c52882bb61ebdc158b465c/html5/thumbnails/6.jpg)
Internet of Things?Smarter washing machines that automatically dose the detergent and water by usingOpenData and at the end using less energy.
Smarter washing machines that provide data, like used energy, used water, washingtime and all kind of stats so someone else could build up on this.
6/27#FirefoxOSAndIoT
![Page 7: How to use OpenData, Firefox OS and a Raspberry Pi to build a better Washing Machine](https://reader033.vdocuments.mx/reader033/viewer/2022042819/55c52882bb61ebdc158b465c/html5/thumbnails/7.jpg)
Using more dataMeasuring the weight is easy, but how about the water hardness and useddetergent?
7/27#FirefoxOSAndIoT
![Page 8: How to use OpenData, Firefox OS and a Raspberry Pi to build a better Washing Machine](https://reader033.vdocuments.mx/reader033/viewer/2022042819/55c52882bb61ebdc158b465c/html5/thumbnails/8.jpg)
OpenData to the rescueSince February 2014 there’s a initiative called „Code for Germany“
http://codefor.de
Volunteers work together with german city councils to digitalize open data and makeit easy accessible to everyone. A good example is the Open Data Lab Heilbronn. Theyput all their data on Github here https://github.com/opendata-heilbronn
8/27#FirefoxOSAndIoT
![Page 9: How to use OpenData, Firefox OS and a Raspberry Pi to build a better Washing Machine](https://reader033.vdocuments.mx/reader033/viewer/2022042819/55c52882bb61ebdc158b465c/html5/thumbnails/9.jpg)
I used their water data for my washing machine sample, by providing it through an API:
https://github.com/SunboX/fxos-washing-machine_water-api
This simple example shows how much OpenData can be used to make things better.Even if the people who opened this data to the public didn’t really know what it canbe used for. All cities have collected data about your water quality (and much more)— very few make it open. So „Code for Germany“ is really necessary to make all thepublic data accessible to everyone.
9/27#FirefoxOSAndIoT
![Page 10: How to use OpenData, Firefox OS and a Raspberry Pi to build a better Washing Machine](https://reader033.vdocuments.mx/reader033/viewer/2022042819/55c52882bb61ebdc158b465c/html5/thumbnails/10.jpg)
Ok, now we know the hardness of our water. But howabout the detergents?Same thing here, make it public available. Every detergent manufacturer prints it onthe packaging. But by now there’s no database containing this data.
Who want’s to build a website for collecting it? I’ve already a proposal how the APIcould look like: https://gist.github.com/SunboX/d688d76ff6ca7b1a2f24
10/27#FirefoxOSAndIoT
![Page 11: How to use OpenData, Firefox OS and a Raspberry Pi to build a better Washing Machine](https://reader033.vdocuments.mx/reader033/viewer/2022042819/55c52882bb61ebdc158b465c/html5/thumbnails/11.jpg)
So now we have enough data to work with, the really cool thing …
11/27#FirefoxOSAndIoT
![Page 12: How to use OpenData, Firefox OS and a Raspberry Pi to build a better Washing Machine](https://reader033.vdocuments.mx/reader033/viewer/2022042819/55c52882bb61ebdc158b465c/html5/thumbnails/12.jpg)
FIREFOX OS RUNNING ON ARASPBERRY PI
12/27#FirefoxOSAndIoT
![Page 13: How to use OpenData, Firefox OS and a Raspberry Pi to build a better Washing Machine](https://reader033.vdocuments.mx/reader033/viewer/2022042819/55c52882bb61ebdc158b465c/html5/thumbnails/13.jpg)
Firefox OS running on a Raspberry PiFirefox OS is great for rapid prototyping. It’s as easy as writing a web page.
There’s a wiki page about the current state of FxOS on RPi and some info about howto flash it onto your RPi: https://wiki.mozilla.org/Fxos_on_RaspberryPi
I’ve used a special build by Jan Jongboom who is currently working on improvedGPIO support. You can download this build from here:https://gist.github.com/janjongboom/94d575526a689687a6b8
13/27#FirefoxOSAndIoT
![Page 14: How to use OpenData, Firefox OS and a Raspberry Pi to build a better Washing Machine](https://reader033.vdocuments.mx/reader033/viewer/2022042819/55c52882bb61ebdc158b465c/html5/thumbnails/14.jpg)
How does it work?I’m running a stripped down version of FxOS called JanOS: http://janos.io/
It’s basically your RPi booting into a HTML page rendered by Gecko (FxOS).
14/27#FirefoxOSAndIoT
![Page 15: How to use OpenData, Firefox OS and a Raspberry Pi to build a better Washing Machine](https://reader033.vdocuments.mx/reader033/viewer/2022042819/55c52882bb61ebdc158b465c/html5/thumbnails/15.jpg)
The washing machine interface is all build using web technology. It’s controlled byan app running on a FxOS phone. The washing machine is providing a REST APIallowing the phone to talk to it. This REST API is running on a web serverimplemented in pure JavaScript.
15/27#FirefoxOSAndIoT
![Page 16: How to use OpenData, Firefox OS and a Raspberry Pi to build a better Washing Machine](https://reader033.vdocuments.mx/reader033/viewer/2022042819/55c52882bb61ebdc158b465c/html5/thumbnails/16.jpg)
Lets go into detail of this …
16/27#FirefoxOSAndIoT
![Page 17: How to use OpenData, Firefox OS and a Raspberry Pi to build a better Washing Machine](https://reader033.vdocuments.mx/reader033/viewer/2022042819/55c52882bb61ebdc158b465c/html5/thumbnails/17.jpg)
The washing machine interfaceYou can find the source code for the interface at:https://github.com/SunboX/fxos-washing-machine_interface
17/27#FirefoxOSAndIoT
![Page 18: How to use OpenData, Firefox OS and a Raspberry Pi to build a better Washing Machine](https://reader033.vdocuments.mx/reader033/viewer/2022042819/55c52882bb61ebdc158b465c/html5/thumbnails/18.jpg)
After the RPi did boot up it tries to automatically connect to wifi (which is pre-defined by now) and than it fires up the web server. The server implementation isbased on https://hacks.mozilla.org/2015/02/embedding-an-http-web-server-in-firefox-os/
wm.WashingApi = (function () { let wifiManager = navigator.mozWifiManager, lastIp, httpServer,
let init = function () {
if ('onconnectioninfoupdate' in wifiManager) { wifiManager.onconnectioninfoupdate = e => { if (e.ipAddress && lastIp !== e.ipAddress) {
httpServer = new HTTPServer(wm.Config.ApiServerPort);
18/27#FirefoxOSAndIoT
![Page 19: How to use OpenData, Firefox OS and a Raspberry Pi to build a better Washing Machine](https://reader033.vdocuments.mx/reader033/viewer/2022042819/55c52882bb61ebdc158b465c/html5/thumbnails/19.jpg)
The server provides a simple JSON REST API which is used to tell the washingmachine about water hardness and detergents, to start/stop the machine and forgetting stats.
httpServer.addEventListener('request', e => { e.response.headers['Content-Type'] = 'application/json; charset=utf-8'; switch (e.request.path) { case '/start': body = JSON.stringify({ success: wm.WashingProgram.start() }); break; case '/data/water-hardness': let programUuid = e.request.params.programUuid; let waterHardness = e.request.params.waterHardness; body = JSON.stringify({ success: wm.WashingProgram.setWaterHardness(programUuid, waterHardness) }); break;
19/27#FirefoxOSAndIoT
![Page 20: How to use OpenData, Firefox OS and a Raspberry Pi to build a better Washing Machine](https://reader033.vdocuments.mx/reader033/viewer/2022042819/55c52882bb61ebdc158b465c/html5/thumbnails/20.jpg)
If all data is collected and the start command was requested, the washing programwill be calculated and it starts a timer. Also a LED connected to the GPIO pins of theRPi begins to blink.
If this were a real machine, it should first automatically dose the detergents basedon the given data and after that start to run through the washing program.
20/27#FirefoxOSAndIoT
![Page 21: How to use OpenData, Firefox OS and a Raspberry Pi to build a better Washing Machine](https://reader033.vdocuments.mx/reader033/viewer/2022042819/55c52882bb61ebdc158b465c/html5/thumbnails/21.jpg)
How to blink the LED?… because blinking LED's is cool. ;o)
navigator.gpio.setPinMode(3, 'output').then(pin3 => { pin3.writeDigital(0);
let blinkValue = 0; let blink = () => { blinkValue ̂= 1; pin3.writeDigital(blinkValue); setTimeout(blink, 500); } wm.WashingProgram.addEventListener('start', e => { blink(); });
21/27#FirefoxOSAndIoT
![Page 22: How to use OpenData, Firefox OS and a Raspberry Pi to build a better Washing Machine](https://reader033.vdocuments.mx/reader033/viewer/2022042819/55c52882bb61ebdc158b465c/html5/thumbnails/22.jpg)
Next the app …
22/27#FirefoxOSAndIoT
![Page 23: How to use OpenData, Firefox OS and a Raspberry Pi to build a better Washing Machine](https://reader033.vdocuments.mx/reader033/viewer/2022042819/55c52882bb61ebdc158b465c/html5/thumbnails/23.jpg)
The washing machine appYou can find the source code for the app at:https://github.com/SunboX/fxos-washing-machine_app
The app will provide some open data like water hardness (after getting the currentlocation) and washing powder dosis to the washing machine.
23/27#FirefoxOSAndIoT
![Page 24: How to use OpenData, Firefox OS and a Raspberry Pi to build a better Washing Machine](https://reader033.vdocuments.mx/reader033/viewer/2022042819/55c52882bb61ebdc158b465c/html5/thumbnails/24.jpg)
So, what's next?
24/27#FirefoxOSAndIoT
![Page 25: How to use OpenData, Firefox OS and a Raspberry Pi to build a better Washing Machine](https://reader033.vdocuments.mx/reader033/viewer/2022042819/55c52882bb61ebdc158b465c/html5/thumbnails/25.jpg)
What's next?There are three points which can be worked on next:
Finishing the software — Interface & AppThe hardware — using real Sensors, maybe a real Washing Machine?OpenData webpage & API for collecton washing detergent dosis
···
25/27#FirefoxOSAndIoT
![Page 26: How to use OpenData, Firefox OS and a Raspberry Pi to build a better Washing Machine](https://reader033.vdocuments.mx/reader033/viewer/2022042819/55c52882bb61ebdc158b465c/html5/thumbnails/26.jpg)
Want to help?I'm looking for someone interested to help, or taking over the whole project if it fitsto him better.
I'm interested in a lot of things and this small „project“ was just meant to get meupdated about current state of OpenData, IoT and FxOS on RPi.
So if you want to get this further, plz help me or take it. :o) Otherwise I will (maybe)work on it from time to time.
26/27#FirefoxOSAndIoT
![Page 27: How to use OpenData, Firefox OS and a Raspberry Pi to build a better Washing Machine](https://reader033.vdocuments.mx/reader033/viewer/2022042819/55c52882bb61ebdc158b465c/html5/thumbnails/27.jpg)
<Thank You!>contact: [email protected]
twitter @sonnenkiste github github.com/SunboX linkedin linkedin.com/profile/view?id=226588234 g+ plus.google.com/116509237159086833815