Re: BME280 Sensor


Fernando Nino Sr
 

This is what I have for the weather tab. if I try to compile it, I get error msgs on the "weatherskytemp" not declared, also error on "double weatherskytemp". I have the lastest sketch 1.4f  and arduino 1.8.10
Thanks Nino

// -----------------------------------------------------------------------------------------------------------------
// Weather functions

#include <Wire.h>
bool outsideTempGood=false, skyTempGood=false, windspeedGood=false, pressureGood=false, humidityGood=false, rainGood=false, skyQualityGood=false;

// =================================================================================================================
// =================================== add your weather sensor support below =======================================

#include <Adafruit_Sensor.h>
#include <Adafruit_BME280.h> // I2C address 0x76 or 0x77; https://github.com/adafruit/Adafruit_BME280_Library
Adafruit_BME280 bme;


// -----------------------------------------------------------------------------------------------------------------
// gets outside temperature in deg. C

// return (invalid) if not implemented or if there's an error
double weatherOutsideTemp() {
  if (!outsideTempGood) return invalid;

  double t = bme.readTemperature();
  if (t<-60.0 || t>60.0) t=invalid;
  return t;
}

bool initOutsideTemp() {
  bool success=true;
  if (!bme.begin(0x76,&Wire)) success=false;
  return success;
}

// -----------------------------------------------------------------------------------------------------------------
// gets barometric pressure in mb

// return (invalid) if not implemented or if there's an error; absolute pressure
double weatherPressure() {
  if (!pressureGood) return (invalid);
 
  double p0 = bme.readPressure()/100.0;  // hpa to millibar
  return p0;
}

// return (invalid) if not implemented or if there's an error; sea-level adjusted pressure
double weatherPressureSeaLevel() {
  if (!pressureGood) return (invalid);
 
  double p0=bme.readPressure();
  double p1=(p0/pow((1.0-((float)(WEATHER_ALTITUDE))/44330.0), 5.255))/100.0;
  return p1;
}

bool initPressure() {
  return true;
}

// -----------------------------------------------------------------------------------------------------------------
// gets relative humidity in %

// return (invalid) if not implemented or if there's an error
double weatherHumidity() {
  if (!humidityGood) return (invalid);

  double h=bme.readHumidity();
  if (h<0.0) h=invalid;
  if (h>100.0) h=100.0;
  return h;
}

bool initHumidity() {
  return true;
}

// -----------------------------------------------------------------------------------------------------------------
// gets windspeed in kph

// return (invalid) if not implemented or if there's an error
double weatherWindspeed() {
  if (!windspeedGood) return invalid;
  return invalid;
}

bool initWindspeed() {
  return false;
}

// return (invalid) if not implemented or if there's an error
 double weatherOutsideTemp() {
   if (!outsideTempGood) return invalid;
  return invalid;
}

bool initOutsideTemp() {
  return false;
}

// -----------------------------------------------------------------------------------------------------------------
// gets sky IR temperature in deg. C

 return (invalid) if not implemented or if there's an error
 double weatherSkyTemp() {
   if (!skyTempGood) return invalid;
   return invalid;
}

bool initSkyTemp() {
  return false;
}

// -----------------------------------------------------------------------------------------------------------------
// gets windspeed in kph

// return (invalid) if not implemented or if there's an error
double weatherWindspeed() {
  if (!windspeedGood) return invalid;
  return invalid;
}

bool initWindspeed() {
  return false;
}

// -----------------------------------------------------------------------------------------------------------------
// gets barometric pressure in mb

// return (invalid) if not implemented or if there's an error, absolute pressure
double weatherPressure() {
  if (!pressureGood) return invalid;
  return invalid;
}

// return (invalid) if not implemented or if there's an error, sea-level adjusted
double weatherPressureSeaLevel() {
  if (!pressureGood) return invalid;
  return invalid;
}

bool initPressure() {
  return false;
}

// -----------------------------------------------------------------------------------------------------------------
// gets relative humidity in %

// return (invalid) if not implemented or if there's an error
double weatherHumidity() {
  if (!humidityGood) return invalid;
  return invalid;
}

bool initHumidity() {
  return false;
}

// -----------------------------------------------------------------------------------------------------------------
// gets rain sensor info. 1 is Rain, 2 is Warn, and 3 is Dry

// return (invalid) if not implemented or if there's an error
int weatherRain() {
  if (!rainGood) return invalid;
  return invalid;
}

bool initRain() {
  return false;
}

// -----------------------------------------------------------------------------------------------------------------
// gets sky brightness in mag/arc-sec^2

// return (invalid) if not implemented or if there's an error
double weatherSkyQuality() {
  if (!skyQualityGood) return invalid;
  return invalid;
}

bool initSkyQuality() {
  return false;
}

// ============================= no user changes are required beyond this point ====================================
// =================================================================================================================

Join onstep-ocs@onstep.groups.io to automatically receive all group messages.