Using an AWS IoT button to get your kids to show up for dinner

June 11, 2017
@julsimon - Configuring a rule for the IoT button - Setting up an SNS topic to send SMS - Writing a Lambda function to send SMS

Transcript

Hi everyone, it's Julien from Arcee again. In a previous video, I showed you how to configure an IoT button, and we were able to send some messages and view them in the IoT console and in MQTTFX. But we didn't really take any action when those messages got sent. So, I figured, let's try to find something really useful, something that I really need every day and solve it thanks to an IoT button. And I figured, can I use an IoT button to get my kids to show up at the dinner table? I'm sure if you have kids, that's a problem you face every evening. So, this is what we're going to do. Whenever I press the button, it's going to send a text message to my kids. And depending on the click type, it's going to get increasingly urgent. First, we need to create a rule. A rule is basically looking at incoming messages in a topic, and depending on the message content, it's going to take actions. So, let's create this. I'm going to call this rule "Dinner is ready." And the description: "Sends a message to the kids when dinner is ready." Rules are written in SQL, which is great because most of us know SQL. You saw in the previous video that one of the variables sent in the message when I press the button is a variable called `clickType`. I'm going to select the `clickType` from messages sent to the topic corresponding to this button. If you remember, the topic name is `IoTButton/serial_number`. Let me just grab this. So, for every incoming message in this topic, I'm going to select the `clickType`. I'm not interested in the other variables stored in the message, only the `clickType`. Now, the good stuff—acting on this message. Here, I want to invoke a Lambda function, passing the message data. This will allow me to send different messages to the kids depending on the click type. So, I'll invoke the Lambda function, configure it, and select my `DinnerIsReadyLambda` function that I wrote. I'll add this action and create the rule. So, for every message sent by the button, I'm getting the `clickType` and sending that to a Lambda function. The rule is created. Now, let's move on to the Lambda function. As you can see, it's a very short function written in Python. Based on the `clickType`, which is stored in the message I get, I'm preparing a text message for the kids with increasing levels of urgency. A single click means "Dinner is ready," a double click means "I said dinner is ready," and a long click means "You've got five seconds to show up." They know what that means, trust me. I'm going to send this to an SNS topic. I created an SNS topic with the phone numbers of the kids. Here are the phone numbers. The notification will send an SMS message to both kids. I'll grab an SNS client and publish my message to this topic. The subject should be "Dinner" instead of "Test." Now, let's save the function. The message will be whatever I selected depending on the `clickType`. We've got everything in place. The button has been configured, we have a rule triggering a Lambda function, and the Lambda function is pushing a message to a topic. Should we try this? Do we have a phone ready? Yes? It should beep. Okay, let's try a single click. I'll use my MQTT FX to ensure the messages are going through. My Wi-Fi is good. Ready. Let's go easy and try the single click. Single click. Can we see the message? It's probably too small, but that's the first message: "Dinner is ready." A few minutes later, I'm getting impatient, so now I send the double click. Double click send. Second SMS: "I said dinner is ready." Of course, they're not listening, so I have to use the long click. Here's the long click. That's the third and last message: "You've got five seconds to show up." If that doesn't work, then I have to use something else, but that's beyond the scope of this video. Here's an example of using a button and a Lambda function together for a good purpose—getting kids to show up for dinner. As you can see, it's really easy. The IoT rule is just the simplest SQL statement ever. You connect that to a Lambda function, make sure you have an SNS topic ready, and you have a 10-line Lambda function to push the message depending on the click type. It worked in five minutes, with zero infrastructure. Pretty cool. I hope you liked it and I hope your kids are showing up for dinner. That's it for today. Have fun with the buttons and the kids. See you.

Tags

IoTAWS LambdaSNSMQTTParenting Hacks

About the Author

Julien Simon is the Chief Evangelist at Arcee AI , specializing in Small Language Models and enterprise AI solutions. Recognized as the #1 AI Evangelist globally by AI Magazine in 2021, he brings over 30 years of technology leadership experience to his role.

With 650+ speaking engagements worldwide and 350+ technical blog posts, Julien is a leading voice in practical AI implementation, cost-effective AI solutions, and the democratization of artificial intelligence. His expertise spans open-source AI, Small Language Models, enterprise AI strategy, and edge computing optimization.

Previously serving as Principal Evangelist at Amazon Web Services and Chief Evangelist at Hugging Face, Julien has helped thousands of organizations implement AI solutions that deliver real business value. He is the author of "Learn Amazon SageMaker," the first book ever published on AWS's flagship machine learning service.

Julien's mission is to make AI accessible, understandable, and controllable for enterprises through transparent, open-weights models that organizations can deploy, customize, and trust.