Slide 1

Slide 1 text

Doorbell Ringer An intentionally complex IoT project by Ates Goral

Slide 2

Slide 2 text

@atesgoral http://magnetiq.com

Slide 3

Slide 3 text

http://myplanet.com

Slide 4

Slide 4 text

In the beginning there was...

Slide 5

Slide 5 text

Onion Omega Invention Platform for IoT

Slide 6

Slide 6 text

No content

Slide 7

Slide 7 text

Onion Omega Dimensions: 28.2mm x 42mm (1.1" x 1.7") CPU: Atheros AR9331 400MHZ MIPS 24K RAM: 64MB DDR2 400MHz Flash: 16MB WiFi: 802.11b/g/n 150Mbps Ethernet: 100Mbps GPIO: 18 USB: USB 2.0, Supports additional USB Hub Power: 3.3V Antenna: PCB Antenna w/ uFL Connector Power Consumption: 0.6W

Slide 8

Slide 8 text

No content

Slide 9

Slide 9 text

No project ideas.

Slide 10

Slide 10 text

Then there was...

Slide 11

Slide 11 text

No content

Slide 12

Slide 12 text

Heath Zenith DL- 6505 Wireless Battery-Operated Door Chime Kit

Slide 13

Slide 13 text

Wireless Doorbell “Piece of junk” —GeorgeC “Simply does NOT perform” —jtreader “Avoid this product” —Julian “Worthless Door bell” —decodenise “Worked one hot second after installed” —NotWorking “Over priced paper weight” — Straightline22

Slide 14

Slide 14 text

The aha! moment

Slide 15

Slide 15 text

No content

Slide 16

Slide 16 text

Earlier…

Slide 17

Slide 17 text

No content

Slide 18

Slide 18 text

No content

Slide 19

Slide 19 text

Prototype Circuit ● Using a single GPIO pin ● Over an 4N35 optocoupler ● Setting the GPIO pin output to HIGH “presses” the button ● Button sends a RF signal to the doorbell to ring it

Slide 20

Slide 20 text

No content

Slide 21

Slide 21 text

But, if this were to be real doorbell… ● Visitors cannot connect through USB and type commands ● Would be silly to add a new button to tell Omega to tell the old button to ring the doorbell

Slide 22

Slide 22 text

IoT to the rescue! ● The natural path is to trigger the button via WiFi ● But, the Omega is behind a NAT on my WiFi at home ● Decided to run a client and not a server on the Omega

Slide 23

Slide 23 text

Then tried...

Slide 24

Slide 24 text

PubNub Always-on communication layer

Slide 25

Slide 25 text

But, couldn’t install the SDK ● Had a plethora of options: Node.js, Python, Perl… ● Tried Node.js and Python, ran into compilation issues and gave up

Slide 26

Slide 26 text

Then was recommended...

Slide 27

Slide 27 text

Twitter

Slide 28

Slide 28 text

Doorbell Ringer ● Python script, running as a daemon via /etc/init.d ● Uses Twitter API ● Watches live user stream of @DoorbellRinger ● Rings the bell when it sees “#ringit”

Slide 29

Slide 29 text

Still, if this were to be real doorbell… ● Not convenient for visitors to tweet ● Don’t want my doorbell to ring at 3am

Slide 30

Slide 30 text

Need a local trigger that is not a physical button ● Thought about using QR codes ● Visitor scans a QR code, is taken to a URL that tweets on behalf of the visitor ● Already had an OLED display for my Omega ● The same good friend recommended that I use TOTP for token generation -- what Google Authenticator uses

Slide 31

Slide 31 text

No content

Slide 32

Slide 32 text

Another display? ● Bigger, faster OLED ● LED ● E-paper

Slide 33

Slide 33 text

Then I remembered...

Slide 34

Slide 34 text

HTC Magic 2009

Slide 35

Slide 35 text

Doorbell Nudger ● Node.js server running on Heroku ● Generating TOTP tokens every 30 seconds ● Shows QR code image + token value + timer ● QR code encodes a callback URL ● Callback tweets as @DoorbellNudger ● Curious hack to avoid adding an API: piggyback token value as a cookie in the image response

Slide 36

Slide 36 text

Hardware upgrade...

Slide 37

Slide 37 text

No content

Slide 38

Slide 38 text

No content

Slide 39

Slide 39 text

No content

Slide 40

Slide 40 text

No content

Slide 41

Slide 41 text

Some DevOps overkill

Slide 42

Slide 42 text

Going the extra mile… ● Vagrant box with OpenWRT image for local development ● Travis CI runs Python tests, ● Calls webhook on Heroku when tests pass, ● Which in turn results in a tweet from @DoorbellNudger with #update ● Which in turn prompts the Python service on Omega to self-update from GitHub

Slide 43

Slide 43 text

BUT SRSLY, WHY?!?!1

Slide 44

Slide 44 text

Play! ● Apply skills that you use for “serious” work to “silly” projects to hone your skills ● Problem solving is fun, so invent new problems ● You don’t need a serious/real project to start experimenting with new stuff - just do silly things ● End-to-end, planned execution practice ● Pleasure of getting multiple moving parts working together ● Conversation starter (or ender) ● Fun

Slide 45

Slide 45 text

New things that I’ve learned/done about in this project Optocouplers, OpenWRT (ubus, opkg, uci), Twitter API, TOTP, QR codes, Python (virtualenv, unittest), Travis CI webhooks, /etc/init.d scripts, Onion relay expansion, using USB storage as rootfs, animating a countdown pie chart in , plus more I’m probably forgetting to appreciate.

Slide 46

Slide 46 text

Links, Q&A

Slide 47

Slide 47 text

Links ● @atesgoral - http://magnetiq.com ● @DoorbellRinger - https://github.com/atesgoral/doorbell- ringer ● @DoorbellNudger - https://github.com/atesgoral/doorbell- nudger ● @OnionIoT - https://onion.io/product/omega/ ● GitHub - https://github.com/atesgoral/ ● LinkedIn - https://www.linkedin.com/in/atesgoral