Hot answers tagged

3

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 (topic, payload) Publishes a string message to the specified topic. Parameters topic - the topic to publish to (const char[]) payload - ...


3

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 multiple objects with different settings and use different objects at different times. Another option would be to modify the library to create a new function ...


3

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 better, and using delay() does not cause problems. Make sure you are up-to-date with the Board Manager definitions for ESP8266-based projects. This page has lots ...


3

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 the callback function references client The only solution is to declare the callback function before it is referenced in client initialisation, but have the ...


3

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/build So to get started : unzip the binary and update the serial2mqtt.json config. Should be piece of cake. Let me know otherwise via github.


2

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) + strlen(msg) + 3]; // Room for topic, message, [ and ] and terminating \0 sprintf(outMessage, "[%s]%s", outTopic, msg); client.publish(outTopic, outMessage); ...


2

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 Mosquitto server that can receive messages published by the ESP devices. Write and run a MQTT client on the RPi that subscribes to the messages published by the ESP ...


2

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 MQTT server itself you can connect, because it's all the same computer. However the ESP8266 is trying to connect to itself, not the MQTT server. You need to ...


2

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-ide/


2

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 is, this code: WiFi.begin(ssid, password); while (WiFi.status() != WL_CONNECTED) { delay(500); Serial.print("."); } is replaced by this in the global ...


2

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 a function and is destroyed at the end of the function. It frees the memory allocated for the internal char array. You send a pointer to the internal char ...


2

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-terminated. If these characters represent an integer value, then the way to retrieve it as an integer value would be char buffer[128]; // Make sure here ...


2

Thanks to Juraj pointing me that UIPEthernet is just a replacement for the Ethernet library, I finnally found this article Which works just fine.


2

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; /*!< Length of the buffer in bytes */ size_t width; /*!< Width of the buffer in pixels */ size_t height; /*!< ...


2

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 own MQTT server and hard coding it into the *fingerprint PROGMEM = "..." part (for example by examining the certificate via a PC browser and copying the SHA1 ...


1

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, "%016x", mac); client.publish("esp32/ChipID", macValue); However, I'm not certain that sprintf can cope with a 64 bit value like that directly. If not, you ...


1

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. If this decision needs to be made at a later time consider storing the state in the of the payload of the message on the subscriber. Also consider running Node-...


1

@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=himinds/OU=CA/CN=$IP" SUBJECT_SERVER="/C=SE/ST=Italy/L=Roma/O=himinds/OU=Server/CN=$IP" SUBJECT_CLIENT="/C=SE/ST=Italy/L=Roma/O=himinds/OU=Client/CN=$IP" ...


1

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 can hope for is a periodic wakeup to connect to the server and check for any new data. But of course that relies on the data being set to QOS 2 so it keeps ...


1

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. There are two options for correcting this depending on your needs: don't use or deeply examine and rebuild one of the libraries - frankly this was a negative ROI ...


1

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 performs a query for a service on the network.


1

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) Like: Setup: mqtt.subscribe(&motor); Loop: MQTT_connect(); Yes, you can both publish and subscribe at the same time. 2) IN THE LINE: ...


1

I had the same problem and i found out, my CH_PD pin and RST pin were shorted together, when i was connecting wire from RST to GPIO_16. On the chip, the CH_PD pin is next to GPIO_16, so when you short them, the RST pin is always high, so esp cannot reboot anymore without external grounding. I fixed it and now deep sleep is working again!


1

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-up for io 0. If you set Serial Monitor to 74880 baud, you will see the boot-log readable. It will print 1 as first value in "boot mode". This value is set ...


1

The answer for this actually goes to Juraj. It was the fact that I was missing a delay. In hindsight it makes sense, as even though I am competing tasks in order, the system is shutting down, before the actual message is sent. I added a delay(1000) between the "sendMQTTMessage()" and "ESP.deepsleep()" and it worked.


1

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 the client disconnects this stored information is published automatically by the server. The specification only allows for one topic and payload to be set. Of ...


1

In C a string is "null terminated". That means that the very last character of every string must be character 0 (or NULL). You need to ensure that you add that NULL character to the end of your incoming_msg string to terminate it, or force the entire string to be cleared to NULLs before you populate it. The simplest way is to zero the string: bzero(...


1

You forgot to set the terminating zero of the c-ctring incoming_msg. add incoming_msg[length] = 0;


1

Use the Time library a.k.a. TimeLib.h. It will keep time between calls to your source of time, if it is your MQTT call or NTP server. In your code you will use the Time library to get time and the source of the current time is independent from the rest of the code. The TimeLib has a function setTime to set the current time and then it keeps the time ...


1

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: #ifndef MQTT_MAX_PACKET_SIZE #define MQTT_MAX_PACKET_SIZE 128 #endif As it says in the PubSubClient README.md: The maximum message size, including header, is ...


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