Everything started with my daughters birth and the fact that my mother in law sleeps over once a week... we are really thankful for her looking after our baby once a week!
As the winecooler is in the same room as the guest bed I had to switch it off every week, the problem was that I couldn't switch it on until coming back from work the next day, which I used to forget.
I had a particle core lying around so I've decided to add some IOT functionality to the winecooler.
What features do I need to add?
Ok, some guys told me to buy a timer power outlet, why not?
- It's not fun!
- When plugged in the winecooler starts a 12° celsius
- I can't control it from everywhere
Features to add:
- Internet connectivity
- Power on/off remotely
- Modify temperature setting
How did I do it
I've started with a bread board, the particle and 3 transistors.
- 2 transistors for the temp up/down buttons on the front
- 1 transistor for power control
So I disassembled the front control of the wine cooler to see how it works.
I wired up one transistor per button to the core, and started playing around with the tinker app.
It worked flawlessly!
Next thing was to get the power on/off to work, I've started taking a look what happens if I disconnect the power cables going to the front unit, and it seemed that it would stop.
Then just to make sure I took the back part of the wine cooler apart and there I found the main board, so just disconnecting the front didn't feel right. So I went and ordered a relay and connected that to the main power supply.
As it's a SS-Relay, three volts should be enough to control it. After wiring that to the core I've tried it with the tinker app and I was able to power it on and off, without writing a single line of code... from anywhere in the world! Pretty cool.
Then I started wired each button to an analog input to be able to attach an interrupt to know when a button is "pressed", either on the front or by the transistors.
Take a look at the code to see the evolution and read the gotchas section ;-)
Stuff I use which comes for free with the particle:
- Remotely readable variable: currentTemp
- Publish events when temperature changes
- Remote function to press up
- Remote function to press down
- Remote function to set a temperature
- Remote function to power on/off
Every functionality is a one liner!
Integration with IFTTT; Now I've a rule which powers the wine cooler off when my mother in law sleeps over and a rule which powers it on again in the morning! As the spark knows what temperature was set when it was powered off it automatically sets that temp again.
Spark.variable("currentTemp"...), name length, max 12 characters
- Avoid taking time in an interrupt callback, it took me some hours to understand why the spark rebootet sometimes (almost always...), I was publishing the event in the callback.