Dzięki za sugestię. Spróbuję tak zobić. To pierwsze kroki. Chodziło mi aby delta załączała przekaźnik na poziomie sprzętowym (niezaleznie od sieci) i to mam. Teraz czas doskonalić kod.YoMan wrote: Thu Jan 09, 2025 9:36 pm
nie lepiej tę deltę zrobić na virtual_thermometer zamiastn gpm? od razu masz jednostki, ikonki, etc.
chyba zadziała (twierdzenie bambika, który zaczął pisać SUPLE 2 mies temu ) ewentualnie podpytaj wujaszka gpt o składnięCode: Select all
class temperatureSensor : public Supla::Sensor::VirtualThermometer { public: temperatureSensor() {} double getValue() override { return (tt1->getTemp()-tt2->getTemp()); }
źródło: https://github.com/SUPLA/supla-device/b ... eter.h#L26
Termometr różnicowy
-
- Posts: 10
- Joined: Fri Jan 03, 2025 9:06 pm
-
- Posts: 10
- Joined: Fri Jan 03, 2025 9:06 pm
Zrobione. Jest znacznie lepiej.YoMan wrote: Thu Jan 09, 2025 9:36 pm
nie lepiej tę deltę zrobić na virtual_thermometer zamiastn gpm? od razu masz jednostki, ikonki, etc.
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/virtual_thermometer.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 virtual thermometer channel.
// Network interface:
Supla::ESPWifi wifi("E______", "_______");
// Channels DS + virtual thermometer
Supla::Sensor::DS18B20 *tt1 = nullptr;
Supla::Sensor::DS18B20 *tt2 = nullptr;
Supla::Sensor::VirtualThermometer *vterm = 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,0x00,0x00,0x00,0x00,0x00,0x00,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,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
// Channel 0-1 - Thermometers DS18B20 at PIN D5.
// Channel 3 - Virtual thermometer channel
// 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);
vterm = new Supla::Sensor::VirtualThermometer();
// Initial device and channels names
SuplaDevice.setName("Termometr różnicowy");
tt1->setInitialCaption("Temperatura WY");
tt2->setInitialCaption("Temperatura WE");
vterm->setInitialCaption("∆Temp");
vterm->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
"your@email.address", // Email address used to login to Supla Cloud
AUTHKEY); // Authorization key
}
void loop() {
SuplaDevice.iterate();
vterm->setValue(tt1->getTemp()-tt2->getTemp());
}