Software apps and online services
By far the simplest task in an IoT project is sending a message from one device to another. While it is a simple concept, it is not always as easy to achieve as it should be.
The solution I found was to send an email to a dedicated address. This email is monitored by a python script on the Raspberry Pi to read the subject of any new messages every second. This means you can simply trigger events with an email.
This is great for a few reasons. The first is that you can set up countless different triggers without writing a line of code using IFTTT. Also, you have a built in event log that you can check from anywhere. Lastly, and most importantly, it's completely free and takes barely any time to get set up.
To trigger the event, you make a POST request. To open a command generator that outputs the Linux command based on the event and data you give it go to
. You can obtain you key by going to ifttt.com/maker.
Go to IFTTT to create yourself an instance of the recipe. If you haven’t already make sure to connect Gmail and the maker channel. The to address should be the dedicated Gmail account you created for you Raspberry Pi. The event source can be whatever you want.
If you want to use a different trigger (e.g. trigger lights when you get home using Android Location) just swap the IF in the recipe.
When you create your Gmail account for this project there is one setting you will need to change, which enables access from IMAP applications, such as the Python client running on the Raspberry Pi.
I created a simple listener script in Python to be run on the Raspberry Pi. Every second it checks for new messages and then calls
for you to parse out what you need and perform any operations. I've included RPi GPIO because odds are you'll end up needing it. All you need to give it is the username and password for your Gmail account. Run this on a Pi Zero with Wi-Fi and you have a Wi-Fi development board cheaper than an Arduino Uno.
This is just one of many ways to approach this topic, and due to latency with Gmail (which is negligible in most projects) isn't necessarily the best. These are the other methods I considered, and why I chose not to use them.
Plain HTTP Request
This is the lowest latency option and can be activated from almost any platform as well as integrated with IFTTT using the maker channel to broaden the source type. The problem is the setup on the Pi takes a long time, and unless you're comfortable with running a webserver on your LAN with a very meager firewall it's probably not the best option.
IoT Cloud Service
You can always choose to go with AWS IoT or Azure IoT Suite, both which are great platforms, but they can be a bit code heavy and AWS takes a lot of command line setup to get the proper modules installed. Also, they start costing when your free trial runs out. The real advantage is you can expose your Raspberry Pi as a RESTful API which makes changing GPIO a breeze if you do go this route.