Last call to make your voice heard! Our 2022 Developer Survey closes in less than a week. Take survey.

Hot answers tagged

6 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 ...
user avatar
  • 1,370
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 ...
user avatar
  • 6,922
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 ...
user avatar
3 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/...
user avatar
  • 31
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 ...
user avatar
  • 1,169
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) + ...
user avatar
  • 101k
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 ...
user avatar
  • 2,090
2 votes

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: #...
user avatar
  • 101k
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 ...
user avatar
  • 101k
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 ...
user avatar
  • 101k
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 ...
user avatar
  • 101k
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-...
user avatar
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-...
user avatar
  • 821
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,...
user avatar
  • 101k
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.
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; ...
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 ...
user avatar
  • 21
2 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 ...
user avatar
  • 101k
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
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 ...
user avatar
  • 1,016
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 ...
user avatar
  • 101k
1 vote

Obtain retained MQTT message

Once a message has passed through an MQTT broker there is not a way to retrieve it from the broker. Consider instead deciding upon the action at the time the message is received by the subscriber. ...
user avatar
  • 6,451
1 vote

Impossible to connect ESP32 with Mosquitto on Raspberry using certificates

@sempaiscuba and Bruno I solved by regenerating the certificates in this way you have to do this comfortably script in Raspiberry #!/bin/bash IP="192.168.0.11" SUBJECT_CA="/C=SE/ST=Italy/L=Roma/O=...
user avatar
  • 29
1 vote
Accepted

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? No. The ESP8266 has to be awake to communicate with the MQTT server. The best you ...
user avatar
  • 101k
1 vote

MQTT PubSubClient connection problem with ESP32

When you set the server from a C string it doesn't copy the string - it just retains a pointer to it: PubSubClient& PubSubClient::setServer(const char * domain, uint16_t port) { this->...
user avatar
  • 101k
1 vote

Connecting to MQTT causes DHT11 Sensor to stop working?

Leaving this here in case anyone else has a similar issue as an "answer" to my own question: Simply put - DHT11 library as used, and MQTT library as used conflict. That's it, that's the answer. ...
user avatar
1 vote

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

You should use mDNS. Install (if it isn't already) avahi-daemon on your Raspberry. Then check out the ESP8266mDNS library and the examples it has. Especially the mDNS-SD_Extended example, which ...
user avatar
  • 101k
1 vote

Convert byte* to int in Arduino

Don't know if you found an answer yet, but I had the exact same issue and eventually came up with this: payload[length] = '\0'; // Add a NULL to the end of the char* to make it a string. int ...
user avatar
1 vote

Notoriously unstable ESP8266 MQTT-client

I use adafruit mqtt library. After a few fixes, it is running very stable. Tips: 1) Make sure you put subscribe line BEFORE connecting to mqtt (you can put it in setup and connect to mqtt in loop) ...
user avatar
  • 11
1 vote
Accepted

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

The c_str() function of the String class returns a pointer to current internal char array. This pointer is valid only until the String exists and is not changed. Variable espInTopicStr is defined in ...
user avatar
  • 16.1k

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