Kod: Zaznacz cały
#include <SuplaDevice.h>
#include <Arduino.h>
#include <TM1637Display.h>
#include <supla/sensor/DS18B20.h>
#include <supla/network/esp_wifi.h>
#include <supla/control/roller_shutter.h>
#include <supla/control/relay.h>
#include <supla/control/button.h>
#include <supla/control/action_trigger.h>
#include <supla/device/status_led.h>
#include <supla/storage/littlefs_config.h>
#include <supla/network/esp_web_server.h>
#include <supla/network/html/device_info.h>
#include <supla/network/html/protocol_parameters.h>
#include <supla/network/html/status_led_parameters.h>
#include <supla/network/html/wifi_parameters.h>
#define CLK 14
#define DIO 13
unsigned long previousMillis = 0;
const long interval = 1000;
int temperatura;
uint8_t stopien[]={
SEG_A|SEG_B|SEG_G|SEG_F,
SEG_A|SEG_D|SEG_E|SEG_F,
};
uint8_t errr[]={
SEG_A|SEG_D|SEG_E|SEG_F|SEG_G,
SEG_E|SEG_G,
SEG_E|SEG_G,
SEG_E|SEG_G,
};
uint8_t high[]={
SEG_B|SEG_C|SEG_E|SEG_F|SEG_G,
SEG_E|SEG_F,
SEG_A|SEG_C|SEG_D|SEG_E|SEG_F,
SEG_B|SEG_C|SEG_E|SEG_F|SEG_G,
};
Supla::ESPWifi wifi("**********", "**********");
TM1637Display display(CLK, DIO);
void setup()
{
Serial.begin(115200);
display.setBrightness(0x0f);
uint8_t mac[6];
WiFi.macAddress(mac);
// Replace the falowing GUID with value that you can retrieve from https://www.supla.org/arduino/get-guid
char GUID[SUPLA_GUID_SIZE] = {0xC6,0xEF,0x6F,0xC7,0x29,0x18,0xAE,0x0B,0x3B,0xC5,0xDB,0x9A,0x1D,0xB0,0xA3,0x3E};
// Replace the following AUTHKEY with value that you can retrieve from: https://www.supla.org/arduino/get-authkey
char AUTHKEY[SUPLA_AUTHKEY_SIZE] = {0xFC,0xC5,0x35,0xA6,0xAB,0x5F,0xAD,0x64,0x0E,0xF6,0x69,0x56,0x90,0x38,0xB3,0xF2};
DeviceAddress ds1addr = {0x28, 0xFD, 0x3A, 0x9E, 0xA, 0x0, 0x0, 0x81};
new Supla::Sensor::DS18B20(5, ds1addr);
SuplaDevice.begin(GUID, "****.supla.org", "*************", AUTHKEY);
}
void loop()
{
SuplaDevice.iterate();
unsigned long currentMillis = millis();
if (currentMillis - previousMillis >= interval)
{
temperatura = tutaj potrzebuję zmienna wstawić z odczytu;
if (temperatura == -127)
{
display.setBrightness(0x0F);
display.setSegments(errr, 4, 0);
}
else if (temperatura > 99)
{
display.setBrightness(0x0F);
display.setSegments(high, 4, 0);
}
else
{
display.setBrightness(0x0F);
display.showNumberDec(temperatura,false,2,0);
display.setSegments(stopien, 2, 2);
}
}
}