
Czujnik wiatru i deszczu
-
- Posts: 1312
- Joined: Wed Aug 10, 2022 12:29 pm
- Location: Kryry
Tak od zera. Jeszcze kilka lat temu prosiłem szwagra, elektryka, żeby mi polutował diodę, rgb bo nie wiedziałem jak to zrobić. Z programowaniem to już całkowite zero było. Coś mnie jednak tchnęło do nauki, bo zawsze mnie do tego ciągnęło. Trafiłem na kursy Forbota i tak już poszło.
Teraz wolę główkować nad kodem, niż lutować;).
https://kryry01.aqi.eco/pl
https://app.weathercloud.net/d4311785603
https://app.weathercloud.net/d4311785603
-
- Posts: 1312
- Joined: Wed Aug 10, 2022 12:29 pm
- Location: Kryry
@Bernix, jak tam, odpaliłeś to? Działa?
https://kryry01.aqi.eco/pl
https://app.weathercloud.net/d4311785603
https://app.weathercloud.net/d4311785603
-
- Posts: 55
- Joined: Tue Jan 03, 2023 10:29 am
Witaj, jeszcze raz dziękuję. Właśnie wróciłem z małych wojaży. Kleje wszystko do kupy. Zamówiam jeszcze anemometr. Jak sklece to pokażę. Pozdrawiam serdecznie
Taki o https://a.aliexpress.com/_ExcPQjA
-
- Posts: 55
- Joined: Tue Jan 03, 2023 10:29 am
Cześć.SOYER wrote: Mon Nov 25, 2024 8:12 pm @BernixJest dodana obsługa odczytu analogowego(czujnik wilgotności gleby) na pinie A0, jako KPOP. Tylko nie wiem czy to będzie działać. Musisz sprawdzić, a przy okazji też czujnik SDS.Code: Select all
#include <SuplaDevice.h> #include <SDS011.h> // https://github.com/ricki-z/SDS011 #include <Timers.h> // https://github.com/nettigo/Timers #include <supla/sensor/DHT.h> #include <supla/network/esp_wifi.h> #include <supla/sensor/general_purpose_measurement.h> Supla::ESPWifi wifi("xx", "xx"); #define dsPin 14 //D5 #define dhtPin 5 //D1 #define windPin 12 //D6 #define rainPin 2 //D4 #define gleba_pin A0 #define rxPin 13 //D7 SDS011 #define txPin 15 //D8 SDS011 float p10, p25; int error; bool startOdczyt = 0; bool odczyt = 0; SDS011 my_sds; Timer minut5; Timer sekund30; Timer minuta; Timer sekund1; Timer sekund6; int rai=0; bool r=0; float mmM2=0; volatile int half_revolutions_time = 2; //Utworzenie zmiennej połowa pełnego obrotu (half revolutions) volatile int rpm = 0; unsigned long static last_event = 0; unsigned long static last_event1 = 0; int sample = 0; float moment_kmh; float temp_kmh; float correct_moment_kmh; float average_kmh; Supla::Sensor::GeneralPurposeMeasurement *moment_wind = nullptr; Supla::Sensor::GeneralPurposeMeasurement *average_wind = nullptr; Supla::Sensor::GeneralPurposeMeasurement *rain = nullptr; Supla::Sensor::GeneralPurposeMeasurement *P2 = nullptr; Supla::Sensor::GeneralPurposeMeasurement *P10 = nullptr; const int analogInPin = gleba_pin; class AnalogValue : public Supla::Sensor::GeneralPurposeMeasurement { public: AnalogValue(int pin) : pin(pin) { } void onInit() { pinMode(pin, INPUT); channel.setNewValue(getValue()); } double getValue() { return analogRead(pin); } protected: int pin; }; void ICACHE_RAM_ATTR rn(){// wektor przerwania deszczomierza unsigned long static last_event1 = 0; if (millis() - last_event1 < 50) { //debouncing return; } rai++; last_event1 = millis(); } void ICACHE_RAM_ATTR rpm_fan() { //funkcja rpm_fan if (millis() - last_event < 5) { //debouncing return; } half_revolutions_time = (millis() - last_event); last_event = millis(); } void temporaryRPM(){ noInterrupts(); if((last_event + 2000) < millis()){ rpm=0; moment_kmh = 0; correct_moment_kmh = 0; } else{ rpm = (30000 / half_revolutions_time) ; moment_kmh = 6.28 * 0.075 * rpm/60.0 * 3.6;// pi x promień czujnika x rpm/60s x ms->km/h if(moment_kmh < 10){ correct_moment_kmh = moment_kmh * 2.8; } else if((moment_kmh >= 10) && (moment_kmh < 25)){ correct_moment_kmh = moment_kmh * 2.7; } else if(moment_kmh >= 25){ correct_moment_kmh = moment_kmh * 2.8; } } if(sekund6.available()){ temp_kmh = temp_kmh + correct_moment_kmh; sample++; sekund6.restart(); } if(sample==10){ average_kmh = temp_kmh / 10; temp_kmh = 0; sample=0; sekund6.restart(); } interrupts() ; //Przywróć przerwania } void sds(){ if((minut5.available()) && (startOdczyt ==0)){ sekund30.restart(); startOdczyt = 1; odczyt = 1; my_sds.wakeup(); } if((sekund30.available()) && (odczyt == 1)){ error = my_sds.read(&p25, &p10); if (!error) { P2->setValue(p25); P10->setValue(p10); Serial.println("P2.5: " + String(p25)); Serial.println("P10: " + String(p10)); minut5.restart(); startOdczyt = 0; odczyt = 0; my_sds.sleep(); } } } 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] = {xx}; // Replace the following AUTHKEY with value that you can retrieve from: https://www.supla.org/arduino/get-authkey char AUTHKEY[SUPLA_AUTHKEY_SIZE] = {xx}; my_sds.begin(rxPin, txPin); //RX, TX Serial.begin(9600); new Supla::Sensor::DHT(dhtPin, DHT22); moment_wind = new Supla::Sensor::GeneralPurposeMeasurement(); average_wind = new Supla::Sensor::GeneralPurposeMeasurement(); rain = new Supla::Sensor::GeneralPurposeMeasurement(); P2 = new Supla::Sensor::GeneralPurposeMeasurement(); P10 = new Supla::Sensor::GeneralPurposeMeasurement(); new AnalogValue(analogInPin); pinMode(windPin,INPUT_PULLUP); pinMode(rainPin,INPUT_PULLUP); attachInterrupt(digitalPinToInterrupt(rainPin), rn, RISING); attachInterrupt(digitalPinToInterrupt(windPin), rpm_fan, FALLING); minut5.begin(299999); sekund30.begin(30001); minuta.begin(59999); sekund6.begin(6000); sekund1.begin(1000); last_event = millis(); last_event1 = millis(); SuplaDevice.begin(GUID, // Global Unique Identifier "svrxx.supla.org", // SUPLA server address "xxx@wp.pl", // Email address used to login to Supla Cloud AUTHKEY); // Authorization key } void loop() { SuplaDevice.iterate(); temporaryRPM(); sendSupla(); sds(); } void sendSupla(){ if(sekund1.available()){ moment_wind->setValue(correct_moment_kmh); sekund1.restart(); } if(minuta.available()){ mmM2=rai*0.15; // dwa przerwnia na jedną kolebkę, więc 0.15 rain->setValue(mmM2); average_wind->setValue(average_kmh); rai=0; minuta.restart(); } }
Od czego zacząć. Podmiana "xx" na właściwe dane, kompilacja bez uwag, flash przy pomocy ESP tool zakończony sukcesem, a urządzenie nie rejestruje się w cloud. Natomiast rozgłasza swoje wifi. Mógłbyś zweryfikować u siebie na jakiś urządzeniu ?
Pozdrawiam
-
- Posts: 1312
- Joined: Wed Aug 10, 2022 12:29 pm
- Location: Kryry
Masz włączoną rejestrację w cloud? Na pewno wgrałeś mój szkic z tego tematu? Tam nie ma webinterface ani OTA…
Czy GUI i AUTH użyte na pewno pierwszy raz?
Czy GUI i AUTH użyte na pewno pierwszy raz?
https://kryry01.aqi.eco/pl
https://app.weathercloud.net/d4311785603
https://app.weathercloud.net/d4311785603
-
- Posts: 55
- Joined: Tue Jan 03, 2023 10:29 am
Dane poprawne, twój szkic, GUID i AUTH użyte po raz pierwszySOYER wrote: Thu Dec 05, 2024 2:54 pm Masz włączoną rejestrację w cloud? Na pewno wgrałeś mój szkic z tego tematu? Tam nie ma webinterface ani OTA…
Czy GUI i AUTH użyte na pewno pierwszy raz?
-
- Posts: 1312
- Joined: Wed Aug 10, 2022 12:29 pm
- Location: Kryry
Skoro się wgrywa i uruchamia, ale pomimo włączonej rejestracji(włączyłeś?) nie loguje się do clouda, to wklej tu logi z serial monitora. Zobaczymy co jest winne.
https://kryry01.aqi.eco/pl
https://app.weathercloud.net/d4311785603
https://app.weathercloud.net/d4311785603
-
- Posts: 55
- Joined: Tue Jan 03, 2023 10:29 am
Ok. Pierwszy raz będę robił coś takiego. Proszę o cierpliwość.
-
- Posts: 1312
- Joined: Wed Aug 10, 2022 12:29 pm
- Location: Kryry
Na co to wgrywasz, jaki moduł? Miałeś tam wcześniej coś wgrane? Masz zainstalowane arduino IDE? Jak nie to zainstaluj wersję 1.8.19 jak mnie pamięć nie myli. Potem skonfiguruj go w.g. tego poradnika:
https://forbot.pl/blog/leksykon/esp8266
Jeśli masz esp32 to będą jeszcze kolejne kroki do zrobienia.
https://forbot.pl/blog/leksykon/esp8266
Jeśli masz esp32 to będą jeszcze kolejne kroki do zrobienia.
https://kryry01.aqi.eco/pl
https://app.weathercloud.net/d4311785603
https://app.weathercloud.net/d4311785603