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개 답변
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
전문가
답변함 일 년 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인