Staff Pick
Building a serverless connected BBQ as SaaS - Part 1
In the world of BBQ, tradition and technology rarely cross paths. But what if I told you that the future of grilling is here, and it’s connected, smart, and runs on the cloud? In this blog series, I will explore how AWS IoT, serverless, and event-driven architecture enables an automated cooking experience. As a tech-savvy griller, I discover how cloud technology can elevate my grilling game to a whole new level.
Published May 29, 2024
Last Modified Aug 23, 2024
This post is the start of a series of post on how I built a IoT connected BBQ as SaaS. This first post will kick everything off by briefly introducing the used hardware and AWS GreenGrass, which will be used to connect and send data to the cloud. In the coming post the architecture will be introduced followed be deep dive technical posts on each part of the architecture.
In the end I will have created a Serverless connected BBQ smoker as a SaaS solution. There will be deep dives into IoT setup, on-boarding, user management, data and tenant isolation.
First, let's go over the required HW and what I'll be using in this series. I will be using a Raspberry Pi 3 model B that will connect to a Inkbird IBT-6xs over bluetooth LE.
However in this first post we'll setup a simulated device running on a small EC2 instance.
AWS IoT Greengrass is an edge runtime and cloud service for building, deploying, and managing device software in an easy way. It support creation of custom software components that can easily be deployed to any device running Greengrass.
To make development a bit easier I will be using Greengrass Development Kit to build new versions of the component. GDK however doesn't support AWS Identity Center and CLI profiles, making it impossible to publish new versions using this tool. Instead I will be manually creating new versions.
First of I use GDK to initialize a new component. To do this run the init command. There is a need to specify the used language and template to base the component of. Available templates can be found in GitHub I will be using Python and base the component of HelloWorld template. I will also supply a name for it, this will create a new folder where all files are stored. Make sure the folder do not exist.
gdk component init -l python -t HelloWorld -n HelloBBQ
In the
HelloBBQ
folder there is now a configuration file gdk-config.json
this need to be updated and the PLACEHOLDER values changed, and the component name specified.Update the main.py file and add code to connect and publish fake temperatures to IoT Core on a topic
e/{THING_NAME}/data
In the same folder the GreenGrass recipe file is also created. This need to be updated to match GDK configuration. In the recipe it's possible to variables like
{artifacts:decompressedPath}
, full reference can be found hereTo send data over MQTT to AWS IoT Core we need to add permissions for the mqttproxy and specify which topics it can publish to. W'll only allow the device to publish to topics it "owns" that is include the thing name. For this we can use the variable
{iot:thingName}
With the GDK config and recipe update it's time to build the component. That is done with command.
The build will produce a zip file located in folder
greengrass-build/COMPONENT_NAME/VERSION/
With build completed copy the zip file to the S3 bucket used in the recipe.
With the zip file uploaded the component can be created in the AWS Console.
To create the component we navigate to the IoT Core part of the console, expand
Greengrass devices
and select Components
, click on Create Component
button to the right.Paste the recipe and click on
Create Component
To simulate the device we can use a small EC2 instance. I will create a small
t3.micro
instance that I will be using.We need create an IAM Role, that we assign to the EC2 Instance, this role will be used to provision the instance as an IoT Thing and all the needed resources. The minimum access needed can be found in the aws documentation below is an example.
I create a Role named
SimulatedBBQDeviceInstanceRole
with the above permissions, and assign this the EC2 instance used to simulated the BBQ device. When the EC2 instance is running I connect to it using EC2 Instance Connect
.First of all Java need to be installed on the instance, since i use a Amazon Linux 2023 based instance Java is installed with command.
Next Python and PIP are needed. Amazon Linux 2023 should come with Python 3.9 installed, verify this by running
which python3
. If Python should not be installed run:Next install PIP for the corresponding Python version
Finally install AWS IoT SDK fpr Python, but before you do this ensure you have the latest version of AWS CLI installed, follow this guide.
To setup GreenGrass Core on the device navigate back to the IoT Console, select
Greengrass
and Core devices
then click on Set up one Greengrass core device
I give it a name and don't assign any Thing group. The rest of the steps are in the wizard but summarized we should:1: Download the installer
2: Run installer
There should be a print in the end indicating success
Successfully set up Nucleus as a system service
and the device should now be visible in the IoT Core Console.Now let's install the component that is needed. Navigate to
Deployments
in the GreenGrass section of IoT Core console, and locate the Deployment for the Simulated device.From the Actions menu select
Revise
and the Revise Deployment
button.Leave target as is and just click next.
Select the HelloBBQ component, LogManager, CloudWatch, and Nucleus, and click next.
Next there is a need to configure
LogManager
and Nucleus
components.In the Configuration screen select LogManager and click Configure, add the below JSON to the merge config.
Now repeat the process for
Nucleus
where we need to set interpolateComponentConfiguration
otherwise {iot:thingName}
will not be inflated to a proper value.Now just click next in rest of the dialog and confirm the deployment to start the process.
To verify that everything now is running navigate to Core Devices, select the simulated device, and check that all components are running.
To verify that data is sent as expected open the MQTT test client in the console and create a subscription to
e/#
. Data should start flowing in the format we defined in the code.To check the logs from the device, navigate to CloudWatch Logs, there should a Log group with the component name e.g.
/aws/greengrass/UserComponent/eu-west-1/com.example.hellobbq
It's also possible to get the logs on the device it self. Connect to the instance, using Instance Connect. Logs can be found in folder
/greengrass/v2/logs
This was the first part in building a connected BBQ as a SaaS solution. We looked at creating a GreenGrass Core component and device running as a simulation on an EC2 instance.
Check out My serverless Handbook for some of the concepts mentioned in this post.
As Werner says! Now Go Build!