Skip to content

2. ESP32 Classic MQTT Publisher

Graham Ross edited this page Oct 18, 2022 · 7 revisions

The ESP32 Classic MQTT publisher will read data from your classic over Modbus and publish it to a MQTT broker. If you use a cloud based broker like dioty then your classic data can be accessed from anywhere on the internet using the Android MQTT subscriber App.

Note: Since the classic only supports one network connection over TCP, you must turn off the ESP32 when using the midnite solar local application. However you can use both HomeAssistant and the Android MQTT subscriber App at the same time.

Flashing the ESP32 MQTT Publisher from a Windows 10 PC

Connect your ESP32 device to a USB port on your PC.

Download firmware.zip from https://github.com/ClassicDIY/ClassicMQTT/releases and extract the content.

go to the extracted folder and run flasher.exe.

Press the !Flash button to start the flashing process.

You may have to press the 'Boot' button on your ESP32 device to initiate the flashing process (this may not be required on some dev boards).

Press Setup WIFI and enter your wifi SSID and password

The flasher tool will launch your default browser with the ClassicMQTT home page.

Click on 'configure page' and sign in using Username: admin and Password: ClassicMQTT

Set the AP password (can re-use ClassicMQTT)

Enter your classic's IP, port and Name (this is the name you will use in the Android App)

Enter your MQTT broker, port, user, password and root topic (this information is available from your dioty.co account)

Hi Apply and reset your device.

You can use the MQTTfx tool to view the messages being published by your device. Once you have setup and connected to your broker, subscribe to 'your Root Topic'/# (example /[email protected]/# )

Prograqmming the ESP32 MQTT publisher

Once you download extract the ZIP file for this project the code for the ESP32 implementation is available in the ClassicMQTT-master\code\ESP32\ClassicMQTT folder.

This project uses Visual Studio CODE with the PlatformIO extension. Here is a video tutorial for the VSCode & PlatformIO setup; PlatformIO for ESP32 Tutorial

Once setup with the PlatformIO extension, use File->Open Folder to open the project selecting the ClassicMQTT-master\code\ESP32\ClassicMQTT folder.

The Log level can be set in the platform.ini file by setting APP_LOG_LEVEL to one of the following;

  • #define ARDUHAL_LOG_LEVEL_NONE (0)
  • #define ARDUHAL_LOG_LEVEL_ERROR (1)
  • #define ARDUHAL_LOG_LEVEL_WARN (2)
  • #define ARDUHAL_LOG_LEVEL_INFO (3)
  • #define ARDUHAL_LOG_LEVEL_DEBUG (4)
  • #define ARDUHAL_LOG_LEVEL_VERBOSE (5)