pico-examples icon indicating copy to clipboard operation
pico-examples copied to clipboard

mqtt_client_test

Open ellebi2000 opened this issue 1 year ago • 4 comments

This PR introduces functionality for temperature monitoring and LED control on a Raspberry Pi Pico W using MQTT. The key features include:

Temperature Monitoring:

Reads onboard temperature using the ADC.
Converts ADC readings to Celsius or Fahrenheit.
Publishes temperature to the /temperature MQTT topic every 5 seconds.

LED Control:

Controls the onboard LED via MQTT messages received on the /led topic.
Turns the LED on/off based on "On" or "Off" messages.
Publishes LED state to the /state MQTT topic.

WiFi and MQTT Configuration:

Connects to WiFi using predefined SSID and password.
Connects to the MQTT broker with the given IP address and port.
Configures an MQTT client with a predefined client ID and keep-alive period.

MQTT Callbacks:

mqtt_incoming_data_cb: Handles incoming data and controls the LED.
mqtt_incoming_publish_cb: Handles incoming publish events.
mqtt_connection_cb: Manages MQTT connection status and subscribes to the /led topic.

ellebi2000 avatar May 25 '24 11:05 ellebi2000

Everything checks out. I just tested it and the code runs great! image Just those little nitpicks and it's good to be approved!

martincarapia avatar May 29 '24 17:05 martincarapia

This implementation is working great. I tested your publisher sample with a subscriber from this repository (running on a Linux machine) simple_subscriber.c.

I configured your code to publish to the address "35.156.49.117" (broker.hivemq.com) on port 1883, and the MQTT-C subscriber successfully listened to the transmitted temperature data.

Thank you, ellebi2000.

francdoc avatar Jun 01 '24 20:06 francdoc

I have removed the comment in Italian and others that are not strictly necessary. I'm very happy that your implementations are working as expected @martincarapia @francdoc

ellebi2000 avatar Jun 02 '24 14:06 ellebi2000

Perhaps this should be in pico_w/wifi/mqtt instead of pico_w/mqtt ?

EDIT: Also, do you really need separate mqtt and mqtt/mqtt_client directories? :thinking: Perhaps it could be "collapsed" to just a single pico_w/wifi/mqtt_client directory?

lurch avatar Jul 05 '24 09:07 lurch

@ellebi2000 If you can confirm that we're ok to release this with the same license as everything else (BSD-3-Clause license), I'll address the review comments and get this merged. Thanks.

peterharperuk avatar Jan 28 '25 13:01 peterharperuk

@ellebi2000 If you can confirm that we're ok to release this with the same license as everything else (BSD-3-Clause license), I'll address the review comments and get this merged. Thanks.

Yes, I confirm that this code can be released under the BSD-3-Clause license.
Thank you for reviewing and helping with the process! 😊 @peterharperuk

ellebi2000 avatar Jan 28 '25 15:01 ellebi2000

I rebased the PR

peterharperuk avatar Jan 30 '25 14:01 peterharperuk

I rebased the PR

@peterharperuk Amazing !

ellebi2000 avatar Feb 03 '25 19:02 ellebi2000