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