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.

Filter by
Sorted by
Tagged with
2
votes
2answers
3k views

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 ...
2
votes
2answers
192 views

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 ...
1
vote
2answers
1k views

MQTT bridging with Arduino and ESP8266 - What software should I use?

Sorry for the vagueness in my question, I am just looking for ideas to point me in the correct direction please... I wish to connect many (read: 20+) different sensors to a local wifi network and ...
1
vote
1answer
1k views

ESP8266 MQTT client error

#include <PubSubClient.h> #include <ESP8266WiFi.h> //EDIT THESE LINES TO MATCH YOUR SETUP #define MQTT_SERVER "YOUR.MQTT.SERVER.IP" const char* ssid = "YOUR_SSID"; const char* password = "...
1
vote
3answers
2k views

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 ...
1
vote
3answers
671 views

Mosquitto TLS over WifiMulti on ESP8266

With these few lines I am able to attach my certificate, tell it to WifiClientSecure the certificate, start the wifi as well as the mosquito pubsubclient: WiFiClientSecure espClient; WiFi.begin(ssid, ...
1
vote
1answer
167 views

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 ...
1
vote
1answer
436 views

Impossible to connect ESP32 with Mosquitto on Raspberry using certificates

I installed Mosquitto broker in Raspberry in my local network. I generated certificates in Raspberry as follows: sudo openssl genrsa -out ca.key 2048 sudo openssl req -new -x509 -days 3600 -key ca....
1
vote
1answer
3k views

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 ...
1
vote
1answer
722 views

Use MQTT to update internal clock

I write code to upload to ESP8266. I wish to use time stamp in order to log events. I found an NTP sketch, I can work with ( since it has a wifi connection ), but I wish to keep my code as simple as ...
1
vote
0answers
200 views

How to parse data most efficiently coming through mqtt with ESP8266

I am writing a program that is currently set up like so: Python script running on my computer. Raspberry pi is the broker for the mqtt data transmission An ESP8266 is programmed to listen to/...
1
vote
2answers
283 views

How to get a list of IPs in a LAN using NodeMcu?

I'm going to create an IoT system. I use a Raspberry Pi as a MQTT broker and as a webserver. Every day, the Pi gets a new IP address, so I need to find its new IP address via ESP8266 to use this ...
0
votes
3answers
3k views

ESP-01 not waking correctly up after deep sleep

I have an ESP-01 that I want to measure pool temperature with. It will send the data over MQTT to the broker. I have connected RST to GPIO16 so I can use the deep sleep functionality. Currently I am ...
0
votes
1answer
915 views

publish json data to mqtt

I am trying to publish JSON data to mqtt with following code snippet #include <Arduino_JSON.h> JSONVar data; data["temperature"] = temperature; data["humidity"] = humidity; data["pressure"] = ...
0
votes
1answer
132 views

How can I call the constructor of a Class after it called once? [closed]

I have a problem with Classes. I have a bunch of code, that code is uses Adafruit MQTT FONA library. I call the Class for make new Instance and Connect to specified server with this code; ...
0
votes
1answer
2k views

MQTT not working on ESP8266 (Nodemcu 0.9)

I'm trying to use NodeMCU on my ESP8266 (NodeMCU 0.9) but the board keep crashing and I don't understand why. I tested the mqtt broker using command line and it works perfectly, so I can suppose that ...
0
votes
1answer
587 views

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 <ESP8266WiFi.h> #include <PubSubClient.h> const char* ssid = "...
0
votes
2answers
1k views

esp32-cam publish image to mqtt

I want to publish image capture through ESP32-CAM to MQTT. Have following code : #include "WiFi.h" #include "esp_camera.h" #include "esp_timer.h" #include "img_converters.h" #include "Arduino.h" #...
0
votes
1answer
224 views

MQTT on nano with Ethernet shield not working

I'm using an arduino nano with an ethernet shield (ENC28J60), and ethernet eem to be working (I can create a webserver with Ethercard library).However, i'm stuck when i try to connect to a MQTT ...
0
votes
1answer
256 views

Mqtt not subscribe on topic that's converted from String to char array

I am still not sure what should be the exact Title for this question, because I don't know where the problem is. I am using #include <MQTTClient.h> mqtt library to subscribe on a topic. This ...
0
votes
2answers
583 views

Using MQTT to send time stamp - to Arduino

In previous question in this forum - I asked about updating clock on an ESP8266, using MQTT broker to send a time stamp on demand, in following manner: 1) ESP8266 sends a publish containing the ...
0
votes
1answer
1k views

ESP8266 fail to connect MQTT broker

I am using NodeMCU dev board with ESP8266 WIFI. Every time I try to connect to my local broker it returns this error: failed, rc=-2 try again in 5 seconds I am using Ubuntu 18.04, my local brokers ...
0
votes
1answer
408 views

String & Char concatenations

A newbie in Arduino- and I'm trying to concatenate string and chars ( well in python it is quite different ). I'm trying to post a MQTT message- constructed following format to the client.publish(...
0
votes
1answer
20 views

PubSubClient - MQTT_MAX_PACKET_SIZE How is it calculated

I'm using an ESP32, and I want to rule out a probable MQTT error. In PubSubClient , MQTT_MAX_PACKET_SIZE is set to 256. Is 256 the size for message only ? if not, what is left for message only ?
0
votes
2answers
30 views

writing mqtt payload to spiffs file

I'm trying to write the payload of a MQTT message into a file in the SPIFFS file system of my esp32 board. I've tried this: if(file.print((long)payload)) { Serial.println("File was written"); }...
0
votes
1answer
100 views

How to transmit data from Arduino to Raspberry Pi?

I am planning to build a network with five Arduino Mega devices, each of which will collect data using multiple sensors. Each Arduino will periodically transmit the sensor data to a gateway Raspberry ...
0
votes
1answer
482 views

cast from 'char*' to 'char' loses precision

Bit of a noob here. Im trying to use the sensor number (float) in my mqtt topic, but cant seem to get this right. Any help would be appreciated. Keep getting this error (cast from 'char*' to 'char' ...
0
votes
1answer
33 views

How to execute commands over desired amount of time

I have a program that receives 4 commands on 4 channels to change the color of an LED using mqtt communication. Lets just focus on two of the channels, the time and the red. I am sending a length of ...
0
votes
1answer
32 views

How do I change the scope of an object?

I am using the File/Examples/Adafruit MQTT Library/mqtt_ESP8266 example as a model for my code. In the example, the mqtt object is created as a global variable, and everything works fine. However, I ...
0
votes
1answer
128 views

Obtain retained MQTT message

I’m using ESP8266 with Arduino code. Each device posts a ‘state’ and an ‘avail’ messages for a specific topic. I wish to be able to read those retained messages and not only right after connecting ...
0
votes
1answer
222 views

Waking an ESP8266 from Light-Sleep using a signal from MQTT?

I was wondering if it would be possible to wake an ESP8266 from a request over MQTT while it is in Light-Sleep mode? I am planning to implement a smart switch that would receive messages from a ...
0
votes
1answer
584 views

MQTT - Can lastwill be sent to multiple topics?

I'm using an ESP8266 as an IOT device, with MQTT to send status messages. Each device have its own availability topic, to state its online or offline state ( needed for Home Assistant indication on ...
0
votes
1answer
187 views

Arduino Uno - MQTT message using PUBSUB on ESP8266

I'm trying to write code involving MQTT messages to operate an ESP8266 relay ( a Sonoff device ), using PubSub library. For some, unknown for me, reason - messages larger than 99 chars are not sent. ...
0
votes
1answer
583 views

Unable to Configure MQTT Client ID using Adafruit MQTT Library

I am utilizing the MQTT library that Adafruit has created, located here, and the library itself works wonderfully - however I am finding myself unable to edit the Client ID or configure the PINGRESP. ...
0
votes
1answer
1k views

Arduino MQTT Bluetooth

Is there a library to use MQTT with a bluetooth module (HC-06) instead of WiFi? If not is there a similar ready for use implementation of a publisher subscriber pattern available?
0
votes
0answers
16 views

Arduino Uno + NodeMCU serial to MQTT

I made a pool monitor with ORP + pH + temp sensor. I had everything working (apart from ORP sensor causing interference with pH sensor, but that is a different topic...) for the past couple days in a ...
0
votes
0answers
26 views

how to serially off leds in an esp running mqtt

hi im using at tiny 85 to monitor dc switches and to serial print with this code below to esp8266 with local broker to turn leds on and off but its only working through mqtt but not with physical ...
0
votes
1answer
27 views

ESP32 using PubSub, creating an error when implemted inside a library

I wish to combine into a single library Wifi + MQTT, for a multi devices project. right after boot, getting Wifi - I get an error the moment MQTT server is trying to connect: mqttClient.connect(...
0
votes
0answers
57 views

node mcu disconnect from mqtt server

/* Basic ESP8266 MQTT example This sketch demonstrates the capabilities of the pubsub library in combination with the ESP8266 board/library. It connects to an MQTT server then: - ...
0
votes
1answer
148 views

Convert JSON into string for MQTT

I am trying to publish json object into string with following snippet JSONVar data; data["chipid"] = chipId; data["co2_equivalent"] = co2_equivalent.c_str(); data["tvoc"] = tvoc.c_str(); data["...
0
votes
0answers
65 views

How to edit code from Node-Red to Cayenne

I am working on a project to run some (relays or LED's) on an inputs (Pins) Arduino by esp8266-01s . now while searching on internet I found a video divided it two step that talks about the issue ...
0
votes
0answers
31 views

How to set ALPN ProtocolName when negotiating SSL using ArduinoBearSSL

I am trying to set up an Arduino MKR Wifi 1010 to push MQTT messages to AWS IOT. I am following this tutorial https://create.arduino.cc/projecthub/Arduino_Genuino/securely-connecting-an-arduino-mkr-...
0
votes
0answers
172 views

Controled in the led by Arduino UNO to Firebase through ESP8266-01+ MIT App Inventor

exchange community , help me community :( I want to control led by MIT App Inventor with used Arduino UNO to Firebase through ESP8266-01 Notes : 1-The led connected pin 11 on Arduino-Uno 2-The ...
0
votes
0answers
54 views

Unable to get input from Wemos D1 PIR sensor

I am using the script below to create a motion sensor using a Wemos D1 and a PIR sensor. I'm using the ESP8266 Community board manager (V2.6.3). THE PROBLEM When I use the Wemos D1 R1 board no ...
0
votes
0answers
661 views

esp32 arduino wifi disconnect

I have this code running on ESP32 connected to SVM30-J #include <WiFi.h> #include <PubSubClient.h> #include <Arduino_JSON.h> #include <svm30.h> // Replace the next variables ...
0
votes
0answers
107 views

Mqtt setCallback with arduino mega in custom library

in pubsubclient library in method Set callback, calback is defined as MQTT_CALLBACK_SIGNATURE I found in code #if defined(ESP8266) || defined(ESP32) #include <functional> #define ...
0
votes
0answers
145 views

ESP8266 mqtt publish + subscribe + serial read

seems I have some issues in my code as I subscribe for specific mqtt topic and also read same value via serial and publish it to mqtt. It takes time for device connected to serial to change setting ...
0
votes
0answers
72 views

Constantly getting RC=-2 error with Arduino Mega and ESP8266 as the wifi module for MQTT

I am trying to use the ESP8266 as the wifi module. My connections are as follows: ESP8266 <-----------------> Arduino Mega VCC ------------------> 3.3V (converted 5V from Mega to 3.3V ...
0
votes
1answer
104 views

ESP8266 Arduino MQTT callback with dynamic topics

I have a program that depending on user input, it creates one or several objects that will publish data to a MQTT broker, each one with a different topic. This is already done. The ESP8266 also has ...
0
votes
0answers
167 views

WDT Reset with PubSubClient library for esp8266

I am using ESP8266 with arduino and PubSubClient library. With this library on esp8266, i can see esp8266 is resetting due to Watchdog reset. After google search get to know this is known issue. I was ...