So Easy MicroPython - IFTTT, IoT Cloud Platform
by Yungger Chen in Circuits > Microcontrollers
772 Views, 1 Favorites, 0 Comments
So Easy MicroPython - IFTTT, IoT Cloud Platform
*** Just add 2~3 lines, then your MCU will be an IFTTT Notifier of IoT device ***
from MyREST_IFTTT import myIFTTT
my_ifttt = myIFTTT(YOUR_API_KEY, YOUR_EVENT)
my_ifttt.send(["2020-04-12 19:00:00-2020-04-13 21:00:00", "22-37", "Very Hot"])
***MyREST_IFTTT is a very useful IFTTT library to let your MCU trigger IFTTT and send real-time message to your client device in very easy and fast way, just like the codes above. ***
*** Before next demonstration, you should have your account on the cloud platform, we will not take more time to introduce it step by step since anyone can easily get help from official website ***
Upload Libraries to MCU
First, You need to upload the libraries to you MCU board:
- MyREST: A basic library for using Restful API communication
- MyREST_IFTTT: A specific function library to trigger IFTTT event and then send out real-time message to your client device
- MyWifi: A basic library for WiFi connection (Optional, if your code already make the MCU connect to WiFi)
*** If you have no idea how to upload File to your MCU, read my another article "So Easy MicroPython - ESP8266/ESP32 MCU File Management" first.
*** If you are interested in MyWifi library or no idea how to use it, read my another article "So Easy MicroPython - My WiFi Connection"
Before the Demo Code ...
First of all, you MUST have an IFTTT account, setup the trigger event, and got the API key before the next demo section.
Follow the demonstration, you will be able to trigger IFTTT event to send out LINE notify to your client device, and just simply add 2~3 lines of MyREST_IFTTT function calls into your code.
*** You can click on the Webhook icon of IFTTT web page, and find your API key inside the "Documentation" link.
Example:Trigger IFTTT Event and Send LINE Notify to Your Client's App
# Connect to WiFi, it cab be omitted if your MCU already get on WiFi in your existing codes
from MyWifi import myWifi
my_wifi = myWifi(YOUR_WIFI_SSID, YOUR_WIFI_PWD)
my_wifi.connect()
# Only add these 3 lines, then your MCU can read triggering IFTTT event to send out message.
from MyREST_IFTTT import myIFTTT
my_ifttt = myIFTTT(YOUR_API_KEY, YOUR_EVENT)
my_ifttt.send(["2020-04-12 19:00:00-2020-04-13 21:00:00", "22-37", "Very Hot"])
*** Basically, it will be all the same to write the codes as this demo code triggering IFTTT event to send out LINE Notify.
That's So Easy, Hope to Help a Little Bit !
Written and posted by Yungger
If it help you, and want to give some encouragement, just go HERE 😘 😘 !!