Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Arduino demo source code for KC868-A4]-14 MQTT demo
#14
(03-06-2023, 08:11 AM)administrateur Wrote: Bon, ça marche maintenant.
I try to integrate ds18b20 I was inspired by the following tutorial   (https://randomnerdtutorials.com/esp32-mq...e-arduino/)
in the serial monitor the temperature changes well but when I listen in home assistant the temperature value does not change it is always 21.94 C

I have a doubt about the following code part
Code:
   unsigned long currentMillis = millis();
  // Every X number of seconds (interval = 10 seconds)
  // it publishes a new MQTT message
  if (currentMillis - previousMillis >= interval) {
    // Save the last time a new reading was published
    previousMillis = currentMillis;
    // New temperature readings
    sensors.requestTemperatures();
    // Temperature in Celsius degrees
    temperature1 = sensors.getTempCByIndex(0);
    // Temperature in Fahrenheit degrees
    //temp = sensors.getTempFByIndex(0);
   
    // Publish an MQTT message on topic esp32/ds18b20/temperature
  uint16_t packetIdPub1 = mqttClient.publish(MQTT_PUB_TEMP, 1, true, String(temperature1).c_str());                
  Serial.printf("Publishing on topic %s at QoS 1, packetId: ", MQTT_PUB_TEMP);
  Serial.println(packetIdPub1);
    Serial.printf("Message: %.2f /n", sensors.getTempCByIndex(0));
  }
Reply


Messages In This Thread
RE: [Arduino demo source code for KC868-A4]-14 MQTT demo - by ledouble33 - 03-09-2023, 10:40 AM

Forum Jump:


Users browsing this thread:
1 Guest(s)