CO Detector Hack – Part 4

CO Detector Hack – Part 4

With many devices becoming connect to the internet, I thought it would be worthwhile to interface the CO Detector that I’ve been covering using a wireless ESP8266 board. There are several IoT services that make connecting devices as streamlined as possible. In this post. I’ll be covering IFTTT, a cloud based service that will perform an action based on a condition.

The ESP8266 board I’m using has 2 GPIO pins that I would like to use to interface with the CO Detector. The CO Detector test push button and the alert led will be the interfaces I’ll attempt to link the ESP8266 with. The ESP8266 will connect to my home wireless network and will have embedded code to connect with my IFTTT service API. The IFTTT service will be accessible from my mobile phone, giving me access to the CO Detector state even when I’m away from the house.

The first step is to download the IFTTT app to the smart phone. I typically disable phone features available to apps before I run them. I won’t run the app on the phone yet, next I’ll connect to the IFTTT website and sign up with an account, https://ifttt.com/

The account is tied to an email, so be sure you have access to verify your account if needed. Set your timezone, this will be helpful if you schedule triggers later on. I set 2FA on my account, I recommend it but you can choose as you like. Once the account is setup, you should be ready to start using the applets in IFTTT.

My first applet will use Webhooks and SMS services in IFTTT. The Webhooks is simply a URL that I’ll hard code into my ESP8266 later on. The SMS service will send a text message to my phone. First I’ll create my applet by clicking “New Applet”. Then I click on the “+this” link and search for “Webhooks”. After selecting Webhooks, I’ll click the “Receive a web request” balloon and enter an event name “CO_Detector_Alarm” and click “Create trigger”. Now I’ll click the “+that” and search for “SMS”. After selecting SMS, I’ll click the “Send me an SMS” balloon and the click “Create action”. The last step is to review before clicking the “Finish” link.

With the new applet created, I can list all of my applets by clicking the “My Applets” link at the top of the page. I see the new applet I just created and I click it. There is a gear icon in the upper right hand corner of the applet, clicking it brings me to a configure dialog were I can make changes to the applet.

If this is the first time you are creating an applet, there are settings in the Webhooks and SMS service that you will be prompted to configure when you setup your first applet. These can be viewed later on by going to your account name and selecting services from the pulldown menu. Click the services tab and type in the name of the server, in this example I’ll type SMS. There is a settings link in the upper right hand corner of the SMS page. Clicking it will bring up the account info that can be edited. Let’s look at the Webhooks service settings next.

First I’ll click my account and then select services from the pulldown menu. Next I’ll search for Webhooks and click it once it appears. Now I’ll click the documentation link instead of the settings link. Here I’ll see the URL to either POST or GET, notice the section with “event” in the URL. You will substitute this entry with the name you gave the event earlier, in my case it is “CO_Detector_Alarm”. Now I can copy the URL and I’ll use this to verify that I get a text message when I enter the URL in a browser.

https://maker.ifttt.com/trigger/CO_Detector_Alarm/with/key/*****************

After a few moments, my phone displays a message. Great, now I’m able to use the URL in my ESP8266 and have it trigger a notification to my phone using IFTTT.

The next item I would like to have is the ability to test the CO Detector from my phone. There are some considerations I need to take into account. First, I do not want my ESP8266 accessible from the internet. I think it’s unwise to put trust in the protocol stack installed on the ESP8266. Even though much work has been put into it, there is no absolute certainty that it will operate as expected to any and all web requests made to it. With that said, I’ll make my web requests from the local network only. This feature will not use the IFTTT service so I won’t go into further detail here.

As you can see, the IFTTT cloud service is rather granular and it supports a huge number of other cloud services. I think it’s worthwhile to take the time to see what other thens and thats IFTTT offers. Thank you for joining me and I look forward to covering more topics with IFTTT, ESP8266 and the CO Detector.

Comments are closed.