When particular user tweets on Twitter, you will be notified on the M5StickC display.
- M5StickC with obnizOS
- smartPhone or PC
- power supply for M5SticKC
- USB-Type-C Cable
You can install obniz OS on your M5StickC. β obnizOS installation
β»It doesnβt matter with no power supply and no cable because M5StickC has its own battery. However, you should use the power supply if you want to run the program for a long time.
How to makeHardware connection
Prepare an M5StickC obnizOS installed. No parts are needed.
Software
The program detects tweets through IFTTT. IFTTT is a web service that makes it easy to connect various web services and devices.
Setting up an obniz Event
Set up the obniz Event so that the program will be run when IFTTT calls the Webhook URL. Learn more about obniz Events here.
First, go to the official obniz website and enter the βDeveloperβs Consoleβ.
Next, click on βCreate Newβ in the left menu, paste and save the program.
You can name the file as you like. In this case, I tried it as a Tweet notification.
Next, click on Create New in the βServerless Eventβ field to create an event.Please refer to the following for details of the settings
Name (any) Webapp to run Select the name of the program saved in the repository. Trigger Webhook
Click βCreateβ.
In the end, note the URL of βEndpointβ on this page. You will use this URL at βMake a recipe with IFTTT.β
Make a recipe with IFTTT
Make a recipe with IFTTT to call Webhook URL when particular user tweets on Twitter.
First of all, you need to access IFTTTT and log in. If you use IFTTTT for the first time, you will be asked to register as a member or log in through Google or Facebook.
If you can log in to IFTTT, click βcreate.β And click βThisβ part (we call it the trigger) of the βIf This Then That.β
Type βtwitterβ in the search bar and select Twitter. Then select βNew tweet by a specific userβ.
Input the username you want to notify on βUsername to watch.β (Please remove the @ mark.)
Next, click on the part of βThatβ (we call it the action).
Type βwebhookβ in the search bar and select Webhooks. Then, select βMake a web requestβ.
Set βURLβ to the URL you have saved, βMethodβ to POST, βContent Typeβ to application/json, and βbodyβ to {"tweet":true, "content":"{{Text}}"}
and click βCreate actionβ.
Compleated!
Program<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<script src="https://obniz.io/js/jquery-3.2.1.min.js"></script>
<script
src="https://unpkg.com/obniz@3.x/obniz.js"
crossorigin="anonymous"
></script>
</head>
<body>
<script>
let obniz = new Obniz.M5StickC("OBNIZ_ID_HERE");
obniz.onconnect = async () => {
if (typeof req === "object") {
if (req.body.tweet) {
console.log("New tweet");
console.log(req.body);
obniz.display.clear();
obniz.display.print("New tweet!");
obniz.display.print("content:");
obniz.display.print(req.body.content);
await obniz.wait(5000);
}
} else {
console.log("failed");
}
if (typeof done === "function") {
done();
}
};
</script>
</body>
</html>
How to useIf particular user tweets on Twitter, the notification of βNew tweet!β and contents of the tweet will be displayed on M5StickC.
In this article, we used the Body to get the content of the tweet (Text), you can also get other information such as the user name (UserName).Try changing the notification text and content to make the notification screen whatever you want it to be.
What is obniz?Here β obniz for DIY electronics
obniz is a cloud-connected IoT development board. You can program on the web browser of any smartphone or computer and the command is sent to obniz through the internet via obniz cloud. By connecting the obniz to the cloud through wifi, users can remotely control devices that are physically connected to obniz.
Thanks to this cloud based approach, you can program with Python, Javascript, or other languages you prefer and control hardware directly. You don't need to integrate firmware into the device side. Recording and analyzing data is also easy with obniz cloud service.
Want to control hardware things with your current Python or Javascript skill? Want to start IoT project but don't know where to start? Want to learn programming with languages you prefer?
obniz will help you broaden your viewpoint and develop both your SW and HW skills.
For more information, please visit our official website β Official Website
Where to get obniz board? β Amazon / Official Store
Comments