Is it possible to build loop for this:
DS18B20.requestTemperaturesByAddress(tP200);
t = DS18B20.getTempC(tP200);
if (t > -100) {tempString += sP200 + "=" + t + "&";}
DS18B20.requestTemperaturesByAddress(TEST);
t = DS18B20.getTempC(TEST);
if (t > -100) { tempString += sTEST + "=" + t + "&"; }
DS18B20.requestTemperaturesByAddress(tP5);
t = DS18B20.getTempC(tP5);
if (t > -100) { tempString += sP5 + "=" + t + "&"; }
DS18B20.requestTemperaturesByAddress(tG5);
t = DS18B20.getTempC(tG5);
if (t > -100) { tempString += sG5 + "=" + t + "&"; }
DS18B20.requestTemperaturesByAddress(tG10);
t = DS18B20.getTempC(tG10);
if (t > -100) { tempString += sG10 + "=" + t + "&"; }
Full code are here:
#include <OneWire.h>
#include <DallasTemperature.h>
//DEKLARACJA ADRESÓW DS18B20
DeviceAddress tP200 = {0x28, 0xFF, 0x4F, 0xEA, 0xB3, 0x16, 0x03, 0x60};
DeviceAddress tP5 = {0x28, 0xFF, 0x32, 0x70, 0xB3, 0x16, 0x05, 0xC6};
DeviceAddress tG5 = {0x28, 0xFF, 0x5F, 0x8D, 0xB3, 0x16, 0x04, 0x89};
DeviceAddress tG10 = {0x28, 0xFF, 0xC0, 0x30, 0xB5, 0x16, 0x05, 0xD2};
DeviceAddress tG20 = {0x28, 0xFF, 0x01, 0x0B, 0xB5, 0x16, 0x05, 0xE1};
DeviceAddress tG50 = {0x28, 0xFF, 0xD4, 0xE6, 0xB3, 0x16, 0x03, 0xB5};
DeviceAddress tG100 = {0x28, 0xFF, 0xC1, 0xE8, 0xB3, 0x16, 0x03, 0x0E};
DeviceAddress tG200 = {0x28, 0xFF, 0x92, 0xC3, 0xB3, 0x16, 0x05, 0xEC};
DeviceAddress tS = {0x10, 0xED, 0xDF, 0x39, 0x01, 0x08, 0x00, 0xAF};
DeviceAddress TEST = {0x10, 0xCD, 0x0D, 0x39, 0x01, 0x08, 0x00, 0xC4};
//DEKLARACJA ADRESÓW JAKO String
String sP200 = "28FF4FEAB3160360";
String sP5 = "28FF3270B31605C6";
String sG5 = "28FF5F8DB3160489";
String sG10 = "28FFC030B51605D2";
String sG20 = "28FF010BB51605E1";
String sG50 = "28FFD4E6B31603B5";
String sG100 = "28FFC1E8B316030E";
String sG200 = "28FF92C3B31605EC";
String sS = "10EDDF39010800AF";
String sTEST = "10CD0D39010800C4";
#define ONE_WIRE_BUS 5
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature DS18B20(&oneWire);
void setup() {
Serial.begin(74880);
}
void loop() {
float t;
String tempString = "?";
DS18B20.requestTemperaturesByAddress(tP200);
t = DS18B20.getTempC(tP200);
if (t > -100) {tempString += sP200 + "=" + t + "&";}
DS18B20.requestTemperaturesByAddress(TEST);
t = DS18B20.getTempC(TEST);
if (t > -100) { tempString += sTEST + "=" + t + "&"; }
DS18B20.requestTemperaturesByAddress(tP5);
t = DS18B20.getTempC(tP5);
if (t > -100) { tempString += sP5 + "=" + t + "&"; }
DS18B20.requestTemperaturesByAddress(tG5);
t = DS18B20.getTempC(tG5);
if (t > -100) { tempString += sG5 + "=" + t + "&"; }
DS18B20.requestTemperaturesByAddress(tG10);
t = DS18B20.getTempC(tG10);
if (t > -100) { tempString += sG10 + "=" + t + "&"; }
tempString.remove(tempString.length()-1);
Serial.println(tempString);
}