Upgrade to Pro — share decks privately, control downloads, hide ads and more …

How I accidentally made a dimmer switch

Sponsored · Ship Features Fearlessly Turn features on and off without deploys. Used by thousands of Ruby developers. →

How I accidentally made a dimmer switch

A journey into IoT.

I discuss how dimmer switches work, why Arduino or an equivalent microcontroller is the right technology for them and how to use a raspberry pi2, docker and hapjs to control it with I2C commands so it appears as a HomeKit accessory.

Avatar for Carl Peto

Carl Peto

June 21, 2018

Other Decks in Programming

Transcript

  1. HOW… ➤ - Bought a kit from PowerSwitchTail to make

    a Twitter powered coffee pot. ➤ - Accidentally bought a PowerSwitchTail SSR… “Solid State Relay”, a 300w maximum TRIAC controlled switch for dimming. ➤ - Decided to make a dimmer! Bought the zero cross kit, lots of soldering and got started...
  2. HOW DIMMERS WORK ➤ - The first version I just

    downloaded the sample code from the PowerSwitchTail guys. ➤ - Written in C, had no easy way to integrate to raspberry pi/ homekit. Most attempts caused jitter...
  3. JITTER… ➤ - received control signals from pi via xbee

    etc. often interfered with timing slightly ➤ - a very slight mistiming causes annoying flickering on the lightbulb, especially at mid brightness (middle of the wave, jitter in power delivered is maximal) ➤ - eventually wrote my own compiler, IDE and functions, in part to resolve this, for stability, profit and fun! ➤ - Swift for Arduino running this program gives a butter smooth dimming experience (www.swiftforarduino.com)
  4. HOMEKIT INTEGRATION AND THE RASPBERRY PI… ➤ - The Arduino

    and other micro controllers excel at performant, exact circuit control, the pi is an all round workhorse computer ➤ - linked Arduino to pi using the popular I2C bus also known as “two wire interface” because it uses only two wires ➤ - running HapJS on node inside a docker container on the pi to present as a homekit accessory and send I2C signals down the bus for dimming
  5. www.swiftforarduino.com www.twitter.com/swiftforarduino www.facebook.com/swiftforarduino [email protected] Parts can be bought at: https://www.adafruit.com/,

    https://www.sparkfun.com/, http://www.powerswitchtail.com/ and many more docker container for HapJS homekit accessories available from: https://github.com/carlos4242/hap-docker or pull the image from docker hub carlos4242/raspberrypi:lamp