Automating Your Home with Grafana and Siemens Controllers
AWS Architecture BlogAutomating Your Home with Grafana and Siemens Controllersby Viktoria Semaan and Emad Mankbadi | on04 AUG 2021| inAmazon CloudWatch,Amazon Managed Grafana,Amazon Timestream,Architecture,AWS IoT SiteWise,AWS Lambda,Customer Solutions|Permalink|ShareImagine that you have access to a digital twin of your house that allows you to remotely monitor and control different devices inside your home. Forgot to turn off the heater or air conditioning? Didn’t close water faucets? Wondering how long your kids have been watching TV? Wouldn’t it be nice to have all the information from multiple devices in a single place?Nowadays, many of us have smart things at home, such as thermostats, security cameras, wireless sensors, switches, etc. The problem is that most of these smart things come with different mobile applications. To get a full picture, we end up switching between applications that serve limited needs.In this blog, we explain how to useSiemens controllers,AWS IoT, and the open-source visualization platformGrafanato quickly build a digital twin of any processes. This includes home automation, industrial applications, security systems, and others. As an example, we will monitor environmental conditions, including temperature and humidity sensors, thermostat settings, light switches, as well as monthly water and energy consumption. We will go through the architecture and steps required to integrate different building components to store data for historical analysis, enable voice control, and create interactive near real-time dashboards showing a digital representation of your house. If you would like to learn more about the solution, we will provide links to all the architecture components and detailed configuration steps.Figure 1. Smart home automation solution with Siemens LOGO! compact controllerArchitectureIn this solution overview, we are using a low-costSiemens LOGO! controller(hardware version 8.3 or higher). This controller supports traditional industrial protocols such as Simatic S7 and Modbus TCP/IP as well as MQTT through the nativeAWS IoT Coreinterface. Automation controllers are the brains behind smart systems that allow orchestrating all the devices in your home. This reference architecture can be extended to other devices that support MQTT protocol, have programmatic APIs, or Software Development Kits (SDKs). It could serve as a starting point for building a home automation solution using AWS IoT and Grafana and further customized based on customer needs.Figure 2. Reference architecture for smart home automation solutionThe components of this solution are:The LOGO! controller controls home automation equipment and ingests data to AWS IoT Core.AWS IoT Core collects data at scale and routes messages to multiple AWS services.AWS Lambdais called inside the AWS IoT Core statement to transform the incoming data prior to ingestion.Amazon Timestreamstores time series data and optimizes it for fast analytical queries.AWS IoT SiteWisemodels and stores data from equipment for large scale deployments.Grafana installed onAmazon Elastic Compute Cloud (Amazon EC2)visualizes data in near real-time using interactive dashboards.TheAlexa Skills Kit (ASK)allows interaction with devices using voice commands.Figure 3. Remote monitoring dashboard allows homeowners to view and control conditionsSolution overviewStep 1: Ingest data to AWS IoTThe IoT-enabled LOGO! controller provides the out-of-box capability to send data to AWS IoT Core service. In a few clicks, you can configure variables and their update frequency to be published to the AWS Cloud. To get started with the LOGO! controller, please refer toSiemens E-learning portal. AWS IoT Core collects and processes messages from remote devices transmitted over the secured MQTT protocol.The LOGO! controller publishes data to AWS IoT Core in hexadecimal format. The Lambda function converts the data from hexadecimal to the standard decimal numeric system. If your home automation equipment sends data in the standard decimal format, then AWS IoT Core can directly write data to other AWS services without Lambda.Step 2: Store data in Timestream or AWS IoT SiteWiseThe ingested IoT data is saved for historical analysis. Timestream is a serverless time series database service that is optimized for high throughput ingestion and has built-in analytical functions. It is one of the options you can use to store IoT data. Time series is a common data format to observe how things are changing over time and it is suitable for building IoT applications.AWS IoT SiteWise is an alternative option to store and organize data at scale. It is beneficial for large-scale commercial building automation and management systems, including offices, hotels, and factories. You can structure data by using built-in asset modeling capabilities.Step 3: Visualize data in Grafana dashboardOnce data is stored, it can be made available to multiple applications. Grafana is a data visualization platform that you can use to monitor data. It supports near real-time visualization with a refresh rate of 5 seconds or higher. You can visualize data from multiple AWS sources (such asAWS IoT SiteWise,Timestream, andAmazon CloudWatch) and other data sources with a single Grafana dashboard. Grafana can be installed on an Amazon Linux system, Windows, macOS, or deployed on Kubernetes (K8S) or Docker containers. For customers who don’t want to manage infrastructure and are interested in developing completely serverless solution, Amazon offers an Amazon Managed Service for Grafana. At the time of writing this post, this service is available in preview with a limited number of supported plugins.To build Grafana dashboard and retrieve data from Timestream, you can use SQL queries. Timestream query example to retrieve humidity values and timestamps for the past 24 hours:SELECT measure_value::double as humidity, time FROM "myhome_db"."livingroom" WHERE measure_name='humidity' and time >=ago(1d)To retrieve data from AWS IoT SiteWise, you can select asset properties from the asset navigation tab, which makes it simple for non-technical users to build dashboards.Figure 4. Grafana dashboard configuration with AWS IoT SiteWiseOne of the common issues of operational dashboards is that it’s hard to get a physical representation by looking at a cluster of multiple readings. To reflect conditions of physical assets, the information from sensors must be overlaid on top of original physical objects.ImageIt Panel Pluginfor Grafana allows you to overcome this issue. You can upload a picture of your house or a system and drag sensor readings to their exact locations, thus creating digital representations of physical objects.Step 4: Control using AlexaUsing theAlexa Skills Kit, you can build voice skills to be used on devices enabled by Alexa globally. Alexa and AWS IoT enables you to create an end-to-end voice-controlled experience without using any additional hardware. Instead, your functions run on the cloud only when you invoke Alexa with voice commands.The easiest way to build a custom Alexa skill is to use a Lambda function. You can upload the code for your Alexa skill to a Lambda function. The code will execute in response to Alexa voice interactions and send commands to the LOGO! controller.ConclusionIn this blog, we reviewed how you can create a digital twin of your home automation or industrial systems using Siemens controllers, AWS IoT, and Grafana dashboards. Connecting the LOGO! controller to AWS gives it access to the Internet of Things (IoT) and opens many potential applications such as anomaly detection, predictive maintenance, intrusion detection, and others.TAGS:Customer SolutionsViktoria SemaanAs a Senior Partner Solutions Architect, Viktoria helps AWS Strategic Partners to build joint innovative solutions on AWS. She specializes in industrial IoT solutions, edge automation and manufacturing. Viktoria has over 10 years of experience in leading multi-site automation and transformation projects across several geographic locations, including Europe, Russia, the Middle East, and North America.Emad MankbadiEmad Mankbadi is a Senior Partner Solutions Architect at AWS with over 20 years of experience in the industry. Emad focuses on supporting AWS strategic partners to build innovation solutions on AWS and to help promote and adopt their solutions to AWS customers. He has held various roles in research and development, solutions architecture, project management, and team leadership and has wide experience in distributed and edge computing, industrial IoT, and embedded systems. Emad holds seven patents for his inventions and work in IoT and cloud computing.
Imagine that you have access to a digital twin of your house that allows you to remotely monitor and control different devices inside your home. Forgot to turn off the heater or air conditioning? Didn’t close water faucets? Wondering how long your kids have been watching TV? Wouldn’t it be nice to have all the […]
Viktoria Semaan
Amazon CloudWatch Amazon Managed Grafana Amazon Timestream Architecture AWS IoT SiteWise AWS Lambda Customer Solutions