Updates in MySQL RDS Table Published to IOT Core

0

Hi, I’m trying to connect a table in a MySQL RDS database to an IOT Core topic. My goal is to have updates in certain cells of the RDS database publish specific messages to an IOT Core topic.

For example, in the MySQL RDS database the table may look like:

CodeStatus
Activated (Code 11)1
Payment Processed (Code 12)1
Paused (Code 13)0

If ‘Paused’ changed to ‘1’, I want this to be published to ‘example_topic’ in IOT Core in the format: “ 13:1 ” And if ‘Paused changed back to ‘0’: “ 13:0 “

I was wondering how should I approach this? I’ve been successful in pushing changes to the database when messages are published to an IOT core topic through using a lambda function. Can a lambda function be used in the opposite manner to publish to an IOT Core topic with updates in the database table?

Regards, MZivcec

1 Answer
2

Some resources that can help you get started:

AWS IoT Core Developer Guide: https://docs.aws.amazon.com/iot/latest/developerguide/what-is-aws-iot.html AWS Lambda Developer Guide: https://docs.aws.amazon.com/lambda/latest/dg/welcome.html AWS SDK for Python (Boto3) Documentation: https://boto3.amazonaws.com/v1/documentation/api/latest/index.html

you can use a Lambda function to detect updates in your MySQL RDS table and publish messages to an IoT Core topic. Here's a high-level overview of the steps you can take:

  • Set up an AWS Lambda function with an execution role that has permission to access your MySQL RDS database and IoT Core.
  • In your Lambda function code, establish a connection to your MySQL RDS database and query for the relevant data (in this case, the 'Paused' column).
  • Compare the current and previous values of the 'Paused' column to determine if it has changed.
  • If the value has changed, publish a message to your IoT Core topic using the AWS IoT SDK for Python.
  • You can format the message payload to include the new value of the 'Paused' column and the corresponding code number, as you described.
profile picture
EXPERT
answered a year ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions