I wanted to be able to monitor and control my garage door from my Smartphone and get e-mail notifications when the door was left open. Around the time this idea came up I had just run across the Photon from Particle.io. The Photon is a WiFi enabled IoT processor (actually a STM32 ARM Cortex M3) with 18 mixed signal GPIO pins. It also includes a free back-end cloud and Web IDE. Their add actually says you can be up and running “in minutes” using their out of the box firmware (which you can replace later) and their Tinker Smartphone app.
Next question was what should a Garage Door Minder do? decided on 5 things:
- Be able to tell if the garage door was open or closed. This required 2 limit switches. One for all the way open, one for all the way closed
- Be able to tell if it was light outside or not. This I implemented with a CDS cell
- Be able to tell if a car was present in the garage or not
- Be able to tell the temperature, just because I could and I wanted to test the I2C interface on the Photon
- Be able to simulate pressing the Garage door open/close button
- Be able to send e-mail if the garage door was open “too long” (whatever that might be)
Tossing all the necessary IO together resulted in a circuit diagram like this:
Using the out of the box Photon software and the Tinker app is was easy to get the basic sensors up and running. Getting the I2C interface to the temperature sensor was another story. To get to the built in I2C I needed new Photon software. Fortunately the WebIDE that Particle.io provides includes a copy of the out of the box Photon software (Tinker in the WebIDE) as a place to start.
The Photon firmware already includes a Wire module to support the I2C interface. It appeared that it would only take a few lines to read the I2C temperature sensor, a Wire.beginTransmission(), a few Wire.read() and Wire.write() commands, plus some housekeeping calls followed by a Wire.endTransmission() call and there was the I2C temperature value.
But…. How to debug was a big question? There is no debugger in the WebIDE. A little digging, turns up the fact that if you plug in the Photon’s USB port to a PC, it enumerates as a COM channel which you can then connect to with any basic terminal emulator. Couple that with the fact that the Photon firmware includes a Serial module to communicate with the resulting COM port and you’ve got basic print line debug capability. It’s not great, but at least I could do some basic troubleshooting and even confirm that yes indeed the I2C routines were properly reading the data from the I2C temperature sensor.
Side note – when you re-flash the software on the Photon, make sure you disconnect the terminal emulator session first and then reconnect after the flash. otherwise it hangs the serial connection.
2nd problem, the Tinker App doesn’t understand how to interact with my new I2C temperature variable. Do I have to build a whole SmartPhone app to see if the new variable is successfully published? No! You can use a handy dandy PHP Dashboard located here. With the dashboard you can view Published Variables and even call Published Functions. Yup, that’ll also come in handy because I need a published function if I want to be able to remotely ‘press’ the garage door open/close button.
So this allowed me to get the basic Photon side of the Garage Door Minder up and running.
Here’s the simple garage door limit switches. Just triggering off the location of the arm that runs back and forth across the screw drive
Here’s the car sensor. It’s a reflective IR distance sensor placed on the ceiling with the IR emitter on the floor so now it operates as a beam break sensor.
Now on to the client side…..