Tak, ale tylko na chwilę podczas zwarcia do masy i zakładam, że nie będzie innych przycisków. Poprawię z delay() na millis()
Sonoff mini + DS18B20
Poprawiony kod, można powiedzieć czysta nowa biblioteka SuplaDevice kolegi @klew
Kod: Zaznacz cały
/*
Copyright (C) AC SOFTWARE SP. Z O.O.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include <SuplaDevice.h> // https://github.com/klew/arduino
#include <supla/network/esp_wifi.h>
#include <supla/sensor/DS18B20.h>
#include <supla/control/relay.h>
Supla::Control::Relay *dzwonkowy = nullptr;
Supla::Control::Button button(4, true);
const char* srv_addr = "xxx";
const char* srv_email = "xxx";
const char* device_name = "SONOFF MINI";
const char* wifi_ssid = "xxx";
const char* wifi_password = "xxx";
Supla::ESPWifi wifi(wifi_ssid, wifi_password);
void setup() {
uint8_t mac[6];
WiFi.macAddress(mac);
char GUID[SUPLA_GUID_SIZE] = {mac[0],mac[1],mac[2],mac[3],mac[4],mac[5],mac[0],mac[1],mac[2],mac[3],mac[4],mac[5],mac[0],mac[1],mac[2],mac[3]};
char AUTHKEY[SUPLA_AUTHKEY_SIZE] = {mac[0],mac[2],mac[4],mac[1],mac[3],mac[5],mac[1],mac[3],mac[5],mac[0],mac[2],mac[4],mac[0],mac[2],mac[4],mac[1]};
button.willTrigger(*dzwonkowy, Supla::Control::Button::ON_PRESS, Supla::Control::Relay::TOGGLE);
button.setSwNoiseFilterDelay(100);
dzwonkowy = new Supla::Control::Relay(12);
new Supla::Sensor::DS18B20(2);
SuplaDevice.setName(device_name);
SuplaDevice.begin(GUID,srv_addr,srv_email,AUTHKEY);
}
void loop() {
SuplaDevice.iterate();
}
https://www.facebook.com/groups/supladiy/
Kod: Zaznacz cały
char GUID[SUPLA_GUID_SIZE] = {mac[0],mac[1],mac[2],mac[3],mac[4],mac[5],mac[0],mac[1],mac[2],mac[3],mac[4],mac[5],mac[0],mac[1],mac[2],mac[3]};
char AUTHKEY[SUPLA_AUTHKEY_SIZE] = {mac[0],mac[2],mac[4],mac[1],mac[3],mac[5],mac[1],mac[3],mac[5],mac[0],mac[2],mac[4],mac[0],mac[2],mac[4],mac[1]};
Jasne, poprawiam.pzygmunt pisze: ↑czw lut 20, 2020 7:30 pmTo przypisanie średnio wygląda to raz, a dwa to użycie mac adresu go wygenerowania GUID-a, i AuthKey to bardzo zły pomysł.Kod: Zaznacz cały
char GUID[SUPLA_GUID_SIZE] = {mac[0],mac[1],mac[2],mac[3],mac[4],mac[5],mac[0],mac[1],mac[2],mac[3],mac[4],mac[5],mac[0],mac[1],mac[2],mac[3]}; char AUTHKEY[SUPLA_AUTHKEY_SIZE] = {mac[0],mac[2],mac[4],mac[1],mac[3],mac[5],mac[1],mac[3],mac[5],mac[0],mac[2],mac[4],mac[0],mac[2],mac[4],mac[1]};
Kod: Zaznacz cały
/*
Copyright (C) AC SOFTWARE SP. Z O.O.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include <SuplaDevice.h> // https://github.com/klew/arduino
#include <supla/network/esp_wifi.h>
#include <supla/sensor/DS18B20.h>
#include <supla/control/relay.h>
Supla::Control::Relay *dzwonkowy = nullptr;
Supla::Control::Button button(4, true);
const char* srv_addr = "xxx";
const char* srv_email = "xxx";
const char* device_name = "SONOFF MINI";
const char* wifi_ssid = "xxx";
const char* wifi_password = "xxx";
Supla::ESPWifi wifi(wifi_ssid, wifi_password);
void setup() {
// 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};
button.willTrigger(*dzwonkowy, Supla::Control::Button::ON_PRESS, Supla::Control::Relay::TOGGLE);
button.setSwNoiseFilterDelay(100);
dzwonkowy = new Supla::Control::Relay(12);
new Supla::Sensor::DS18B20(2);
SuplaDevice.setName(device_name);
SuplaDevice.begin(GUID,srv_addr,srv_email,AUTHKEY);
}
void loop() {
SuplaDevice.iterate();
}
https://www.facebook.com/groups/supladiy/
IDE bezpośrednio załaduje program na ESP.
https://www.facebook.com/groups/supladiy/