viewtopic.php?p=130298#p130298
proszę o pomoc w znalezieniu błędu, dlaczego warunek ustawiony w funkcji ustaw() nie zmienia stanu w Supli. Fizycznie stan po spełnieniu warunku ładnie się zmienia z 0 na 1, ale Supla tego nie widzi.
Poniżej szkic:
Code: Select all
#include <SuplaDevice.h>
#include <supla/sensor/thermometer.h>
#include <supla/network/esp_wifi.h>
#include <supla/control/relay.h>
Supla::ESPWifi wifi("xx,xx");
#include <ESP8266WiFi.h>
#include <ESP8266mDNS.h>
#include <WiFiUdp.h>
Supla::Control::Relay *r1 = nullptr;
int sus;
#define r1_pin D2
const int analogInPin = A0;
class AnalogValue : public Supla::Sensor::Thermometer {
public:
AnalogValue(int pin) : pin(pin) {
}
void onInit() {
pinMode(pin, INPUT);
channel.setNewValue(getValue());
}
double getValue() {
return analogRead(pin);
}
protected:
int pin;
};
void ustaw(){
sus = analogRead(analogInPin);
if(sus > 200){
r1->turnOff();
}
}
void setup() {
Serial.begin(9600);
new AnalogValue(analogInPin);
// Replace the falowing GUID with value that you can retrieve from https://www.supla.org/arduino/get-guid
char GUID[SUPLA_GUID_SIZE] = {x};
// Replace the following AUTHKEY with value that you can retrieve from: https://www.supla.org/arduino/get-authkey
char AUTHKEY[SUPLA_AUTHKEY_SIZE] = {z};
r1 = new Supla::Control::Relay(r1_pin, false);
SuplaDevice.begin(GUID, // Global Unique Identifier
"z", // SUPLA server address
"x", // Email address used to login to Supla Cloud
AUTHKEY); // Authorization key
}
void loop() {
Serial.println(analogRead(analogInPin));
Serial.print(" -----");
Serial.println(digitalRead(D2));
//ustaw();
SuplaDevice.iterate();
}
