Stacja pogodowa

Awatar użytkownika
shimano73
Posty: 1968
Rejestracja: ndz lut 28, 2016 12:27 pm
Lokalizacja: Orzesze
Kontakt:

QLQ pisze: śr cze 19, 2019 10:23 pm Stacja pogody dziś dorobiła się czujnika pomiaru opadów:
.W krótce zrobię filmik aby pokazać jak on działa
.

Screenshot_2019-06-20-00-19-37.png
Gdzie udało cię kupić deszczomierz ?
W elektronice jak nie wiadomo o co chodzi to zwykle chodzi o zasilanie

Wezmę udział w Supla Offline Party 2024 :)
Awatar użytkownika
QLQ
Posty: 2276
Rejestracja: ndz wrz 03, 2017 9:13 am
Lokalizacja: Koszalin

Na aukcji allegro kupiłem dwa komplety trochę połamane ale przede wszystkim zależało mi na deszczimierzu właśnie. Za 127 zł 2x anenometr, 2x obudowa radiacyjna, 2 deszczomierze i wyswietlacze radiowe.
jak coś nie działa to włącz zasilanie.....
Awatar użytkownika
shimano73
Posty: 1968
Rejestracja: ndz lut 28, 2016 12:27 pm
Lokalizacja: Orzesze
Kontakt:

Zastanawiam się nad wyświetlaniem temperatury zewnętrznej min i max w ciągu doby , tylko w jakich godzinach je resetować . Ponieważ temperatura min zimą nie musi być przed godz. 0.00 a max latem o 12.00 . Myśle tu o temp min do godz 6.00 i max do 18 i stacja musiałaby zacząć odliczać czas i/lub uaktualniać z ntp . Jakie jest wasze zdanie w tym temacie
W elektronice jak nie wiadomo o co chodzi to zwykle chodzi o zasilanie

Wezmę udział w Supla Offline Party 2024 :)
Awatar użytkownika
wojtas567
Posty: 2209
Rejestracja: ndz kwie 03, 2016 7:16 pm
Lokalizacja: Olsztyn

Może połączyć to jakoś ze wschodem lub zachodem słońca?
Generalnie najniższa temperatura w nocy a w zasadzie nad ranem, jest między 4 - 5, najwyższa 13 - 15 więc jak zrobisz reset o północy to powinno być chyba prawidłowo.
Pozdrawiam
Wojtek
Awatar użytkownika
shimano73
Posty: 1968
Rejestracja: ndz lut 28, 2016 12:27 pm
Lokalizacja: Orzesze
Kontakt:

Witajcie , mój czujnik nasłonecznienia działa na kanale temperaturowym DS’a i wartości pokazuje ok , ale gdy przeglądam historie to wyniki kończą się na max 1000 podczas gdy online jest 50000
W elektronice jak nie wiadomo o co chodzi to zwykle chodzi o zasilanie

Wezmę udział w Supla Offline Party 2024 :)
Awatar użytkownika
wojtas567
Posty: 2209
Rejestracja: ndz kwie 03, 2016 7:16 pm
Lokalizacja: Olsztyn

Gdyż założenie jest, że wyższej temperatury jak 1000 st nie ma. Pisałem już o tym odnośnie ciśnienia 1030hPa już też nie ma :( stąd zrobiłem przelicznik na 103,0kPa żeby mieć wykresy.
Pozdrawiam
Wojtek
Awatar użytkownika
shimano73
Posty: 1968
Rejestracja: ndz lut 28, 2016 12:27 pm
Lokalizacja: Orzesze
Kontakt:

Czyli musimy czekać na dedykowany kanał ? :(
W elektronice jak nie wiadomo o co chodzi to zwykle chodzi o zasilanie

Wezmę udział w Supla Offline Party 2024 :)
Awatar użytkownika
QLQ
Posty: 2276
Rejestracja: ndz wrz 03, 2017 9:13 am
Lokalizacja: Koszalin

shimano73 pisze: czw cze 27, 2019 4:28 pm Czyli musimy czekać na dedykowany kanał ? :(
Zrób sobie na czujniku odległości. Aj mam tak. Tyle że np 65433 lux (Max dla bh1750 ) pokazuje jako 65.43km. Ale idzie się przyzwyczaić. Prosiłem wielokrotnie @pzygmunta i pewnie zrobi jak znajdzue czas.

Pod Arduino mam przerobiona bibliotekę SuplaDevice gdzie Kompiluje się normalnie kanał ciśnienia i nie trzeba to robić na termometrze.
jak coś nie działa to włącz zasilanie.....
Awatar użytkownika
QLQ
Posty: 2276
Rejestracja: ndz wrz 03, 2017 9:13 am
Lokalizacja: Koszalin

Proszę:
SuplaDevice.rar
(55.44 KiB) Pobrany 205 razy

Kod: Zaznacz cały

double get_rain(int channelNumber, double t) {
double get_Wind(int channelNumber, double t) {
double get_Weight(int channelNumber, double t) {
double get_Pressure(int channelNumber, double t) {
....
...
SuplaDevice.addRainSensor();
SuplaDevice.addWeightSensor();
SuplaDevice.addWindSensor();
SuplaDevice.addPressureSensor();
..
..
cb.get_rain = get_rain;
cb.get_wind = get_wind;
cb.get_weight = get_rain;

Kod stacji pogodowej (twoje dzieło @shimano73) lekko poddane mojej modyfikacji z właśnie czujnikiem światła na odległości, czujnikiem ciśnienia BME280 i twoim wiatromierzem - działa w moim przypadku na obrotach nie z kontaktronu a hall'a:

Kod: Zaznacz cały

/**
 * Supla.org NodeMCU WiFi minimal example
 * Author: Programistyk - Kamil Kaminski <kamil@programistyk.pl>
 * 
 * This example shows how to configure SuplaDevice for building for NodeMCU within Arduino IDE
 */


#include <srpc.h>
#include <log.h>
#include <eh.h>
#include <proto.h>
#include <IEEE754tools.h>
// We define our own ethernet layer
#define SUPLADEVICE_CPP
#include <SuplaDevice.h>
#include <DHT.h>
#include <lck.h>

#include <BH1750FVI.h>  // I2C
BH1750FVI LightSensor(BH1750FVI::k_DevModeContLowRes);

#include <WiFiClient.h>
#include <ESP8266WiFiType.h>
#include <ESP8266WiFi.h>
#include <ESP8266WiFiScan.h>
#include <ESP8266WiFiMulti.h>
#include <WiFiServer.h>
#include <ESP8266WiFiGeneric.h>
#include <WiFiClientSecure.h>
#include <ESP8266WiFiAP.h>
#include <ESP8266WiFiSTA.h>
#include <WiFiUdp.h>
#include <Bounce2.h>
WiFiClient client;



#include <Wire.h>

#include <Adafruit_Sensor.h>
#include <Adafruit_BME280.h>

#define WindImpuls 13 // GPIO 13 - nr wejścia impulsatora  anemometru
#define SEALEVELPRESSURE_HPA (1013.25) // cisnienie na poziomie morza 

Adafruit_BME280 bme; // I2C


double diameter = 2.75;
double mph; //Utworzenie zmiennej mile/godzinę
double kmh; //Utowrzenie zmiennej km/h
double ms; // Utworzenie zmiennej m/s 
double pomiar[3];
int licz_pomiar;

int rawVoltage ;
float voltage;

  
// Setup Supla connection
const char* ssid     = "xx";
const char* password = "xxxxx";

//***************************************************************************************
double get_pressure(int channelNumber, double last_val) {

    double value = -275;
    switch(channelNumber) {
      case 0: {  
     
      break;    
    } //end case 0  
        
    case 1: {   
        value = bme.readPressure() / 100;
        Serial.print("Pressure = ");
         Serial.print(value);
         Serial.println(" hPa"); 
        break;    
    } //end case 1 
   case 2: {
         value = WiFi.RSSI();
         Serial.print("WiFi meter = ");
         Serial.print(value);
         Serial.println(" dBm"); 
     break;    
    } //end case 2
      
   case 3: {  
       rawVoltage = analogRead(A0);
       voltage = 62.5 * rawVoltage / 102.4;
      value=voltage;
      Serial.print("Battery = ");
      Serial.print(value);
      Serial.println(" V"); 
      break;    
    } //end case 3      
   }
    return value;  
}
//***************************************************************************************
double  get_wind(int channelNumber, double last_val){
  
    double t = -275;  
    t=ms;
    return t;
}
//***************************************************************************************

void get_temperature_and_humidity(int channelNumber, double *temp, double *humidity) {
   *temp = bme.readTemperature();
    Serial.print("Temperature = ");
    Serial.print(bme.readTemperature());
    Serial.println(" *C");
    
    *humidity = bme.readHumidity();
    Serial.print("Humidity = ");
    Serial.print(bme.readHumidity());
    Serial.println(" %");
    if ( isnan(*temp) || isnan(*humidity) ) {
      *temp = -275;
      *humidity = -1;
    }
  
   
}
//***************************************************************************************
double get_distance(int channelNumber, double t) {

 // float lux = analogRead(LIGHTSENSORPIN);             //TEMT6000
   uint16_t lux = LightSensor.GetLightIntensity();     //BH1750
    t = abs(lux);
    Serial.print("Natezenie swiatla = ");
    Serial.print(LightSensor.GetLightIntensity());
    return t;

} //void
//***************************************************************************************
//Średnica anemometru

// Odczyt obrotĂłw (RPM)
int half_revolution_time = 0; //Utworzenie zmiennej przechowującej
double rpm = 0; //Utworzenie zmiennej RPM (obroty)
unsigned long lastmillis = 0; //Utworzenie zmiennej long lastmilis

void rpm_fan() {
  unsigned long static last_event = 0;
  if (millis() - last_event < 5) {   //debouncing
    return;
  }
  half_revolution_time = (millis() - last_event);
  last_event = millis();
}
//***************************************************************************************


void setup() {
  Serial.begin(115200);
  LightSensor.begin();  
  delay(10);
  pinMode(WindImpuls, INPUT_PULLUP);   
  attachInterrupt(digitalPinToInterrupt(WindImpuls), rpm_fan, FALLING); 
  Wire.begin(4,5);
  if (!bme.begin(0x76)) {
    Serial.println("Could not find a valid BME280 sensor, check wiring!");
    while (1);
  }
  
  // Replace the falowing GUID
    char GUID[SUPLA_GUID_SIZE] = {0xF3,0x76,0xD9,0xF8,0xB3,0x3B,0xE1,0x0E,0x53,0x1D,0xCF,0x39,0xE9,0xEE,0x21,0x38};
  // char GUID[SUPLA_GUID_SIZE] = {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
  // with GUID that you can retrieve from https://www.supla.org/arduino/get-guid

  // Ethernet MAC address
  uint8_t mac[6] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00};

  /*
   * Having your device already registered at cloud.supla.org,
   * you want to change CHANNEL sequence or remove any of them,
   * then you must also remove the device itself from cloud.supla.org.
   * Otherwise you will get "Channel conflict!" error.
   */
    
  // CHANNEL0 - RELAY
   SuplaDevice.setName("R@F_Pogoda_Firma");


   SuplaDevice.addWindSensor(); // Wind m/s
   SuplaDevice.addPressureSensor(); //Pressure
   SuplaDevice.addDS18B20Thermometer(); // Level WiFi
   SuplaDevice.addDS18B20Thermometer(); // Valtage battery
   SuplaDevice.addDHT22();  // BME T i %
   SuplaDevice.addDistanceSensor(); // Natezenie swiatla
   
   SuplaDevice.setPressureCallback(&get_pressure);
   WiFi.softAPdisconnect(true);
  
  
  SuplaDevice.begin(GUID,              // Global Unique Identifier 
                    mac,               // Ethernet MAC address
                    "svr5.supla.org",  // SUPLA server address
                    3434,                 // Location ID 
                    "vvv");               // Location Password

}
//***************************************************************************************

void loop() {
 
  SuplaDevice.iterate();
  SuplaDevice.setPressureCallback(&get_pressure);
  
    if (millis() - lastmillis >= 1000) {
    //Aktualizuj co sekundę, będzie to równoznaczne z odczytem częstotliwości (Hz)

    lastmillis = millis();          // Aktualizacja lastmillis
    
    noInterrupts();                   // W trakcie kalkulacji wyłącz obsługę przerwań
    if (half_revolution_time>0) rpm = (30000 / half_revolution_time) ;      
    interrupts() ; //Przywróć przerwania
    if (rpm>0) {
      mph = diameter / 5 * 3.14 * rpm * 60 / 5280;//Odczyt prędkości wiatru w milach/godzinę
      mph = mph * 3.5; // Kalibracja błędu odczytu, wartość należy dobrać we własnym zakresie
      kmh = mph * 1.609;// Zamiana mil/godzine na km/h
      ms = kmh / 3.6;     
   Serial.print("Wind meter = ");
      Serial.print(ms);
      Serial.println(" m/s"); 
    }
       pomiar[licz_pomiar]=ms;  
      if ((pomiar[0]==pomiar[1]) and (pomiar[1]==pomiar[2]) and (pomiar[2]==pomiar[3])) {
          ms=0;      
      }
      licz_pomiar=licz_pomiar+1;    
      if (licz_pomiar==4) licz_pomiar=0;
  
  }

}
//***************************************************************************************

// Supla.org ethernet layer
    int supla_arduino_tcp_read(void *buf, int count) {
        _supla_int_t size = client.available();
       
        if ( size > 0 ) {
            if ( size > count ) size = count;
            return client.read((uint8_t *)buf, size);
        };
    
        return -1;
    };
    
    int supla_arduino_tcp_write(void *buf, int count) {
        return client.write((const uint8_t *)buf, count);
    };
    
    bool supla_arduino_svr_connect(const char *server, int port) {
          return client.connect(server, 2015);
    }
    
    bool supla_arduino_svr_connected(void) {
          return client.connected();
    }
    
    void supla_arduino_svr_disconnect(void) {
         client.stop();
    }
    
    void supla_arduino_eth_setup(uint8_t mac[6], IPAddress *ip) {

       // Serial.println("WiFi init");
        WiFi.begin(ssid, password);

        while (WiFi.status() != WL_CONNECTED) {
            delay(500);
        //    Serial.print(".");
        }

        //Serial.print("\nlocalIP: ");
        //Serial.println(WiFi.localIP());
        //Serial.print("subnetMask: ");
        //Serial.println(WiFi.subnetMask());
        //Serial.print("gatewayIP: ");
        //Serial.println(WiFi.gatewayIP());
    }
//***************************************************************************************

SuplaDeviceCallbacks supla_arduino_get_callbacks(void) {
          SuplaDeviceCallbacks cb;
          
          cb.tcp_read = &supla_arduino_tcp_read;
          cb.tcp_write = &supla_arduino_tcp_write;
          cb.eth_setup = &supla_arduino_eth_setup;
          cb.svr_connected = &supla_arduino_svr_connected;
          cb.svr_connect = &supla_arduino_svr_connect;
          cb.svr_disconnect = &supla_arduino_svr_disconnect;        
          cb.get_temperature_and_humidity =get_temperature_and_humidity;
          cb.get_rgbw_value = NULL;
          cb.set_rgbw_value = NULL;
          cb.get_distance = NULL;
          cb.get_temperature = &get_pressure;
          cb.get_wind=&get_wind;
      cb.get_distance= get_distance;
          return cb;
}




kod deszczomierza:

Kod: Zaznacz cały

                                              /**
   Supla.org NodeMCU WiFi minimal example
   Author: Programistyk - Kamil Kaminski <kamil@programistyk.pl>

   This example shows how to configure SuplaDevice for building for NodeMCU within Arduino IDE
*/

#include <srpc.h>
#include <log.h>
#include <eh.h>
#include <proto.h>
#include <IEEE754tools.h>
// We define our own ethernet layer
#define SUPLADEVICE_CPP
#include <SuplaDevice.h>
#include <lck.h>

#include <WiFiClient.h>
#include <ESP8266WiFiType.h>
#include <ESP8266WiFi.h>
#include <ESP8266WiFiScan.h>
#include <ESP8266WiFiMulti.h>
#include <WiFiServer.h>
#include <ESP8266WiFiGeneric.h>
#include <WiFiClientSecure.h>
#include <ESP8266WiFiAP.h>
#include <ESP8266WiFiSTA.h>
#include <WiFiUdp.h>
#include <Wire.h>
#include <OneWire.h>
#include <DallasTemperature.h>

#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#include <Adafruit_Sensor.h>
#define OLED_RESET 0
Adafruit_SSD1306 display(OLED_RESET); // GPIO5 - SCL , GPIO4 -SDA


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

#define NUMFLAKES 10
#define XPOS 0
#define YPOS 1
#define DELTAY 2


#define LOGO32_GLCD_HEIGHT 32
#define LOGO32_GLCD_WIDTH  32
static const unsigned char PROGMEM temp_glcd_bmp[] =
{ // temp_home
  0x00, 0x03, 0xc0, 0x00, 0x00, 0x04, 0x20, 0x00, 0x00, 0x08, 0x10, 0x00, 0x00, 0x08, 0x50, 0x00, 
  0x00, 0x08, 0x50, 0x00, 0x00, 0x08, 0x50, 0x00, 0x00, 0x08, 0x10, 0x00, 0x00, 0x09, 0x50, 0x00, 
  0x00, 0x08, 0xd0, 0x00, 0x00, 0x0b, 0x10, 0x00, 0x00, 0x0b, 0xd0, 0x00, 0x00, 0x0b, 0xd0, 0x00, 
  0x00, 0x0b, 0xd0, 0x00, 0x00, 0x0b, 0xd0, 0x00, 0x00, 0x0b, 0xd0, 0x00, 0x00, 0x0b, 0xd0, 0x00, 
  0x00, 0x0b, 0xd0, 0x00, 0x00, 0x0b, 0xd0, 0x00, 0x00, 0x0b, 0xd0, 0x00, 0x00, 0x0b, 0xd0, 0x00, 
  0x00, 0x0b, 0xd0, 0x00, 0x00, 0x0b, 0xd0, 0x00, 0x00, 0x0b, 0xd0, 0x00, 0x00, 0x17, 0xe8, 0x00, 
  0x00, 0x2f, 0xf4, 0x00, 0x00, 0x2f, 0x94, 0x00, 0x00, 0x2f, 0xb4, 0x00, 0x00, 0x2f, 0xf4, 0x00, 
  0x00, 0x07, 0xe0, 0x00, 0x00, 0x13, 0xc8, 0x00, 0x00, 0x08, 0x10, 0x00, 0x00, 0x03, 0xc0, 0x00
};

static const unsigned char PROGMEM waga_glcd_bmp[] =
{
 0x00,0x00,0x80,0x00, // ········▌·······
  0x00,0x01,0xC0,0x00, // ·······▐█·······
  0x00,0x01,0xC0,0x00, // ·······▐█·······
  0x00,0x01,0xC0,0x00, // ·······▐█·······
  0x3F,0xFF,0xFF,0xFC, // ·██████████████·
  0x3F,0xFF,0xFF,0xFE, // ·██████████████▌
  0x3F,0xFF,0xFF,0xFE, // ·██████████████▌
  0x07,0x81,0xC0,0xF0, // ··▐█▌··▐█···██··
  0x07,0x81,0x80,0xF0, // ··▐█▌··▐▌···██··
  0x0F,0xC1,0xC1,0xF8, // ··███··▐█··▐██▌·
  0x1C,0xC1,0xC1,0x98, // ·▐█·█··▐█··▐▌▐▌·
  0x18,0xE1,0xC3,0x8C, // ·▐▌·█▌·▐█··█▌·█·
  0x38,0x61,0xC3,0x0E, // ·█▌·▐▌·▐█··█··█▌
  0x30,0x71,0xC7,0x06, // ·█··▐█·▐█·▐█··▐▌
  0xFF,0xF9,0xCF,0xFF, // ██████▌▐█·██████
  0xFF,0xF9,0xCF,0xFF, // ██████▌▐█·██████
  0xFF,0xF9,0xCF,0xFF, // ██████▌▐█·██████
  0x7F,0xF9,0xCF,0xFF, // ▐█████▌▐█·██████
  0x3F,0xF1,0xC7,0xFE, // ·█████·▐█·▐████▌
  0x3F,0xE1,0xC3,0xFE, // ·████▌·▐█··████▌
  0x0F,0xC1,0xC1,0xF8, // ··███··▐█··▐██▌·
  0x00,0x01,0xC0,0x00, // ·······▐█·······
  0x00,0x01,0xC0,0x00, // ·······▐█·······
  0x00,0x01,0xC0,0x00, // ·······▐█·······
  0x00,0x01,0xC0,0x00, // ·······▐█·······
  0x00,0x01,0x80,0x00, // ·······▐▌·······
  0x00,0x1F,0xFC,0x00, // ·····▐█████·····
  0x00,0x3F,0xFE,0x00, // ·····██████▌····
  0x00,0x3F,0xFE,0x00, // ·····██████▌····
  0x00,0x3F,0xFE,0x00, // ·····██████▌····
  0x00,0x1F,0xFC,0x00, // ·····▐█████·····
  0x00,0x00,0x00,0x00  // ················
};


static const unsigned char PROGMEM logo32_glcd_bmp[] =
{
  // 'logo SUPLA'
  0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x03, 0xf8, 0x00, 0x00, 0x07, 0xfc, 0x00, 0x00,
  0x0e, 0x0e, 0x00, 0x00, 0x0c, 0x06, 0x00, 0x00, 0x1c, 0x03, 0x00, 0x00, 0x1c, 0x03, 0x00, 0x00,
  0x1c, 0x03, 0x00, 0x00, 0x0c, 0x07, 0x00, 0x00, 0x0e, 0x0f, 0x80, 0x00, 0x07, 0xfc, 0xe0, 0x00,
  0x03, 0xf8, 0x30, 0x00, 0x00, 0xf0, 0x0d, 0xe0, 0x00, 0x10, 0x07, 0x30, 0x00, 0x18, 0x02, 0x10,
  0x00, 0x18, 0x06, 0x18, 0x00, 0x08, 0x02, 0x10, 0x00, 0x08, 0x03, 0xf0, 0x00, 0x0c, 0x07, 0xc0,
  0x00, 0x04, 0x0c, 0x00, 0x00, 0x04, 0x08, 0x00, 0x00, 0x04, 0x10, 0x00, 0x00, 0x00, 0x20, 0x00,
  0x00, 0x03, 0xc0, 0x00, 0x00, 0x04, 0x40, 0x00, 0x00, 0x0c, 0x20, 0x00, 0x00, 0x0c, 0x20, 0x00,
  0x00, 0x04, 0x40, 0x00, 0x00, 0x03, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
};
static const unsigned char PROGMEM ASL_glcd_bmp[] =
{
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 
  0x00, 0x00, 0x60, 0x00, 0x00, 0x08, 0x21, 0x00, 0x00, 0x0c, 0x03, 0x00, 0x00, 0x00, 0x62, 0x00, 
  0x00, 0x1f, 0xf8, 0x00, 0x00, 0x3f, 0x0c, 0x00, 0x00, 0x61, 0x84, 0x00, 0x00, 0xc0, 0xc4, 0xe0, 
  0x01, 0xc0, 0xf4, 0x00, 0x03, 0x00, 0x1c, 0x00, 0x06, 0x00, 0x0c, 0x00, 0x06, 0x00, 0x0c, 0x00, 
  0x06, 0x10, 0xcd, 0x00, 0x03, 0x10, 0x99, 0x00, 0x01, 0x84, 0x30, 0x00, 0x00, 0x25, 0x00, 0x00, 
  0x00, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 
  };

char* Message[] = {"This is string 1",
                   "Already initialized",
                   "Cb not assigned",
                   "Invalid GUID",
                   "Unknown server address",
                   "Unknow location ID",
                   "Initialized",
                   "Channel limit exceeded",
                   "Rozlaczony",
                   "Rejstracja w toku",
                   "Iterate fail",
                   "Protocol version error",
                   "Bad credentials",
                   "Temporarily unawaliable",
                   "Location conflict",
                   "Channel conflict",
                   "Polaczony i gotowy",
                   "Device is diasbled",
                   "Location is disabled",
                   "Device limit execeeded"
                  };



#if (SSD1306_LCDHEIGHT != 64)
//#error("Height incorrect, please fix Adafruit_SSD1306.h!");
#endif

// ***** logowanie WiFi ********************************************************************************
WiFiClient client;

// Setup Supla connection
const char* ssid     = "sssdF";
const char* password = "kcxcsd9";

char str[10];
char StatCommStr[25];
int StatCommInt;
byte Icon;
byte FiveSek;

//*****************************OPADY_DESZCZ*******************************************

double get_rain(int channelNumber, double t) {


//double t = -275;  
    t = rainrate*100;
    return t;
  
  
    
}
//**********************************WYLICZ OPADY****************************************
void count() {
  float de;
  // Grab the current ms count for common calculations
  unsigned long curtime = millis();
  
  // Make sure we don't record bounces
  if ((curtime - tiptime) < interval) {
    return;
  }
// How long since the last tip?
  unsigned long tipcount = curtime - tiptime;
  tiptime = curtime;
  
  // Calculate mm/hr from period between cup tips
  rainrate = 914400.0 / tipcount;
  
  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");  

}
//**************************#########################################################
void timer0_ISR (void) {
  FiveSek++;
  if (FiveSek==2) {
    FiveSek=0;
    Icon++;
    if (Icon==3) Icon=1;
  }
  timer0_write(ESP.getCycleCount() + 80000000L); // 80MHz == 1sec 
}

//// ******* Funkcja główna *********************************************************************************
void setup() {
 
  Serial.begin(9600); 
 // Set up our digital pin as an interrupt
  pinMode(interruptPin, INPUT_PULLUP);
  attachInterrupt(digitalPinToInterrupt(interruptPin), count, FALLING);
  
  noInterrupts();
  timer0_isr_init();
  timer0_attachInterrupt(timer0_ISR);
  timer0_write(ESP.getCycleCount() + 80000000L); // 80MHz == 1sec
  interrupts();
 
  display.begin(SSD1306_SWITCHCAPVCC, 0x3C);  // initialize with the I2C addr 0x3C (for the 128x64)
 
  Icon = 0;

  // Clear the buffer.
  display.clearDisplay();

  // text display tests
  display.setTextSize(3);
  display.setTextColor(WHITE);
  display.setRotation(2);
  display.setCursor(30, 25);
  display.print("SUPLA");
  drawbitmap(logo32_glcd_bmp, LOGO32_GLCD_HEIGHT, LOGO32_GLCD_WIDTH);
  display.display();





  // Replace the falowing GUID
char GUID[SUPLA_GUID_SIZE] = {0xF0,0xE2,0xA7,0x5A,0xF6,0xDF,0xE8,0x24,0xA6,0xAE,0x36,0x2A,0x8F,0x11,0xD7,0x18};

  //  GUID that you can retrieve from https://www.supla.org/arduino/get-guid

  // Ethernet MAC address
  uint8_t mac[6] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00};

  /*
     Having your device already registered at cloud.supla.org,
     you want to change CHANNEL sequence or remove any of them,
     then you must also remove the device itself from cloud.supla.org.
     Otherwise you will get "Channel conflict!" error.
  */
    
          // CHANNEL0 
            SuplaDevice.addRainSensor(); //deszcz czujnik
    

 
  SuplaDevice.setName("R@F_Deszcz");
  SuplaDevice.setStatusFuncImpl(&status_func);

  SuplaDevice.begin(GUID,              // Global Unique Identifier
                    mac,               // Ethernet MAC address
                    "svr5.supla.org",  // SUPLA server address
                    854645,                 // Location ID
                    "6575");               // Location Password

}


// ***********************************************************************************************************
void loop() {
  SuplaDevice.iterate();
  DisplayTemp();

}

// ****   Obsługa OLED    ****************************************************************************************************

void DisplayTemp() {

  
 
  display.clearDisplay();
  display.setTextSize(3);
  display.setTextColor(WHITE);
  display.setRotation(2);
  display.setCursor(45, 25);  
 
  switch (Icon) {
      case 1:
        display.setTextSize(4);
        display.setCursor(30, 20 );  
     //   display.print(waga, 0);
        display.print("kg" );
        drawbitmap(waga_glcd_bmp, LOGO32_GLCD_HEIGHT, LOGO32_GLCD_WIDTH);
        
        break;
        
        case 2:
        display.setTextSize(4);
        display.setCursor(30, 20 );  
     //   display.print(waga, 0);
        display.print("kg" );
      
        drawbitmap(waga_glcd_bmp, LOGO32_GLCD_HEIGHT, LOGO32_GLCD_WIDTH);
        
        break;
     
    

//---------------------        
  };
  display.setTextSize(1);
  display.setTextColor(WHITE);
  display.setCursor(0, 55);
  display.print(Message[StatCommInt - 1]);
  display.display();
  display.display();

}; //DisplayTemp

void drawbitmap(const uint8_t *bitmap, uint8_t w, uint8_t h) {
  uint8_t icons[NUMFLAKES][3];

  display.drawBitmap(0, 0, bitmap, w, h, WHITE);
} //drawbitmap


// Supla.org ethernet layer
int supla_arduino_tcp_read(void *buf, int count) {
  _supla_int_t size = client.available();

  if ( size > 0 ) {
    if ( size > count ) size = count;
    return client.read((uint8_t *)buf, size);
  };

  return -1;
};

int supla_arduino_tcp_write(void *buf, int count) {
  return client.write((const uint8_t *)buf, count);
};

bool supla_arduino_svr_connect(const char *server, int port) {
  return client.connect(server, 2015);
}

bool supla_arduino_svr_connected(void) {
  return client.connected();
}

void supla_arduino_svr_disconnect(void) {
  client.stop();
}

void supla_arduino_eth_setup(uint8_t mac[6], IPAddress *ip) {

  // Serial.println("WiFi init");
  WiFi.begin(ssid, password);

  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
        Serial.print(".");
  }

 // Serial.print("\nlocalIP: ");
 // Serial.println(WiFi.localIP());
  //Serial.print("subnetMask: ");
 // Serial.println(WiFi.subnetMask());
  //Serial.print("gatewayIP: ");
  //Serial.println(WiFi.gatewayIP());
}

SuplaDeviceCallbacks supla_arduino_get_callbacks(void) {
  SuplaDeviceCallbacks cb;

  cb.tcp_read = &supla_arduino_tcp_read;
  cb.tcp_write = &supla_arduino_tcp_write;
  cb.eth_setup = &supla_arduino_eth_setup;
  cb.svr_connected = &supla_arduino_svr_connected;
  cb.svr_connect = &supla_arduino_svr_connect;
  cb.svr_disconnect = &supla_arduino_svr_disconnect;
  cb.get_rain = get_rain;
  cb.get_temperature_and_humidity = NULL;
  cb.get_pressure = NULL; 
  cb.get_temperature = NULL;
  cb.get_rgbw_value = NULL;
  cb.set_rgbw_value = NULL;
  cb.get_distance= NULL;

  return cb;
}



void status_func(int status, const char *msg) {
  Serial.print("Status : ");
  Serial.print(status);
  StatCommInt = status;
  Serial.print(" - ");
  Serial.println(Message[StatCommInt - 1]);
  display.fillRect(0, 55, 128, 65, BLACK);

  display.setTextSize(1);
  display.setTextColor(WHITE);
  display.setRotation(2);
  display.setCursor(0, 55);
  display.print(Message[StatCommInt - 1]);
  display.display();

}

Ostatnio zmieniony pt cze 28, 2019 8:23 pm przez QLQ, łącznie zmieniany 1 raz.
jak coś nie działa to włącz zasilanie.....
Zybi
Posty: 1511
Rejestracja: ndz cze 26, 2016 4:24 pm

QLQ pisze: pt cze 28, 2019 8:06 pm ...
Pod Arduino mam przerobiona bibliotekę SuplaDevice gdzie Kompiluje się normalnie kanał ciśnienia i nie trzeba to robić na termometrze.
Szkoda tylko, że dla nieoficjalnie uruchomionych kanałów nie jest określona wartość, dla której w apce na smartfonie wyświetlane są "kreseczki", tak jak np. -275 dla temperatury, czy też -1 dla wilgotności.
ODPOWIEDZ

Wróć do „Projekty użytkowników”