• Skip to main content
  • Skip to primary sidebar

RNTLab.com

The Ultimate Shortcut to Learn Electronics and Programming with Open Source Hardware and Software

  • Courses
  • Forum
    • Forum
    • Ask Question
  • Shop
  • Account
  • Blog
  • Login

Project 4 esp32 Data Monitoring and Logging with mqtt?

Q&A Forum › Category: ESP32 › Project 4 esp32 Data Monitoring and Logging with mqtt?
0 Vote Up Vote Down
Jack Douglas asked 3 years ago

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?

Question Tags: ESP32 MQTT
4 Answers
0 Vote Up Vote Down
Sara Santos Staff answered 3 years ago

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
 
 
 

0 Vote Up Vote Down
Jack Douglas answered 3 years ago

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?

0 Vote Up Vote Down
Sara Santos Staff answered 3 years ago

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

0 Vote Up Vote Down
Jack Douglas answered 3 years ago

I have it working now.
Interestingly, although at first it worked, I later had to switch from pin 26 to pin 34 in order to get moisture readings.

Primary Sidebar

Login to Ask or Answer Questions

This Forum is private and it’s only available for members enrolled in our Courses.

Login »

Latest Course Updates

  • [eBook Updated] Learn Raspberry Pi Pico/Pico W with MicroPython eBook – Version 1.2 May 26, 2025
  • [New Edition] Build ESP32-CAM Projects eBook – 2nd Edition April 16, 2025

You must be logged in to view this content.

Contact Support - Refunds - Privacy - Terms - MakerAdvisor.com - Member Login

Copyright © 2013-2025 · RandomNerdTutorials.com · All Rights Reserved

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.