Hello! I am using a raspberry 5 I have used the tutorial ESP32 Mqtt publish ds18b20. In the seriel monitor I got the temperature but the packet id say 0. In node-red it says conected.
Message: 23.31 /nPublishing on topic esp32/ds18b20/datarum6 at QoS 1, packetId: 0
And no message in debug in node-red.
And I have tested so the node-red works with an Esp8266 and the tutorial for ESP8266 NodeMCU MQTT . Both tested with no changes just password and ssid. So with Esp8266 it works.
Publishing on topic esp8266/ds18b20/datarum5 at QoS 1, packetId: 3 Message: 23.19
Publish acknowledged. packetId: 3
Hi.
Taking into account what you described, it seems to be an issue with the MQTT topic.
On the Node-RED MQTT IN node, double-check that the topic is correct. It is sensitive to lowercase or uppercase, and spaces matter too.
Let me know if that was the problem.
Regards,
Sara
Hi Sara! Thanks for your advice. I always use copy and paste to avoid such things and I have tried again without any results. I have tried several times. And I have four DS18B20 that I will use which I started with. And all four I got the temperature in the serial monitor but nothing in node-red. After that I decided to test with just one sensor and made a new fresh installation with the code from gitshub. I get it with ctrl a and then ctrl c and then paste it into a new sketch. From that sketch I also take by copying the unique topic and pasting it into node-red, everything to avoid something going wrong. And it’s not the first time I’ve tested and it has always failed with Esp32 so I’ve gotten used to Esp8266 but now I’m going to have it work with Esp32. So I’ve used the tutorial from Esp8266 which is not written in the same way as the tutorial for Esp32 so it’s a different code, I think you have observed that. I’m out of ideas what’s wrong.
And I have installed Influxdb and made sensor with Esp32 and also Esp01 and others and they have been working out of the box. But not the one Esp32 and mqtt,
Ok.
Can you tell me the exact code you’re running? So that I can also test it myself?
Also, tell me the exact library versions you’re using.
Are you using our forked version of the MQTT library? Which AsyncTCP library are you using, and which version?
It may be an issue with the library versions you’re using.
Regards,
Sara
Ok, https://raw.githubusercontent.com/RuiSantosdotme/Random-Nerd-Tutorials/master/Projects/ESP32/ESP32_MQTT/ESP32_DS18B20.ino that`s the code I use. And I use Ardiono 2.3.7 . and Async TCP version 3.4.10 and I have download the async-mqtt-client from here:https://github.com/marvinroger/async-mqtt-client/archive/master.zip renamed it to async-mqtt-clent and used add zip libery. And checked in my ardino folder and it`s there. And the compiling runs with no fault.
Hi.
Use this version of the library instead: https://github.com/RuiSantosdotme/async-mqtt-client/archive/refs/heads/develop.zip
Delete the other one.
Tell me if that fixes the issue.
Regards,
Sara
I did like this. I went to the libraries and deleted the AsyncMqttClient. Downloaded async-mqtt-client-devlop.zip. Rename the file to async-mqtt-client.zip Went to Arduion/Sketch/Include Library/Add ZIP Library The output says ok or done. Then I check in the library and ther was AsyncMqttClient I restarted the Arduino and then compiled the sketch with the same result, packetId: 0
What about the AsyncTCP library?
Which version do you have installed?
Regards,
Sara
Well I have Async TCP 3.4.10 But in the code it`s not include So I don`t understand? inklude:
freertos/FreeRTOS,freertos/timers, AsyncMqttClient, OneWire, DallasTemperature thats in the code.
Regards
Anders
You seem to have the correct libraries installed.
The AsyncMQTTClient library will automatically reference the AsyncTCP library.
I’ll try to test the code and setup tomorrow to try to understand if there’s something wrong or if there was some update with breaking changes.
Regards,
Sara
Hello!
Could I use the code as Esp8266 and just replace it with ESP32? That code says this:
#include <OneWire.h>
#include <DallasTemperature.h>
#include <ESP8266WiFi.h>
#include <Ticker.h>
#include <AsyncMqttClient.h>
So just replace #include <ESP8266WiFi.h> with #include <WiFi.h> or is there more that needs to be changed. I have this to measure temperatures for my heating system and it is cold now down to -20C so it is a great help so you don’t have to keep going and checking.
Regards
Anders
Hi! No I didn’t manage to do that and haven`t time to try. I’ve ordered some new Esp 8266 so I can get measurements on that heater also. Did you find anything wrong with Esp32 code?
Hi.
I was waiting for an answer before testing…
Anyway, I tested the project this morning. It is working as expected with the whole MQTT setup.
Your issue is probably that you forgot to insert the MQTT username and password???
Check like 123 of the code:
// If your broker requires authentication (username and password), set them below
//mqttClient.setCredentials("REPlACE_WITH_YOUR_USER", "REPLACE_WITH_YOUR_PASSWORD");
You need to uncomment that second line and replace with your MQTT username and password. Did you do that?
Regards,
Sara
Hello!
Yes I have the credentials infilled and uncomment the second line.
Message: 19.50 /nPublishing on topic esp32/ds18b20/datarum1 at QoS 1, packetId: 0 I think I have an RPI4 to test with to see if that is the fault. But now I have messurment on that heater too, from the new Esp8266 so it`s not in a hurry right now Regards Anders