Dzięki forum udało mi się stworzyć termometr różnicowy. ESP + 2 DS18B20. Róznica (delta) temperatury pomiędzy dwoma DS jest podawana na KPOP (GPM). Poniżej kod. Nie potrafiłem sobue poradzić z odświeżaniem delty i wrzuciłem odpowiednią instrukcję do pętli loop. Czy można inaczej? Żeby w loop pozostało tylko SuplaDevice.iterate().
Code: Select all
#include <SuplaDevice.h>
#include <DallasTemperature.h>
#include <OneWire.h>
#include <supla/network/esp_wifi.h>
#include <supla/sensor/DS18B20.h>
#include <supla/sensor/general_purpose_measurement.h>
#include <supla/device/supla_ca_cert.h>
// This program is designed to create a differential thermometer.
// It calculates the temperature difference based on readings from two thermometers DS18B20 at pin D5
// and sends this value to the gpm channel.
// Network interface:
Supla::ESPWifi wifi("your_wifi_ssid", "your_wifi_password");
// Channels DS + gpm
Supla::Sensor::DS18B20 *tt1 = nullptr;
Supla::Sensor::DS18B20 *tt2 = nullptr;
Supla::Sensor::GeneralPurposeMeasurement *gpm = nullptr;
void setup() {
Serial.begin(115200);
// Replace the falowing GUID with value that you can retrieve from https://www.supla.org/arduino/get-guid
char GUID[SUPLA_GUID_SIZE] = {0x00,0x00,0x00,0xE0,0x00,0x00,0x00,0x00,0xA3,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
// Replace the following AUTHKEY with value that you can retrieve from: https://www.supla.org/arduino/get-authkey
char AUTHKEY[SUPLA_AUTHKEY_SIZE] = {0x00,0x00,0x00,0x00,0x000x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
// Channel 0-1 - Thermometers DS18B20 at PIN D5.
// Channel 3 - General Purpose Measurement
// The DS18B20 thermometer addresses must be entered manually,
// or you can develop a function to automatically detect them.
DeviceAddress ds1addr = {0x28, 0xFA, 0xA3, 0x49, 0xF6, 0x96, 0x3C, 0x85};
DeviceAddress ds2addr = {0x28, 0xF1, 0x6D, 0x49, 0xF6, 0xE2, 0x3C, 0x70};
tt1 = new Supla::Sensor::DS18B20(D5, ds1addr);
tt2 = new Supla::Sensor::DS18B20(D5, ds2addr);
gpm = new Supla::Sensor::GeneralPurposeMeasurement();
gpm->setValue(tt1->getTemp()-tt2->getTemp());
// Configure defualt Supla CA certificate
SuplaDevice.setSuplaCACert(suplaCACert);
SuplaDevice.setSupla3rdPartyCACert(supla3rdCACert);
SuplaDevice.begin(GUID, // Global Unique Identifier
"svrxx.supla.org", // SUPLA server address
"[email protected]", // Email address used to login to Supla Cloud
AUTHKEY); // Authorization key
}
void loop() {
SuplaDevice.iterate();
gpm->setValue(tt1->getTemp()-tt2->getTemp());
}