Dodałem w SUPLI sensor dystans, , jak mam do niego dopisać zmienną, którą odczytuję z czujnika odległości. Miernik laserowy po I2C. Próbowałem przerobić przykład z hc-sr04, ale ni dy rydy
Ktoś coś ?
Code: Select all
#include <SuplaDevice.h>
#include <VL53L0X.h>
#include <Wire.h>
#include <supla/sensor/distance.h>
// 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] = {0x00, 0x01, 0x02, 0x03, 0x04, 0x05};
Supla::EthernetShield ethernet(mac);
// Arduino Mega with ENC28J60:
// #include <supla/network/ENC28J60.h>
// 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("xxxxxl", "xxxxxx");
#endif
class VL53L0XDSensor : public Supla::Sensor::Distance {
public:
void onInit() {
Wire.begin();
sensor.setTimeout(500);
if (!sensor.init()) {
Serial.println("Failed to detect and initialize sensor!");
while (1) {
}
}
sensor.startContinuous();
}
double getValue() {
return 0.001 * sensor.readRangeSingleMillimeters();
}
/*
// aktualnie klasa Distance robi odczyt co 100 ms, jeśli to za szybko, to
// odkomentuj tą metodę i zmień "100" na inną wartość.
void iterateAlways() {
if (lastReadTime + 100 < millis()) {
lastReadTime = millis();
channel.setNewValue(getValue());
}
}
*/
VL53L0X sensor;
};
void setup() {
Serial.begin(9600);
auto distance = new VL53L0XDSensor;
// Replace the falowing GUID with value that you can retrieve from
// https://www.supla.org/arduino/get-guid
char GUID[SUPLA_GUID_SIZE] = {xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx};
// Replace the following AUTHKEY with value that you can retrieve from:
// https://www.supla.org/arduino/get-authkey
char AUTHKEY[SUPLA_AUTHKEY_SIZE] = {xxxxxxxxxxxxxxxxxxxxxxxxxx};
SuplaDevice.begin(
GUID, // Global Unique Identifier
"xxxxxxxxxxx", // SUPLA server address
"xxxxxxxxxxxxxxxxx", // Email address used to login to Supla Cloud
AUTHKEY); // Authorization key
}
void loop() {
SuplaDevice.iterate();
}
Dzięki, nie trzebaMcGyver_lodz wrote: Sat Jun 19, 2021 9:26 pm Super działa, gdzie mam dostarczyć piwko ? chyba że będziesz w Łodzi to stawiam