Deszczomierz nowa biblioteka

QLQ
Posts: 2512
Joined: Sun Sep 03, 2017 9:13 am

Post

Czy ktoś w Was chłopaki może to przerobić na nową bibliotekę (chodzi mi o modyfikację pliku rain.h w katalogu src/supla/sensor)
Jakoś nie mogę tego ogarnąć na klasach

Code: Select all



const byte interruptPin = 12;
const int interval = 500;
volatile unsigned long tiptime = millis();
double rainrate;
unsigned long curtime;

// ##############  tak wcześniej dsefinowaliśmy ####################
//double get_rain(int channelNumber, double t) {

  //  t = rainrate*100;
    //return t;  
//}
//SuplaDevice.addRainSensor(); //deszcz czujnik   ITD  .....

//################################################################
void setup() {   // 
 
  Serial.begin(9600); 
 // Set up our digital pin as an interrupt
  pinMode(interruptPin, INPUT_PULLUP);
  attachInterrupt(digitalPinToInterrupt(interruptPin), count, FALLING);
}

void count() {
  float de;
  unsigned long curtime = millis();
  
  if ((curtime - tiptime) < interval) {
    return;
  }

  unsigned long tipcount = curtime - tiptime;
  tiptime = curtime;
  rainrate = 914400.0 / tipcount;
  //#######################  podgląd na serial #################################
 /* Serial.print("Cup tip: ");
  Serial.print(tipcount);
  Serial.println("ms");  
  
  Serial.print("Opady deszczu: ");
  Serial.print(rainrate/10);
  Serial.println("l/m2");  
  Serial.println("mm/h");  
  */
jak coś nie działa to włącz zasilanie.....
QLQ
Posts: 2512
Joined: Sun Sep 03, 2017 9:13 am

Post

:( :(
jak coś nie działa to włącz zasilanie.....
User avatar
pzygmunt
Posts: 20302
Joined: Tue Jan 19, 2016 9:26 am
Location: Paczków
Been thanked: 59 times

Post

Uśmiechnij się do @klew
SUPLA.... Nareszcie w domu.
User avatar
klew
Posts: 13909
Joined: Thu Jun 27, 2019 12:16 pm
Location: Wrocław
Has thanked: 135 times
Been thanked: 137 times

Post

Taka szybka przeróbka (do umieszczenia w pliku ino projektu):

Code: Select all

#include <supla/sensor/rain.h>

const byte interruptPin = 12;
const int interval = 500;
volatile unsigned long tiptime = millis();
double rainrate;
unsigned long curtime;

void count() {
  unsigned long curtime = millis();
  
  if ((curtime - tiptime) < interval) {
    return;
  }

  unsigned long tipcount = curtime - tiptime;
  tiptime = curtime;
  rainrate = 914400.0 / tipcount;
}

class MyRain : public Supla::Sensor::Rain {
  public:

    double getValue() {
      return rainrate*100.0;
    }
};

void setup() {   // 
 
  Serial.begin(9600); 
 // Set up our digital pin as an interrupt
  pinMode(interruptPin, INPUT_PULLUP);
  attachInterrupt(digitalPinToInterrupt(interruptPin), count, FALLING);

  new MyRain;
}

Zliczanie nadal jest na przerwaniu w metodzie "count". Klasa MyRain zwraca wartość zmiennej globalnej, więc będzie to działać dla jednego czujnika deszczu. Przy dwóch już nie da rady, ale myślę, że więcej niż jeden nie potrzeba.
Najlepsze suple dla Twojego domu :mrgreen:
QLQ
Posts: 2512
Joined: Sun Sep 03, 2017 9:13 am

Post

zARAZ COŚ ROZPIERDZIELĘ!!!!!!!!!!


NIBY SIĘ KOMIPLUJE I WGRYWA ALE CAŁY CZAS MODUŁ SIĘ rESTRTUJE wtf!!!????

Code: Select all

#include <SPI.h>
#include <SuplaDevice.h>



#include <supla/sensor/Anemometr.h>
#include <supla/sensor/BME280.h>
#include <supla/sensor/GLSBH1750.h>
#include <supla/sensor/rain.h>



#include <supla/network/esp_wifi.h>

Supla::ESPWifi wifi("rrrF", rrr9");


//#define WIND_FACTOR 2.400 // km/h
#define WIND_FACTOR 0.6666 // m/s
#define MODE_REAL  0 // The actual wind speed
#define MODE_TIME  1 // The wind speed is averaged at sampleTime or when you ask, whichever is longer 

#define ANEMOMETR_PIN 12
//#define RAIN_PIN 13

const byte interruptPin = 12;
const int interval = 500;
volatile unsigned long tiptime = millis();
double rainrate;
unsigned long curtime;

void count() {
  unsigned long curtime = millis();
  
  if ((curtime - tiptime) < interval) {
    return;
  }

  unsigned long tipcount = curtime - tiptime;
  tiptime = curtime;
  rainrate = 914400.0 / tipcount;
}

class MyRain : public Supla::Sensor::Rain {
  public:

    double getValue() {
      return rainrate*100.0;
    }
};

void setup() {

  Serial.begin(9600); 
 // Set up our digital pin as an interrupt
  pinMode(interruptPin, INPUT_PULLUP);
  attachInterrupt(digitalPinToInterrupt(interruptPin), count, FALLING);

  new MyRain;

  // Replace the falowing GUID with value that you can retrieve from https://www.supla.org/arduino/get-guid
  char GUID[SUPLA_GUID_SIZE] = {0x90, 0x7B, 0xD8, 0x9B, 0x7F, 0x9A, 0x71, 0x2E, 0xF5, 0x95, 0x36, 0xC6, 0xAE, 0x4D, 0x1A, 0x8D};

  // Replace the following AUTHKEY with value that you can retrieve from: https://www.supla.org/arduino/get-authkey
  char AUTHKEY[SUPLA_AUTHKEY_SIZE] = {0xF0, 0xB5, 0xBC, 0xC7, 0x96, 0xA4, 0x00, 0x14, 0x93, 0x5E, 0xDD, 0x53, 0x08, 0x4A, 0xF6, 0x03};


  new Supla::Sensor::Anemometr(ANEMOMETR_PIN, WIND_FACTOR, MODE_TIME );
  new Supla::Sensor::Rain();
  new Supla::Sensor::BME280(0x76, 100);
  new Supla::Sensor::GLSBH1750();



  /*
     SuplaDevice Initialization.
  */
  SuplaDevice.setName("Test R@F");
  SuplaDevice.begin(GUID,              // Global Unique Identifier
                    "svrx.supla.org",  // SUPLA server address
                    "[email protected]",   // Email address used to login to Supla Cloud
                    AUTHKEY);          // Authorization key

}

void loop() {
  SuplaDevice.iterate();
}


jak coś nie działa to włącz zasilanie.....
krycha88
Posts: 5575
Joined: Fri Nov 16, 2018 7:25 am
Been thanked: 5 times

Post

Po co dodajesz Supla::Sensor::Rain()? Wystarczy new MyRain;
https://gui-generic-builder.supla.io/
User avatar
klew
Posts: 13909
Joined: Thu Jun 27, 2019 12:16 pm
Location: Wrocław
Has thanked: 135 times
Been thanked: 137 times

Post

QLQ wrote: Mon Mar 29, 2021 5:54 pm NIBY SIĘ KOMIPLUJE I WGRYWA ALE CAŁY CZAS MODUŁ SIĘ rESTRTUJE wtf!!!???
Coś w logach widać?
Najlepsze suple dla Twojego domu :mrgreen:
QLQ
Posts: 2512
Joined: Sun Sep 03, 2017 9:13 am

Post

krycha88 wrote: Mon Mar 29, 2021 5:59 pm Po co dodajesz Supla::Sensor::Rain()? Wystarczy new MyRain;
jak jest zaremowane // też to samo się dzieje :( tu nie zauważyłem wkejając

jakie macie blbki płytrek ESP8266 w Arduino ?


log czy com?

tu co na porcie:

Code: Select all

--------------- CUT HERE FOR EXCEPTION DECODER ---------------

Abort called

>>>stack>>>

ctx: cont
sp: 3ffffed0 end: 3fffffc0 offset: 0000
3ffffed0:  feefeffe feefeffe feefeffe 00000100  
3ffffee0:  000000fe 00000000 00000000 00000000  
3ffffef0:  00000000 00000000 00000000 00ff0000  
3fffff00:  5ffffe00 5ffffe00 3fff0ccc 00000000  
3fffff10:  00000002 0000000d 3ffefe08 4020a2be  
3fffff20:  401007b6 4020bbc1 ffffffff 4020a2d0  
3fffff30:  feefeffe 00000001 3ffefe08 4020af11  
3fffff40:  00000000 00000001 3ffefd0c 40209074  
3fffff50:  00000000 feefeffe feefeffe 3ffefe48  
3fffff60:  3fffdad0 00000000 3ffefe08 4020afc0  
3fffff70:  3fffdad0 00000000 3ffefe08 40201cd1  
3fffff80:  feefeffe feefeffe feefeffe feefeffe  
3fffff90:  feefeffe feefeffe feefeffe feefeffe  
3fffffa0:  3fffdad0 00000000 3ffefe08 40209e78  
3fffffb0:  feefeffe feefeffe 3ffe8504 401010c1  
<<<stack<<<

--------------- CUT HERE FOR EXCEPTION DECODER ---------------
H)ԅ⸮⸮⸮-⸮ISR not in IRAM!

User exception (panic/abort/assert)
--------------- CUT HERE FOR EXCEPTION DECODER ---------------

Abort called

jakie logi ?
jak coś nie działa to włącz zasilanie.....
krycha88
Posts: 5575
Joined: Fri Nov 16, 2018 7:25 am
Been thanked: 5 times

Post

zacznij od dodania jednego czujnika później dodaj kolejny itd. wtedy napisz który fragment kodu powoduje problem.
https://gui-generic-builder.supla.io/
User avatar
klew
Posts: 13909
Joined: Thu Jun 27, 2019 12:16 pm
Location: Wrocław
Has thanked: 135 times
Been thanked: 137 times

Post

Zmień na
void ICACHE_RAM_ATTR count () {
Najlepsze suple dla Twojego domu :mrgreen:

Return to “Pomoc”