Sending PSoC6’s sensor to MQTT (node-red)

Lab Objective:

Building upon the foundational knowledge acquired from the previous lab on MQTT communication via the Mosquitto broker and public key cryptography, participants will now explore the integration of the PSoC 6 microcontroller's sensor data with Node-RED. Through this lab, participants will learn how to set up and configure Node-RED flows to receive, process, and visualize sensor data from the PSoC 6, transmitted via MQTT. The end goal is to enhance participants' proficiency in creating IoT workflows, harnessing the power of MQTT for real-time data communication, and visualizing sensor outputs in an interactive environment using Node-RED.

🔥 Requirements

ResourcesLinks

Computer

💻

ModusToolbox™ software v3.0 or later

CY8CKIT-062S2-43012 Infineon Board

Technical Report

🚩 Let start

Use the previous lab

Config mqtt_client_config.h:

  • Open config >> mqtt_client_config.h.\

mqtt_client_config.h
#define MQTT_PUB_TOPIC                    "PSoC6Status/temperature,pressure"
#define MQTT_SUB_TOPIC                    "PSoC6Status/led"
  • Open publisher_task.c in source.

  • Copy code from publiser_task.c and past in publisher_task.c

Add sensor-xensiv-dps3xx library

Save the file, Build and Launch the Application

Download and install Nodejs

Set-up node-red

  1. Check node-red version

  1. Run Node-Red by using node-red start

3. Open the Node-Red server: go to http://127.0.0.1:1880/

  1. Import Button control LED PSoC6 nodes:

    1. Go to Import

    2. Copy and Past this json code to create the nodes

  1. You will get this flow of nodes for Button control LED on PSoC6

    1. Go to Server and click edit

    2. Upload your client.crt

    3. Upload your client.key

    4. Upload your mosquito.org.crt

    1. Topic >> set up as PSoC6Status/temperature,pressure

    2. QoS >> set up as “1”

Result

🎉 Congratulations! You can now complete this lab

Supported toolchains (make variable 'TOOLCHAIN')

  • GNU Arm® embedded compiler v10.3.1 (GCC_ARM) - Default value of TOOLCHAIN

  • Arm® compiler v6.16 (ARM)

  • IAR C/C++ compiler v9.30.1 (IAR)

Supported kits (make variable 'TARGET')

ResourcesLinks

ModusToolbox™ Software Training

Other resources

Infineon provides a wealth of data at www.infineon.com to help you select the right device, and quickly and effectively integrate it into your design.

Document history

VersionDescription of change

1.0.0

Node-Red Read Sensor PSoC6 vai MQTT

Authors:

  • Assoc. Prof. Wiroon Sriborrirux

  • Mr. Sriengchhun Chheang

  • Mr. Sabol Socare


© BDH Corporation, 2022-2023

Last updated

Assoc. Prof. Wiroon Sriborrirux, Founder of Advance Innovation Center (AIC) and Bangsaen Design House (BDH), Electrical Engineering Department, Faculty of Engineering, Burapha University