Data Donderdag - Making your own smart ‘machine learning’ thermostat

Download Data Donderdag - Making your own smart ‘machine learning’ thermostat

Post on 12-Apr-2017

365 views

Category:

Devices & Hardware

0 download

Embed Size (px)

TRANSCRIPT

PowerPoint Presentation

Making your own smart machine learning thermostat Data Donderdag 19 november 2015 Niek Temme

personal project you can see the result in the picutremostley learning project And you see it does not look as sleek as a nest or other smart thermostat that you can buyNOT A GOOD PROGRAMMER and electrical engineer ;-)Does result to a working self learning thermostat

But this isPersonal Journey into the Internet of Thins (in short IOT)IoT persentation cisco (in short: connected devices, clich fridge, cars, termostats, carage dors)But also Farm equipment

- Started my career with web development Move to Business Intelligence (I am often involved in creating dashboards like this, ore preparing)Just an example dashboard from the internetFrom talking to a couple of people in earlier meetups more people here work in this field

Interest in IoT Combination of data with consumer facing technology of web next to the verry intressting data from sensors

Stephen few

1

Arduino+XBeeRaspPI+XBeeAWSHBaseSparkBoiler

Quirky needs your Wink Hub back after a botched security update- CNET -18 50 billion connected devices by 2020- Gartner, IDC, Cisco -

devicehubcloud

- In project (scematic shown)Tried to incorportate actual use cases and technology

On the left is the boiler Furnace and boiler interchangeably Heating system based on radiators and hot water (I believe boiler is used as correct therm)Furnace most common American termTolled by my wife (who is American), but I believe furnace is used for forced air (I believe most common in the US)

Then there is the device in this case the thermostat with sensors and control of the boiler (explain boiler)Explain arduini and raspberry pi (experimentation and teaching devices)Device sends using xbee (phillips HUE)HUB (why and issues), sends to cloud, GE backed (recall possibley all, 100.000 units)Cloud relates to the clich of IOT (lots of devices = lots of data)

For every person living on earth, there will be at least 2, maybe even 6 connected things by 2020.Up from 5 billion devices now

Car security came later

2

Arduino+XBeeRaspPI+XBeeAWSHBaseSparkBoiler

Quirky needs your Wink Hub back after a botched security update- CNET -18 50 billion connected devices by 2020- Gartner, IDC, Cisco -

devicehubcloud

DeviceConnectionCloud

- Storage

- Analitics

How Smart, Connected Products Are Transforming CompaniesMichael E. Porter James E. Heppelmann

oktober 2015

EXPLAIN AFTER INTRODUCTION

In project (scematic shown)Tried to incorportate actual use cases and technologyFirst device with sensors and control of the boiler (explain boiler)Explain arduini and raspberry pi (experimentation and teaching devices)Device sends using xbee (phillips HUE)HUB (why and issues), sends to cloudCloud (lots of devices = lots of data0

Furnace and boiler interchangeably Heating system based on radiators and hot water (I believe boiler is used as correct therm)Furnace most common American termTolled by my wife (who is American), but I believe furnace is used for forced air (I believe most common in the US)

For every person living on earth, there will be at least 2, maybe even 6 connected things by 2020.

Car security came later

3

The device

Bought a House (apartement) december 2014I did not know how it workedOnley knew 24v on off thermostat (not openterm, modulating)Could have looked this upBut data drivven aproach.4

2341

Now to prove that I did write some codeHighlight some of the issues I encoutered4 step proces1 read sensor value 2 calcalute tembareature 3 prepare string to send 4 send value

C programmingWhere do you calculate temparature values from censor volt valuesNo OTA (little bit with philips hue (hardware), but more issue in security I believe car)After Jeep Hack, Chrysler Recalls 1.4M Vehicles for Bug FixData schema works through the chain

5

2341

A01_1933A01_1933A01_1982A01_1982A01_1933A01_1884A01_1933A01_1982A01_193340b5af00_rx000A01_8574094222_9670832 column=fd:cd, timestamp=1425905812807, value=193340b5af00_rx000A01_8574094222_9796804 column=fd:cd, timestamp=1425905812807, value=193340b5af00_rx000A01_8574094222_9919598 column=fd:cd, timestamp=1425905812807, value=198240b5af00_rx000A01_8574094223_9043289 column=fd:cd, timestamp=1425905812807, value=198240b5af00_rx000A01_8574094223_9166720 column=fd:cd, timestamp=1425905812807, value=193340b5af00_rx000A01_8574094223_9294077 column=fd:cd, timestamp=1425905812807, value=188440b5af00_rx000A01_8574094223_9416375 column=fd:cd, timestamp=1425905812807, value=193340b5af00_rx000A01_8574094223_9540631 column=fd:cd, timestamp=1425905812807, value=198240b5af00_rx000A01_8574094223_9669088 column=fd:cd, timestamp=1425905812807, value=1933

Reverse to easily see last inserted timestampInsert all values with higher timestampCarefully thing about data structure and scema eraly on (counter intuitive to other big data aspects just collect)

6

Connection & Storage

3 sensors1000 values per scecondIn one year

31 bilion rows

+/- 800GB

How quickly it gets bigOriginally relational databaseAt 1000 records per scecond: 31 bilion rows +/- 800GB. Just one person100.000 customers almost 80PB a year (just for 3 sensors)1000.0000 customers almost an exabyte (1 biljon GB) per yearCompressesion brigs that down to 80GB or 10 years of data at the lowest level of detaul

Open TimeSeries Database (ased on HBASE)Used by yahoo, ebay, pintrest, ticketmasterRow key desing (device + port)- What I have as storage. At AmazonLZO + fast diff row key encoding (duplicate partial row key)Of course aggregation would be easier. Thrift (binary rest) over ssh2 minutes connection down without data loss

7

?Analytics

First part was insightHow does a thermostat work8

increasemaintain

612345123456Smart Temp - Sensor value - 2015-03-19

Looking at dataAlways 6 times per hourAgain Could have looked this up (now I know this usually is a setting)Difference in the number of minutes boiler was turned onThis clearly highilits data to understand how a device is working

9

Making it smart

00:0000:1000:3000:2000:4000:5001:006 min5 min4 min3 min2 min2 min

Explain PatternIn 1 hour 6 intervals of 10 minutesIn each interval of 10 minutes the boiler heats the water for X amout of minutesIn this example (tipical pattern for increasing the temperature of the room)First interval boiler is on for 6 minutes, second interval 5 minutes, third 4 etc.

10

Making it smart

Learning part in the thermostat I build: what pattern is best to use in a certain cenarioFor example in a cerntain cenario it might be better to have loger bursts of water heating so the boiler can stay of at certain intervalsStaying off is more efficientSenario here is inside and outside temperature

11

Scorescore =( [number of times boiler goes on] * 10 * 60 ) +( [total minutes boiler is on] * 2 ) +( absolute( [maximum reached temperature] [set temperature] ) ) +( if([overshoot]=true ) then 3600 else 0 )

Penalty pointsIt of course would be better to measue actual gass usage did not get to that(problem is in weighing different variables in the formula)12

00:0000:1000:3000:2000:4000:5001:004 min4 min4 min3 min3 min2 min

00:0000:1000:3000:2000:4000:5001:002 min2 min2 minoffoffoffscenariotempdif: 7 outempdif: 8 initialimprovedk-means clustering

Final partResult in learing pattern greatly reduces both in how often on as how Machine learningCreates customn optimization for my house (does not overshoot)

Spark chosen to gain experience + spark works with hbase + spark has example machine learning library for clusteringDistributed and in memmoryOverkill (16 seconds) I onley have one node13

Thank youquestions or feedback?

http://niektemme.com/2015/08/09/smart-thermostat/

niektemme@gmail.com

@niektemmelinkedin.com/in/niektemme

14

Extra slides

15

16

DUPLO AND WASHI TAPE

Problem expected 24 voltLed and photocell next to each otherOnly problem was my daughter requesting her duplo backEspecially because it was red, red had best result

Recitfier (diode bridge) + capacitator to prevent flickering as much as posibleBoiler shown as a 21

Threa mesuresto improve aquracy3.3V + refbetter sensors (enclosed + precision)Roling avarage (5 seconds next part rapsberry PI)

Tried digital sensor (dallas bus) I believe recommended in the openthermostat project I noticed delay. Not sure this is correct 22

Final breadboard layoutJust to show the result wont go into detailLCD takes most the wireingOn the left you see the diode bridge23

- Top shows boiler onSunlightProblem with temperatureA) fluctuates B) no correlation24

Highlight of the ardiuno code to use a thermistor- To how dad I did acutally program something - Used from adafruit25

1000 values per second

Why 1000?

Solved with in-memory database

Arduino+XBeeRaspPI+XBeeAWSHBaseSparkBoiler

234567

Arduino to Raspberry PI1000 story predictive maintenanceNo reason 1000Storage using relatonal database what I am used to Could not receive at this rate (python + sqllite)Solved with in memory databaseIn practice no more then 20 per second and down to 10 per second bi directional transforXBEee not capable of sending at this frequency. Trying to put more values in one payload.12 values per payload could increase