Skip to main content

Monitor MQTT messages.

Project description

MqttPrint and MqttMonitor

The function is based on MQTT. When the original serial of ESP8266/ESP32 cannot be used, it can replace serial print.

MqttPrint

An Arduino library MqttPrint

Easy Arduino example:

#if defined(ESP32)
#include <WiFi.h>
#else
#include <ESP8266WiFi.h>
#endif

#include "MqttPrint.h"

// Update these with values suitable for your network.

const char* ssid = "YOUR_WIFI_SSID";
const char* password = "YOUR_WIFI_PASSWORD";

const char* MqttServer = "broker.emqx.io";
const char* MessageTopic = "YOUR_MQTT_SUB_TOPIC";

void setup() {

    Serial.begin(115200);
    
    //
    // Begin to connect to thw WiFi AP.
    //
    Serial.println("setup : Attempting to connect...");
    WiFi.mode(WIFI_STA);
    WiFi.begin(ssid, password); // Connect to WiFi.

    int count = 0;
    while (WiFi.status() != WL_CONNECTED) {
        if (count > 30)
        break;
        delay(500);
        Serial.print(".");
        count++;
    }

    Serial.println("");
    Serial.println("WiFi connected");
    Serial.println("IP address: ");
    Serial.println(WiFi.localIP());
    
    mbegin(MqttServer, 1883, MessageTopic);

}

void loop() {
    mprint("millis = ");
    mprintln(millis());
    mprintln("Hello World");
    mprintf("TEST = %d\n", millis());
    delay(1000);
}

MqttMonitor

An application to receive the MQTT messages. It's written in Python. Please install it by the command.

pip install MqttMonitor

How to run 'MqttMonitor'?

  • Right-click on your desktop and select New > Shortcut.

  • Add the below string in the textbox - "Type the location of the item:" and press 'Next'.

    pythonw.exe -m MqttMonitor

  • Add the below string in the textbox - "Type a name for this shortcut:" and press 'Finish'.

    MqttMonitor

Usage

MqttPrint is a MQTT sender, MqttMonitor is a MQTT receiver. They should use the same MQTT broker and sub topic. This is the screentshot of MqttMonitor.

alt screenshot

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

MqttMonitor-1.0.8.tar.gz (10.0 kB view details)

Uploaded Source

File details

Details for the file MqttMonitor-1.0.8.tar.gz.

File metadata

  • Download URL: MqttMonitor-1.0.8.tar.gz
  • Upload date:
  • Size: 10.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.6.0 importlib_metadata/4.8.2 pkginfo/1.7.1 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.1

File hashes

Hashes for MqttMonitor-1.0.8.tar.gz
Algorithm Hash digest
SHA256 70418a3d393b21d8334100db73e4d72b53430b5a817bd4ce0975e051f140403c
MD5 aee387ad1b864ce5e1c38a0c8fc0df15
BLAKE2b-256 53290bf83a3499bc443b8235aa39434adb6b7d3665fce2120d69f16177548c82

See more details on using hashes here.

Provenance

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page