Address of tempsensors is published to MQTT

This commit is contained in:
Ollo
2021-04-07 20:27:42 +02:00
parent dc5dc27ba5
commit 3932e82593
4 changed files with 62 additions and 19 deletions

View File

@@ -15,3 +15,5 @@ framework = arduino
build_flags = -DPIO_FRAMEWORK_ARDUINO_LWIP2_LOW_MEMORY
lib_deps = OneWire
DallasTemperature
upload_port = /dev/ttyUSB1

View File

@@ -110,9 +110,29 @@ void setup() {
Serial.print("Bat I");
Serial.print("\t");
Serial.println("Temp/10");
}
void loop() {
static int loop=1;
DeviceAddress t;
for(int i=0; i < sizeof(t); i++) {
t[i] = loop + i*2;
}
char buf[sizeof(DeviceAddress)*2];
snprintf(buf, sizeof(buf), "%.2X%.2X%.2X%.2X%.2X%.2X%.2X%.2X", t[0], t[1], t[2], t[3], t[4], t[5], t[6], t[7]);
/*
%X -> linksbündige hexzahl
%2X -> 2Stellige hexzahl ... dynamisch erweitert
%0.2X -> 2stellige hexzahl mit führerder "0"
*/
printf("Print: %s\n", buf);
loop++;
delay(500);
return;
whatever = !whatever;
digitalWrite(OUTPUT_PUMP, HIGH);
delay(500);