mqtt_client_test
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.
Everything checks out. I just tested it and the code runs great!
Just those little nitpicks and it's good to be approved!
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.
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
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?
@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.
@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
I rebased the PR
I rebased the PR
@peterharperuk Amazing !