Rozpoczynam swoją zabawę z WEMOS D1 MINI oraz SUPLA, wgrałem z gotowych plików termometr DS18B20 podoba mi się jak to działa JEDNAK, nie chce wgrywać gotowych plików .bin jednak konfigurować mikrokontroler przez ArduinoIDE i tu jest problem. Aktualnie WEMOS pracuje jednak temperatura jest wyświetlana jako "?"
sam termometr pracuje, bo widać to w porcie szeregowym
Oczywiście nazwa i hasło WiFi są wpisane prawidłowo jednak teraz zmieniłem je na XXX
Poniżej wstawiam kod który aktualnie używam
Code: Select all
#include <SuplaDevice.h>
#include <supla/sensor/DS18B20.h>
#include <OneWire.h>
#include <DallasTemperature.h>
#define ONE_WIRE_BUS D4 // Ustaw pin danych magistrali OneWire na pin 4
// Ilość czujników
#define SENSORS_NUM 1
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);
// Choose proper network interface for your card:
#ifdef ARDUINO_ARCH_AVR
// Arduino Mega with EthernetShield W5100:
#include <supla/network/ethernet_shield.h>
// Ethernet MAC address
uint8_t mac[6] = {E0:98:06:24:60:CD};
Supla::EthernetShield ethernet(mac);
// Supla::ENC28J60 ethernet(mac);
#elif defined(ARDUINO_ARCH_ESP8266) || defined(ARDUINO_ARCH_ESP32)
// ESP8266 and ESP32 based board:
#include <supla/network/esp_wifi.h>
Supla::ESPWifi wifi("XXX", "XXX");
#endif
void setup() {
Serial.begin(115200);
sensors.begin();
// Replace the falowing GUID with value that you can retrieve from https://www.supla.org/arduino/get-guid
char GUID[SUPLA_GUID_SIZE] = {0x51,0xF5,0xF0,0x4F,0x7E,0x5E,0x22,0xC7,0xB4,0x10,0xEC,0x2E,0xB5,0x37,0x41,0x0A};
// Replace the following AUTHKEY with value that you can retrieve from: https://www.supla.org/arduino/get-authkey
char AUTHKEY[SUPLA_AUTHKEY_SIZE] = {0x67,0x27,0x68,0xD8,0x12,0xBB,0xA0,0x20,0x3E,0x5A,0x2B,0x1A,0x36,0x1D,0x1E,0x40};
// CHANNEL0-3 - Thermometer DS18B20
// 4 DS18B20 thermometers at pin 23. DS address can be omitted when there is only one device at a pin
DeviceAddress ds1addr = {0x28, 0x71, 0x63, 0x29, 0x80, 0x22, 0xB, 0x1F};
//DeviceAddress ds2addr = {0x28, 0xFF, 0x54, 0x73, 0x6E, 0x18, 0x01, 0x77};
//DeviceAddress ds3addr = {0x28, 0xFF, 0x55, 0xCA, 0x6B, 0x18, 0x01, 0x8D};
//DeviceAddress ds4addr = {0x28, 0xFF, 0x4F, 0xAB, 0x6E, 0x18, 0x01, 0x66};
new Supla::Sensor::DS18B20(23, ds1addr);
//new Supla::Sensor::DS18B20(23, ds2addr);
//new Supla::Sensor::DS18B20(23, ds3addr);
//new Supla::Sensor::DS18B20(23, ds4addr);
SuplaDevice.begin(GUID, // Global Unique Identifier
"svr105.supla.org", // SUPLA server address
"[email protected]", // Email address used to login to Supla Cloud
AUTHKEY); // Authorization key
}
void loop() {
SuplaDevice.iterate();
// Wybierz rozdzielczość (9, 10, 11, lub 12 bitów)
int resolutionBits = 12; // Możesz zmienić tę wartość
// Ustaw rozdzielczość na wszystkich czujnikach
sensors.setResolution(resolutionBits);
sensors.requestTemperatures(); // Inicjalizuje odczyt temperatury
int numberOfDevices = sensors.getDeviceCount();
// Odczytuje temperaturę z pierwszego dostępnego czujnika na magistrali OneWire
float temperatureC = sensors.getTempCByIndex(0);
// Sprawdza, czy odczyt temperatury jest prawidłowy
if (temperatureC != -127.00) {
Serial.print("Temperatura: ");
Serial.print(temperatureC);
Serial.println(" °C");
} else {
Serial.println("Błąd odczytu temperatury!");
}
delay(1000); // Poczekaj sekundę przed kolejnym odczytem
}