therm_press_meter

arkadiusz.kuznik
Posts: 19
Joined: Sat Oct 15, 2022 1:51 pm

Post

Witam,
chciałbym się dowiedzieć, czy istnieje możliwość stworzenia klasy dla pomiaru temperatury i ciśnienia. Mam czujnik BMP180 i przerobioną bibliotekę BME280.h, która używa therm_hygro_press_meter.h. Wszystko działa, ale chciałbym się pozbyć pomiaru wilgotności, bo czujnik jej nie ma i wyświetlane są 3 kreski
User avatar
veeroos
Posts: 1081
Joined: Sun Mar 20, 2022 9:30 am
Location: Głogów
Has thanked: 1 time
Been thanked: 9 times

Post

viewtopic.php?p=138336#p138336

Tu jest odpowiedź na Twoje pytanie w sumie w moim temacie na temat tego czujnika 😉. Czasami warto użyć lupki 😉
Zamel Mew-01, Zamel PEW-01, Zamel SBW-01, Zamel THW-01, Zamel SRW-01, Zamel mSLW-02, Auraton BOX + Indor Sensor, Airly Gate By Veeroos, Zigbee to Supla Gateway + sensors, Zamel SGW-01 and more

https://github.com/v33r005
arkadiusz.kuznik
Posts: 19
Joined: Sat Oct 15, 2022 1:51 pm

Post

Głupi ja nie wpadłem na pomysł, żeby wyszukać bmp280. Szukałem po: czujnik/pomiar/odczyt ciśnienia.

Dzięki za podesłanie linku. Zaraz sprawdzę, czy działa.
User avatar
veeroos
Posts: 1081
Joined: Sun Mar 20, 2022 9:30 am
Location: Głogów
Has thanked: 1 time
Been thanked: 9 times

Post

Daj znać czy działa, ja z tego korzystam, ale mam czujnik BMP280 a nie jak Ty BMP180. Najwyżej przerobisz sobie tą bibliotekę od Krychy 😉
Zamel Mew-01, Zamel PEW-01, Zamel SBW-01, Zamel THW-01, Zamel SRW-01, Zamel mSLW-02, Auraton BOX + Indor Sensor, Airly Gate By Veeroos, Zigbee to Supla Gateway + sensors, Zamel SGW-01 and more

https://github.com/v33r005
arkadiusz.kuznik
Posts: 19
Joined: Sat Oct 15, 2022 1:51 pm

Post

Po drobnych przeróbkach działa. Mianowicie musiałem zakomentować jedną linijkę w odczycie ciśnienia.

Code: Select all

  double getPressure() {
    float value = PRESSURE_NOT_AVAILABLE;
    bool retryDone = false;
    do {
      if (!sensorStatus || isnan(value)) {
        sensorStatus = bmp.begin(address);
        retryDone = true;
      }
      value = PRESSURE_NOT_AVAILABLE;
      if (sensorStatus) {
        value = bmp.readPressure() / 100.0;
      }
    } while (isnan(value) && !retryDone);
    if (!isnan(altitude)) {
 //     value = bmp.seaLevelForAltitude(altitude, value);                             // tej funkcji nie obsługuje BMP085
    }
    return value;
  }

Poniżej działająca biblioteka dla czujnika BMP085 / BMP180 razem z bibliotekami od krycha88

Code: Select all

#ifndef SRC_SUPLA_SENSOR_BMP085_H_
#define SRC_SUPLA_SENSOR_BMP085_H_

// Dependency: Adafruid BMP085 library - use library manager to install it
#include <Adafruit_BMP085.h>

#include "therm_press_meter.h"

namespace Supla {
namespace Sensor {
class BMP085 : public ThermPressMeter {
 public:
  explicit BMP085(int8_t address = 0x77, float altitude = NAN)
      : address(address), sensorStatus(false), altitude(altitude) {
  }

  double getValue() {
    float value = TEMPERATURE_NOT_AVAILABLE;
    bool retryDone = false;
    do {
      if (!sensorStatus || isnan(value)) {
        sensorStatus = bmp.begin(address);
        retryDone = true;
      }
      value = TEMPERATURE_NOT_AVAILABLE;
      if (sensorStatus) {
        value = bmp.readTemperature();
      }
    } while (isnan(value) && !retryDone);
    return value;
  }

  double getPressure() {
    float value = PRESSURE_NOT_AVAILABLE;
    bool retryDone = false;
    do {
      if (!sensorStatus || isnan(value)) {
        sensorStatus = bmp.begin(address);
        retryDone = true;
      }
      value = PRESSURE_NOT_AVAILABLE;
      if (sensorStatus) {
        value = bmp.readPressure() / 100.0;
      }
    } while (isnan(value) && !retryDone);
    if (!isnan(altitude)) {
 //     value = bmp.seaLevelForAltitude(altitude, value);
    }
    return value;
  }

  void onInit() {
    sensorStatus = bmp.begin(address);

    pressureChannel.setNewValue(getPressure());
    channel.setNewValue(getValue());
  }

  void setAltitude(float newAltitude) {
    altitude = newAltitude;
  }

 protected:
  int8_t address;
  bool sensorStatus;
  float altitude;
  Adafruit_BMP085 bmp;  // I2C
};

};  // namespace Sensor
};  // namespace Supla

#endif  // SRC_SUPLA_SENSOR_BMP085_H_
Do głównego programu należy dodać

Code: Select all

#include <supla/sensor/BMP085.h>


new Supla::Sensor::BMP085();

Return to “Arduino IDE”