Friday, October 21, 2016

Triggering a Photon Servo with a QR Code (#IoT)


In my last post, I got a servo running on a Photon by using web requests sent from Node.js and Twitter. After getting to that point, I wondered how I might automate the process so that someone else could trigger my servo, if I were to integrate one into a wifi-connected book.  Today, I had an idea that this might be achieved by creating a QR code.  I wasn't sure whether this was possible until I came across a blog by Trevor Fox. While his post was related to a completely different (albeit clever) use of the QR code, I noticed that he was using If Then Than That (IFTTT) like I was, when I created my web request for Twitter.  This prompted me to do some experimenting which ended up working!

The last time I played with my servo, I created a recipe that paired Twitter with an "Action" on the Maker Channel.  The "Action" was a web POST.  When paired with the hashtag #servo, it triggered a Particle function that made the servo move.  This time, I needed to create a "Trigger" to receive a web request.
The "Trigger" became a unique URL that I could then paste into a QR code generator to produce a QR code.   


After making a new recipe on IFTTT that used the "Trigger" to call the "Action," I was able to control the servo by scanning the QR code.



To learn more, visit "How to Trigger Events" on the Maker Channel page.   

WARNING:  Using a QR could become a security issue, if someone really wanted to try to figure out your IFTTT key.