Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

of

Outsmarting the smart meter (UtrechtJUG) Slide 1 Outsmarting the smart meter (UtrechtJUG) Slide 2 Outsmarting the smart meter (UtrechtJUG) Slide 3 Outsmarting the smart meter (UtrechtJUG) Slide 4 Outsmarting the smart meter (UtrechtJUG) Slide 5 Outsmarting the smart meter (UtrechtJUG) Slide 6 Outsmarting the smart meter (UtrechtJUG) Slide 7 Outsmarting the smart meter (UtrechtJUG) Slide 8 Outsmarting the smart meter (UtrechtJUG) Slide 9 Outsmarting the smart meter (UtrechtJUG) Slide 10 Outsmarting the smart meter (UtrechtJUG) Slide 11 Outsmarting the smart meter (UtrechtJUG) Slide 12 Outsmarting the smart meter (UtrechtJUG) Slide 13 Outsmarting the smart meter (UtrechtJUG) Slide 14 Outsmarting the smart meter (UtrechtJUG) Slide 15 Outsmarting the smart meter (UtrechtJUG) Slide 16 Outsmarting the smart meter (UtrechtJUG) Slide 17 Outsmarting the smart meter (UtrechtJUG) Slide 18 Outsmarting the smart meter (UtrechtJUG) Slide 19 Outsmarting the smart meter (UtrechtJUG) Slide 20 Outsmarting the smart meter (UtrechtJUG) Slide 21 Outsmarting the smart meter (UtrechtJUG) Slide 22 Outsmarting the smart meter (UtrechtJUG) Slide 23 Outsmarting the smart meter (UtrechtJUG) Slide 24 Outsmarting the smart meter (UtrechtJUG) Slide 25 Outsmarting the smart meter (UtrechtJUG) Slide 26
Upcoming SlideShare
What to Upload to SlideShare
Next
Download to read offline and view in fullscreen.

0 Likes

Share

Download to read offline

Outsmarting the smart meter (UtrechtJUG)

Download to read offline

It all started when I got my new energy meter... It was supposed to be smart, but turned out to be rather dumb. So I tried to make it a little bit smarter. How hard could that be? Well, it certainly wasn't easy, but it was fun to do! I'll take you on a trip that started with curiosity and ended with a nice home-made solution to read my energy meter. Don't be scared, you don't need any knowledge on Scala, Akka or React, we'll cover everything that is needed.

Related Books

Free with a 30 day trial from Scribd

See all

Related Audiobooks

Free with a 30 day trial from Scribd

See all
  • Be the first to like this

Outsmarting the smart meter (UtrechtJUG)

  1. 1. Outsmarting your Smart Meter UtrechtJUG // October 27, 2017 Maarten Mulders
  2. 2. Maarten Mulders @mthmulders architect | lead software engineer | trainer | speaker  
  3. 3. What's Up? Background Connecting the Smart Meter Building a Dashboard Questions
  4. 4.  
  5. 5.  
  6. 6.   Connecting the Smart Meter Pin # Signal name Description 1 +5 V Power supply 2 Request Input 3 Data GND Ground 4 not connected 5 Data Output 6 Power GND Power supply
  7. 7. Reading data eBay shopping list 1. RJ11-to USB female 2. USB male-to-male Total: $ 4.08 (€ 3.50) incl. shipping
  8. 8. Reading data $ cu -l /dev/ttyUSB0 -s 115200 --parity=none Connected. /KFM5KAIFA-METER 1-3:0.2.8(42) 0-0:1.0.0(160416112854S) ... ... !4016 ~. Disconnected.
  9. 9. Interpreting data identi cation: vendor-speci c, not speci ed data: CRC16-checksum over / to ! /???5<identification> <data> (repeated) !<CRC> OBIS-reference(value)
  10. 10. Parsing data This is easily parsed with Scala's parser combinators   Input: Parser: 000635.311 def number = """d*.?d*""".r ^^ { BigDecimal(_) }
  11. 11. Parsing data (ctd) This is easily parsed with Scala's parser combinators   Input: Parser: 1-0:1.8.1(000635.311*kWh) def elecCons1 = "1-0:1.8.1(" ~> """d*.?d*""".r <~ "*kWh)" ^^ { BigDecimal(_) }
  12. 12. Parsing data (ctd) This is easily parsed with Scala's parser combinators def make = "/" ~> "[A-Za-z0-9]{3}".r ^^ { String(_) } def identification = "5" ~> ".*".r ^^ { String(_) } def header = make ~ identification ^^ { case make ~ identification => P1Header(make, identification) }
  13. 13. Parsing data (ctd) This is easily parsed with Scala's parser combinators private def telegram = header ~ metadata ~ data ~ checksum private def parser: Parser[P1Telegram] = telegram ^^ { case header ~ metadata ~ data ~ checksum => P1Telegram(header, metadata, data, checksum) } | failure("Not all required lines are found")
  14. 14. Architecture Smart Meter Hyperion      raw      data Database      historical            records       Client (web)      live data &       historical record
  15. 15. Hyperion (1)  Collecting Actor          #append(...) P1 Parser     #parseTelegram()           Message Distributor           TelegramReceived (telegram) IO(Serial)       Serial.Received (bytes)
  16. 16. Hyperion (2)    Client (Browser)     Http         HTTP & WebSockets     RecentHistoryActor               GetRecentHistory                RecentReadings         ActualValuesHandlerActor       (Akka Streams)    DailyHistoryActor             RetrieveMeterReading            RetrievedMeterReading         StateTimeout     Message Distributor           RegisterReceiver         TelegramReceived     (telegram)              RegisterReceiver         TelegramReceived (telegram)           RegisterReceiver      TelegramReceived (telegram)
  17. 17. Web Dashboard Separate ui and data Single page app Small components (UI and logic)
  18. 18. ES6 classes class CurrentReadingsService { constructor() { const hostname = config.apiLocation(); this.base_url = `wss://${hostname}/api/actual`; } connect(cb) { this.ws = new WebSocket(this.base_url); this.ws.onmessage = (message) => cb(JSON.parse(message.data)); } disconnect() { this.ws.close(); } } export default new CurrentReadingsService();
  19. 19. React Components (1) class CurrentReadingsPage extends React.Component { componentDidMount() { currentReadingsService.connect((data) => { this.setState({ currentReading: data, }); }); } componentWillUnmount() { currentReadingsService.disconnect(); } // continued... }
  20. 20. React Components (2) class CurrentReadingsPage extends React.Component { // continued... render() { const makeRow = (label, value) => (<Row> <Col lg={ 6 }><strong>{ label }</strong></Col> <Col lg={ 6 }>{ value }</Col> </Row>); return (<Grid> { makeRow("Last updated", formattingService.formatDateFull(ts)) } { makeRow("Electricity consumption", formattingService.formatNumberPower(consumption)) } { makeRow("Electricity production", formattingService.formatNumberPower(production)) } { gas ? makeRow("Gas meter", formattingService.formatNumberGas(gas)) : null } { makeRow("Current tariff", tariff) } </Grid>); } }
  21. 21.  
  22. 22. What's Going On? (1)
  23. 23. What's Going On? (1)
  24. 24. What's Going On? (2)
  25. 25. What's Going On? (2)
  26. 26. Questions?

It all started when I got my new energy meter... It was supposed to be smart, but turned out to be rather dumb. So I tried to make it a little bit smarter. How hard could that be? Well, it certainly wasn't easy, but it was fun to do! I'll take you on a trip that started with curiosity and ended with a nice home-made solution to read my energy meter. Don't be scared, you don't need any knowledge on Scala, Akka or React, we'll cover everything that is needed.

Views

Total views

264

On Slideshare

0

From embeds

0

Number of embeds

3

Actions

Downloads

0

Shares

0

Comments

0

Likes

0

×