hello
i need help i can not figure it out
i want to use a arduino mega 2560 to report 12 sensors (ds18b20) trough mqtt to home assistant to report the temperature of the sensors
i can not find any detailt how to report this sensors over mqtt using a mega 2560
thank you
i have found this script but how do i send the values over mqtt to home assistant
// Include the libraries we need
#include <OneWire.h>
#include <DallasTemperature.h>
// Data wire is connected to GPIO15
#define ONE_WIRE_BUS 15
// Setup a oneWire instance to communicate with a OneWire device
OneWire oneWire(ONE_WIRE_BUS);
// Pass our oneWire reference to Dallas Temperature sensor
DallasTemperature sensors(&oneWire);
DeviceAddress sensor1 = { 0x28, 0xFF, 0x77, 0x62, 0x40, 0x17, 0x4, 0x31 };
DeviceAddress sensor2 = { 0x28, 0xFF, 0xB4, 0x6, 0x33, 0x17, 0x3, 0x4B };
DeviceAddress sensor3= { 0x28, 0xFF, 0xA0, 0x11, 0x33, 0x17, 0x3, 0x96 };
void setup(void){
Serial.begin(115200);
sensors.begin();
}
void loop(void){
Serial.print("Requesting temperatures...");
sensors.requestTemperatures(); // Send the command to get temperatures
Serial.println("DONE");
Serial.print("Sensor 1(*C): ");
Serial.print(sensors.getTempC(sensor1));
Serial.print(" Sensor 1(*F): ");
Serial.println(sensors.getTempF(sensor1));
Serial.print("Sensor 2(*C): ");
Serial.print(sensors.getTempC(sensor2));
Serial.print(" Sensor 2(*F): ");
Serial.println(sensors.getTempF(sensor2));
Serial.print("Sensor 3(*C): ");
Serial.print(sensors.getTempC(sensor3));
Serial.print(" Sensor 3(*F): ");
Serial.println(sensors.getTempF(sensor3));
delay(2000);
}