Questions tagged [mqtt]

MQTT (Message Queuing Telemetry Transport) is a machine-to-machine (M2M)/"Internet of Things" connectivity protocol. The MQTT protocol enables a publish/subscribe messaging model in an extremely lightweight way. It is useful for connections with remote locations where a small code footprint is required and/or network bandwidth is at a premium.

MQTT (Message Queuing Telemetry Transport) is a lightweight publish/subscribe messaging protocol. It is useful for use with low power sensors, but is applicable to many scenarios.

The MQTT protocol is based on the principle of publishing messages and subscribing to topics, or "pub/sub". Multiple clients connect to a broker and subscribe to topics that they are interested in. Clients also connect to the broker and publish messages to topics. Many clients may subscribe to the same topics and do with the information as they please. The broker and MQTT act as a simple, common interface for everything to connect to. This means that you if you have clients that dump subscribed messages to a database, to Twitter, Cosm or even a simple text file, then it becomes very simple to add new sensors or other data input to a database, Twitter or so on.

89 questions
5
votes
1 answer

MQTT connection fails when using String objects

On my ESP32 I am trying to connect to my HomeAssistant server using ArduinoHA library. I can easily connect when hard-coding the credentials: mqtt.begin("server", "username", "password"); But I recently tried to move the credentials to a config file…
SagiZiv
  • 201
  • 1
  • 8
4
votes
2 answers

How to connect to MQTT broker with TLS?

I have ESP8266 which is connecting to MQTT broker and it is working ok using user+pass with following code: #include #include const char* ssid = "WIFINAME"; const char* password = "WIFI_PASS"; const char*…
iWizard
  • 143
  • 1
  • 1
  • 5
3
votes
1 answer

how to transfer json to string?

I am getting a json object from aws iot MQTT. Assuming that json from aws is {status:opened}. Here is my code. #include void messageHandler(char *topic, byte *payload, unsigned int length) { StaticJsonDocument<32> doc; …
Jess
  • 53
  • 2
3
votes
1 answer

Connect ESP32 via MQTT

For a project I am working on, I need to connect my ESP32 board to another server via MQTT protocol. I am using the Mosquitto MQTT Broker and it is presently on my laptop. Following is the test code I am using, which I'll build around this…
P_K
  • 57
  • 7
3
votes
3 answers

Convert byte* to int in Arduino

I am trying to convert byte* value to int here is how I have it. void mqttCallback(char* topic, byte* payload, unsigned int length) { String topicStr = topic; int* payload_value; int updates_cal; payload_value = (int*)payload; …
user3201500
  • 225
  • 1
  • 6
  • 15
3
votes
1 answer

ESP8266 deep sleep and MQTT

I am working on a project were I am putting my board into deep sleep mode, and it wakes up with an interrupt from a sensor. When it wakes from deep sleep I would like to send a message to my MQTT broker. The wiring works, the interrupt works,…
Paul Carlson
  • 141
  • 1
  • 4
3
votes
2 answers

MQTT over serial

I'm planning to build a 32 relay IOT node next to my Raspberry Pi. The relays will be controlled by an Arduino Mega 2560. The Pi will run Home Assistant and Mosquitto so I would prefer to communicate with the arduino using MQTT. The Arduino and the…
pvoj
  • 193
  • 1
  • 5
2
votes
0 answers

MQTT on ESP8266 cannot connect if using Last Will service

Issue (short) description An ESP8266 using PubSubClient fails to establish connection to MQTT broker (mosquitto) if requesting Last Will Testament (LWT) on connection, though it is able to connect without LWT. The aim and detailed description of the…
Vadim
  • 145
  • 9
2
votes
0 answers

AsyncMqttclient publish affects accelerometer readings

Using M5StickC ESP32 with built-in MPU6886 accelerometer to read vibrations. In the loop() section the code gets 10 readings per second and if the readings exceed a threshold, it starts publishing the results in a JSON MQTT message on…
febalci
  • 21
  • 1
2
votes
2 answers

ArduinoJson library parsing error

I am trying to retrieve JSON mqtt message I received in ESP32. void mqttMsgCallback(char* topic, byte* payload, unsigned int length) { payload[length] = '\0'; String _message = String((char*)payload); String _topic = String(topic); …
2
votes
1 answer

OTA over MQTT for ESP32

Before starting working, I am just researching around how can I achieve OTA over MQTT in ESP32 in using Arduino IDE. The process I understand the esp listen to MQTT messages and then received that file over MQTT(not fully at once may be in chunks).…
2
votes
0 answers

Multiple MQTT topics

I have 3 nodemcu's(ESP32) each connected with a sensor, from which I get data and send it to aws IoT-core. How can I send all 3 sensor's data by a single MQTT subscription? The below code is for a single MQTT using one nodemcu. #include…
2
votes
1 answer

MQTT connection not being recognised in void loop()

I am trying to publish MPU 9250 readings in the Adafruit IO sending the data from ESP32. The WiFi connection is being established, but the code is not going inside the if(mqtt.connected()) inside the void loop() whereas it's going inside the same…
Ajay Raj
  • 63
  • 6
2
votes
1 answer

Publish chipid to mqtt using ESP32-CAM

I have been trying to push the data of temp, humidity, and pressure from a sensor to MQTT using ESP 32Cam, and was able to do using the following code: pressure = bme.readPressure(); //Convert the value to a char array char…
sanil jain
  • 23
  • 2
2
votes
2 answers

Connecting to MQTT causes DHT11 Sensor to stop working?

I have a project I am working on, based on an ESP32 from NodeMCU. I have a bunch of sensors connected to said ESP32 - they all work and the code itself "works" with a minor quirk. The issue in question starts with a DHT11 sensor. I started from the…
1
2 3 4 5 6