I am looking for guidance how the LoRa Sender code for this project can be reconfigured for mqtt instead of LoRa.
Which lines need to be removed and which to add?
Hi Jack.
I recommend following the MQTT Modules first to understand how it works.
I’m sure that after following the MQTT modules, you’ll easily figure out how to make something similar to the LoRa project, but with MQTT.
First, make sure you can send and receive data via MQTT between boards. Then, you can add the other functionalities.
Try to do it yourself first. Then, I can help you later with specific doubts.
Regards,
Sara
Hi Sara
I am able to publish/subscribe with mqtt from an esp32 client and RPi broker/server. But I am struggling trying to organize and integrate the two codes. Should I copy it all here?
The general layout is:
header files / libraries eg, #include <OneWire.h>
I use PubSubClient.h rather than the Asynch library
wifi connection (eg, ssid, pw)
mqtt const char (eg, topics, broker ip, clientID)
Save reading number on RTC memory
Define deep sleep options
Data wire connection to ESP32 GPIO15
Setup a OneWire instance to communicate with a OneWire device
Pass OneWire reference to Dallas Temperature sensor
Set moisture, temp and battery variables
Try to make a connection to broker via wifi
IF NO CONNECTION, read and store sensor data
Go into sleep mode with timer for periodic wakening
Read sensor data and write to csv file with timestamps.
eg, void getReadings()
IF CONNECTED, send data, confirm, then go to sleep.
Read csv file and send via mqtt.
What are you thoughts?
Hi again.
Your layout seems fine. Can you provide more details?
What errors are you getting when trying to compile? Are any of those functionalities not working?
Regards,
Sara