Skip to main content
Share Your Experience: Take the 2024 Developer Survey
7 votes
Accepted

How to connect to MQTT broker with TLS?

You could make the following changes to your code by making use of WifiClientSecure (which is already part of the ESP8266 Wifi library). The tricky part is finding out the SHA1 fingerprint for your ...
StarCat's user avatar
  • 1,651
6 votes
Accepted

how to transfer json to string?

That's one of the peculiarities of the C language: the == operator compares the string addresses, not their content. It makes sense when you think of them as pointers, but it can be confusing for ...
Benoit Blanchon's user avatar
5 votes

MQTT over serial

As the author of the serial2mqtt gateway. Maybe it's time to have a new look. I've included the binaries for different platforms in the build : https://github.com/vortex314/serial2mqtt/tree/master/...
Lieven's user avatar
  • 51
4 votes

MQTT not working on ESP8266 (Nodemcu 0.9)

The Soft WDT reset means that the software watchdog timer reset. Depending on the version of Arduino core to the ESP8266 using delay() can cause this to happen, though current versions handle this ...
jose can u c's user avatar
  • 6,974
3 votes

ESP8266 MQTT client error

In C++, you can't use or reference a function before it is declared, that's not Arduino specific, it's how C++ "works" Moving the callback function above the client declaration won't help, because ...
Jaromanda X's user avatar
3 votes
Accepted

publish json data to mqtt

What's your last error message? no matching function for call to 'PubSubClient::publish(const char [11], String&)' Read the documentation for the publish() method in PubSubClient: int publish ...
romkey's user avatar
  • 1,554
3 votes
Accepted

PubSubClient - MQTT_MAX_PACKET_SIZE How is it calculated

It is the maximum size of an entire packet. In publish() this check is done: if (MQTT_MAX_PACKET_SIZE < MQTT_MAX_HEADER_SIZE + 2+strlen(topic) + plength) { So the maximum length of a message ...
Majenko's user avatar
  • 105k
3 votes

Arduino does not connect to MQTT local broker

The issue was coming from mosquitto local broker, which was being blocked by windows 10 firewall. When I executed mosquitto with the correct permissions on its folder (read and write for "all ...
bardulia's user avatar
  • 141
2 votes
Accepted

String & Char concatenations

You can't simply concatenate C strings like that. Instead you have to build them up into a new string. For formatting like that the simplest way is with sprintf: char outMessage[strlen(outTopic) + ...
Majenko's user avatar
  • 105k
2 votes

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

MQTT is perfectly suited to this application. Here is an overview of a possible configuration. You should be able to find tutorials about each piece of the system. On the Raspberry Pi: Setup a ...
Craig's user avatar
  • 2,120
2 votes
Accepted

Arduino Uno - MQTT message using PUBSUB on ESP8266

The maximum MQTT packet size in PubSubClient is 128 bytes. After all the MQTT header information that leaves only 99 bytes for a message. You can change it by editing the PubSubClient.h file: #...
Majenko's user avatar
  • 105k
2 votes
Accepted

ESP8266 fail to connect MQTT broker

127.0.0.1 is not the address of your computer. That is the address of the "loopback" interface - a virtual interface that allows a device to talk to itself. That means that when you are using the ...
Majenko's user avatar
  • 105k
2 votes
Accepted

MQTT - Can lastwill be sent to multiple topics?

The "Last Will & Testament" facility of MQTT is controlled by the server, not the client. The topic and payload are specified when the client connects as part of the connection handshaking. When ...
Majenko's user avatar
  • 105k
2 votes
Accepted

Mosquitto TLS over WifiMulti on ESP8266

The WiFiMulti has nothing to to with the MQTT and TLS side of things at all. It only has anything to do with the WiFi. As such it just replaces the code that directly interfaces with the WiFi. That ...
Majenko's user avatar
  • 105k
2 votes

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

You can't. Once constructed, an object remains constructed until you delete it. You could either use dynamic allocation and new and delete to create and destroy objects at will, or you could create ...
Majenko's user avatar
  • 105k
2 votes
Accepted

Convert byte* to int in Arduino

Judging by the comments, you are actually receiving your integer data as text, as a sequence of ASCII characters. This is what you send yourself using mosquitto_pub. The buffer is apparently not zero-...
AnT stands with Russia's user avatar
2 votes

ESP-01 not waking correctly up after deep sleep

Pretty sure you will need gpio 16 connected to reset in order for this to ever work, it’s tricky but not impossible. Have a read here: https://randomnerdtutorials.com/esp8266-deep-sleep-with-arduino-...
user54057's user avatar
2 votes
Accepted

Publish chipid to mqtt using ESP32-CAM

You would be better off formatting it nicely instead of relying on String... char macValue[17]; // Don't forget one byte for the terminating NULL... uint64_t mac = ESP.getEFuseMac(); sprintf(macValue,...
Majenko's user avatar
  • 105k
2 votes
Accepted

MQTT on nano with Ethernet shield not working

Thanks to Juraj pointing me that UIPEthernet is just a replacement for the Ethernet library, I finnally found this article Which works just fine.
Neil's user avatar
  • 143
2 votes

esp32-cam publish image to mqtt

As you can see here, the definition of the return value for esp_camera_fb_get() is typedef struct { uint8_t * buf; /*!< Pointer to the pixel data */ size_t len; ...
Maximilian Gerhardt's user avatar
2 votes

How to connect to MQTT broker with TLS?

There is an example of client certificates here. https://github.com/espressif/arduino-esp32/blob/master/libraries/WiFiClientSecure/examples/WiFiClientSecure/WiFiClientSecure.ino I believe the answer ...
Richard's user avatar
  • 21
2 votes

couldn't connect to MQTT broker via esp8266/32 and pub/sub client

I found this video as a problem solver, This may help you. All MQTT Errors explained very well and Suggester Different troubleshooting techniques https://youtu.be/CbodTTk-D18
Veera Subrahmanyam Mediboina's user avatar
2 votes

PubSubClient: Subscription working, but callback never called

nknolleary, the owner of the library, correctly identified the problem: You need to call mqttClient.loop() in you main loop. Without that, you are never giving the client a chance to check for any ...
dj_segfault's user avatar
2 votes
Accepted

I Can't Connect to my MQTT server via arduino

This is the problem: mosquitto 10436 mosquitto 4u IPv4 46043 0t0 TCP 127.0.0.1:1883 (LISTEN) Your MQTT server is listening only on port 127.0.0.1. That will accept local incoming ...
jwh20's user avatar
  • 1,045
2 votes

OTA over MQTT for ESP32

I am not familiar with OTA for ESP32 but with SAMD21 using ArduinoOTA library and there the download is not done over MQTT but HTTPS. Link to download is sent over MQTT but that's where it ends, ...
Nino's user avatar
  • 411
2 votes
Accepted

ArduinoJson library parsing error

Your shell is stripping the " from inside the string. If you run the command: $ echo "{"callbackTopic" : "xyz"}" you get: {callbackTopic : xyz} so you see all the ...
Majenko's user avatar
  • 105k
2 votes

PubSub'a - KeepAlive function not as expected

This is the correct behavior. The “last will” message is sent by the broker when it detects that the client has gone away. When you reset the ESP8266, the original connection to the broker is ...
romkey's user avatar
  • 1,554
2 votes

Arduino + ESP8266 to send MQTT messages

I didn't use MQTT yet so I didn't try any of the following options. I only know they exist. AT firmware version 2 has a set of AT commands for MQTT. But development of AT 2 for esp8266 was ended with ...
Juraj's user avatar
  • 18k
2 votes

Problem with using PubSubClient, the "callback" function doesn't seem to work correctly

From the PubSubClient library documentation: Internally, the client uses the same buffer for both inbound and outbound messages. After the callback function returns, or if a call to either publish or ...
Bra1n's user avatar
  • 1,008
1 vote

ESP-01 not waking correctly up after deep sleep

You left io 0 floating. With io 0 not HIGH at boot, the esp8266 goes into flashing mode. The wake-up from deep-sleep is boot startup. So your code doesn't start if io 0 is not pulled high. Add a pull-...
Juraj's user avatar
  • 18k

Only top scored, non community-wiki answers of a minimum length are eligible