Supla, wodomierz i czujnik odbiciowy

dobo
Posts: 1051
Joined: Sun Apr 07, 2019 8:14 pm
Location: Nadarzyn

Post

SOYER wrote: Thu Apr 06, 2023 4:00 pm Możesz, zaoszczędzisz 1.5zł :D na module, stracisz na przewodach i robociźnie.
Tu nie chodzi o oszczędność w zł, a zmniejszenie tak zbudowanego czujnika, który mógłby mieć niewiele większy wymiar jak ta tarcza z odblaskiem.
Bo to na zdjęciu poniżej jak dla mnie było nie do przyjęcia. Ponadto trzeba by było napisać i tak własny kod do ESP specjalnie pod takie rozwiązanie, a to już przewyższa na obecną chwilę moje możliwości. Chyba, że forumowy magik :D by dopisał takie rozwiązanie licznika impulsów z trzema GPIO w GG.

Ja ze swojej strony mógłbym zaprojektować obudowę dla TCRT5000.
.
1680800736565.jpg
You do not have the required permissions to view the files attached to this post.
User avatar
SOYER
Posts: 1623
Joined: Wed Aug 10, 2022 12:29 pm
Location: Kryry
Been thanked: 2 times

Post

Cześć, małe uzupełnienie.
Dzięki kolegom z forum Forbota udało mi się chyba rozwiązać problem nabijania impulsów w momencie zatrzymania kółeczka wodomierza na granicy włączenia i wyłączenia.
Moduł tcrt5000 ma w sobie komparator napięcia. Po wlutowaniu rezystora 100kOm między wejście nieodwracające oraz wyjście komparatora, ustawiamy histerezę przełączenia tego komparatora.
Problem wydaje się ustąpił. Pomimo usilnych prób nie udało mi się tak ustawić kółeczka by licznik nabijał impulsy. Teraz moduł później się załącza a wcześniej wyłącza, ale zlicza prawidłowo. Będę obserwował i dam znać za jakiś czas.
You do not have the required permissions to view the files attached to this post.
https://youtube.com/@tomaszhamer8134?si=_J1cT_QWsXxgt1Fm
https://kryry01.aqi.eco/pl
https://app.weathercloud.net/d4311785603
https://github.com/Soyer79
User avatar
SOYER
Posts: 1623
Joined: Wed Aug 10, 2022 12:29 pm
Location: Kryry
Been thanked: 2 times

Post

Jeszcze jedno, trzeba sie przyglądnąć albo zmierzyć który komparator jest użyty na płytce. Na module jest układ LM393, zawiera w sobie dwa komparatory, ale w użyciu jest tylko jeden.
nalazłem na necie schemat tego modułu tcrt5000 na którym w użyciu jest komparator nr1, jednak na mojej płytce użyty jest komparator nr2.
https://youtube.com/@tomaszhamer8134?si=_J1cT_QWsXxgt1Fm
https://kryry01.aqi.eco/pl
https://app.weathercloud.net/d4311785603
https://github.com/Soyer79
User avatar
SOYER
Posts: 1623
Joined: Wed Aug 10, 2022 12:29 pm
Location: Kryry
Been thanked: 2 times

Post

Jak zresetować ten licznik?
https://youtube.com/@tomaszhamer8134?si=_J1cT_QWsXxgt1Fm
https://kryry01.aqi.eco/pl
https://app.weathercloud.net/d4311785603
https://github.com/Soyer79
User avatar
SOYER
Posts: 1623
Joined: Wed Aug 10, 2022 12:29 pm
Location: Kryry
Been thanked: 2 times

Post

https://youtube.com/@tomaszhamer8134?si=_J1cT_QWsXxgt1Fm
https://kryry01.aqi.eco/pl
https://app.weathercloud.net/d4311785603
https://github.com/Soyer79
User avatar
SOYER
Posts: 1623
Joined: Wed Aug 10, 2022 12:29 pm
Location: Kryry
Been thanked: 2 times

Post

@klew jak zmodyfikować ten kod którym mnie już kiedyś poratowałeś do tego by zamiast temperatury wyświetlał wartość bez opisu, np z klasy impulse counter.
Chcę zrobić ustawianie wirtualnym przekaźnikiem wartości którą obsłużę w swoim kodzie.

Code: Select all

class RelayAsInput : public Supla::Control::VirtualRelay {
 public:
  explicit RelayAsInput(int step = 1) : step(step) {
  }
  virtual ~RelayAsInput() {}
  void onInit() override {}
  void turnOn(_supla_int_t duration = 0) override {

    (void)(duration);
    int newTemp = temp.getValue() + step;
    if (newTemp > 90) {
      newTemp = 90;
    }
    temp.setValue(newTemp);
    tempON = newTemp;
    sekund5.restart();
     if(menu != PIEC){
      lcd.clear();
     }
    menu = PIEC;
    Supla::Storage::ScheduleSave(2000);
  }

  void turnOff(_supla_int_t duration = 0) override {
    (void)(duration);
    int newTemp = temp.getValue() - step;
    if (newTemp < 5) {
      newTemp = 5;
    }
    temp.setValue(newTemp);
    tempON = newTemp;
    sekund5.restart();
     if(menu != PIEC){
      lcd.clear();
     }
    menu = PIEC;
    Supla::Storage::ScheduleSave(2000);
  }

  int getValue() {
    return temp.getValue();
  }

  void setValue(int value) {
    temp.setValue(value);
    Supla::Storage::ScheduleSave(2000);
  }

  void onLoadState() override {
    int temperature = 0;
    Supla::Storage::ReadState(reinterpret_cast<unsigned char *>(&temperature),
                              sizeof(int));
    temp.setValue(temperature);
    tempON = temperature;
  }

  void onSaveState() override {
    int temperature = temp.getValue();
    Supla::Storage::WriteState(reinterpret_cast<unsigned char *>(&temperature),
                               sizeof(int));
  }

 protected:
  Supla::Sensor::VirtualThermometer temp;
  int step = 1;
};
https://youtube.com/@tomaszhamer8134?si=_J1cT_QWsXxgt1Fm
https://kryry01.aqi.eco/pl
https://app.weathercloud.net/d4311785603
https://github.com/Soyer79
User avatar
SOYER
Posts: 1623
Joined: Wed Aug 10, 2022 12:29 pm
Location: Kryry
Been thanked: 2 times

Post

klew wrote: Thu Apr 06, 2023 4:55 pm
SOYER wrote: Thu Apr 06, 2023 4:47 pm Daj proszę jakiegoś linka bo zanim ja coś znajdę na forum to trochę wody upłynie.
Hm, trochę się zagalopowałem ;)
Tego jeszcze nie ma w głównym branchu.
Jest tutaj: https://github.com/SUPLA/supla-device/b ... _counter.h
Możesz skopiować ten plik i odpowiedni cpp i będzie działać
@klew dodałem ten plik do biblioteki supladevice>src>supla>sensor> jako virtual_impulse_counter.h
w szkicu dodałem:

Code: Select all

#include <supla/control/virtual_relay.h>
#include <supla/sensor/impulse_counter.h>
#include <supla/sensor/virtual_impulse_counter.h>
a potem:

Code: Select all

class RelayAsInput1 : public Supla::Control::VirtualRelay {//////////prog wody
 public:
  explicit RelayAsInput1(int step = 1) : step(step) {
  }
  virtual ~RelayAsInput1() {}
  void onInit() override {}
  void turnOn(_supla_int_t duration = 0) override {
    (void)(duration);
    int newWoda = woda.getCounter() + step;
    woda.setCounter(newWoda);
    progWody = newWoda;
    Supla::Storage::ScheduleSave(2000);
  }

  void turnOff(_supla_int_t duration = 0) override {
    (void)(duration);
    int newWoda = woda.getCounter() - step;
    woda.setCounter(newWoda);
    progWody = newWoda;
    Supla::Storage::ScheduleSave(2000);
  }

  int getValue() {
    return woda.getCounter();
  }

  void setValue(int value) {
    woda.setCounter(value);
    Supla::Storage::ScheduleSave(2000);
  }

  void onLoadState() override {
    int wod = 0;
    Supla::Storage::ReadState(reinterpret_cast<unsigned char *>(&wod),
                              sizeof(int));
    woda.setCounter(wod);
    progWody = wod;
  }

  void onSaveState() override {
    int wod = woda.getCounter();
    Supla::Storage::WriteState(reinterpret_cast<unsigned char *>(&wod),
                               sizeof(int));
  }

 protected:  Supla::Sensor::VirtualImpulseCounter woda;
  int step = 1;
};
Skompilowało się, będzie działać?

EDIT: no i w SETUP:

Code: Select all

new RelayAsInput1();
https://youtube.com/@tomaszhamer8134?si=_J1cT_QWsXxgt1Fm
https://kryry01.aqi.eco/pl
https://app.weathercloud.net/d4311785603
https://github.com/Soyer79
User avatar
SOYER
Posts: 1623
Joined: Wed Aug 10, 2022 12:29 pm
Location: Kryry
Been thanked: 2 times

Post

No i jajo bo po dodaniu w setup tego:
new RelayAsInput1();
już się nie kompiluje....
https://youtube.com/@tomaszhamer8134?si=_J1cT_QWsXxgt1Fm
https://kryry01.aqi.eco/pl
https://app.weathercloud.net/d4311785603
https://github.com/Soyer79
User avatar
SOYER
Posts: 1623
Joined: Wed Aug 10, 2022 12:29 pm
Location: Kryry
Been thanked: 2 times

Post

Gapa, nie dołączyłem pliku cpp.
Jednak po dołączeniu .cpp jest kolejny błąd i tu już nie wiem co zrobić:

Code: Select all

D:\ARDUINO\projekty\libraries\SuplaDevice\src\supla\sensor\virtual_impulse_counter.cpp: In member function 'virtual void Supla::Sensor::VirtualImpulseCounter::handleAction(int, int)':
D:\ARDUINO\projekty\libraries\SuplaDevice\src\supla\sensor\virtual_impulse_counter.cpp:67:10: error: 'INCREMENT' was not declared in this scope
     case INCREMENT: {
          ^~~~~~~~~
https://youtube.com/@tomaszhamer8134?si=_J1cT_QWsXxgt1Fm
https://kryry01.aqi.eco/pl
https://app.weathercloud.net/d4311785603
https://github.com/Soyer79
User avatar
SOYER
Posts: 1623
Joined: Wed Aug 10, 2022 12:29 pm
Location: Kryry
Been thanked: 2 times

Post

Zrobiłem powiadamianie na stałym poziomie. Jeśli zużycie przekroczy 30 litrów na minutę przychodzi powiadomienie przez Pushover.
Jak kolega @klew pomoże to zrobię ustawianie progu z aplikacji Supla.

https://youtu.be/VmGbeRZdono
https://youtube.com/@tomaszhamer8134?si=_J1cT_QWsXxgt1Fm
https://kryry01.aqi.eco/pl
https://app.weathercloud.net/d4311785603
https://github.com/Soyer79

Return to “Pomoc”