BMP280 not showing results

Discussion about Z-Uno product. Visit http://z-uno.z-wave.me for more details.
Post Reply
karlbaker
Posts: 13
Joined: 03 Mar 2019 12:04

BMP280 not showing results

Post by karlbaker »

Hey everybody,

I'm still relatively new to this kind of development, and am trying to build a weather station using the BMP280 sensor to capture the barometric pressure and humidity. The sensor is not delivering these values, and I'd like to ask if someone could point me in the right direction.

I have wired the sensor to the Z-Uno I2C pins 9 and 10 according to the information I found at Z-Uno.Z-wave.me and comparing these to the pins needed as described in the Adafruit I2C wiring guide. With this, the SCK pin is at pin 9 on the Z-Uno, and the SDI pin on pin 10. Below is the code I wrote to simply test functionality before I attempt to write the values to a database. The serial monitor reports only zero values.

I have studied the forum and looked at some things and tried them out. I also looked to see if a new version of the library is available, but I have the newest. I'm using the Z-Uno library 2.1.5 in the Arduino IDE.

I would greatly appreciate any help anyone could provide.

Thanks,

Karl

Code: Select all

#include <ZUNO_BMP280.h>

// Barometric pressure sensor
ZUNO_BMP280 bmp;

boolean foundBmp;
int barometricPressure; // here we will store the barometric pressure
int humidity; // here we will store the humidity

void setup() {
  // put your setup code here, to run once:
   Serial.begin();
   Serial.println("start");
   foundBmp = bmp.begin();
}

void loop() {
  // put your main code here, to run repeatedly:

    if (foundBmp = true) {
      // Get barometric pressure
      barometricPressure = bmp.readPressurePa()/10;
      // Get humidity
      humidity = bmp.readHumidityH10()/10;
      Serial.print("Pressure = ");
      Serial.print(barometricPressure);
      Serial.println(" Pa");
      Serial.print("Humidity = ");
      Serial.print(humidity);
      Serial.println(" %");
    } else {
       Serial.println("Could not find a valid BMP280 sensor, check wiring!");
    }

    // send every 10 second
    delay(10000);

}
User avatar
PoltoS
Posts: 7571
Joined: 26 Jan 2011 19:36

Re: BMP280 not showing results

Post by PoltoS »

This example has no Z-Wave channels. You should add them. Please have a look on some other example for setting up channels
karlbaker
Posts: 13
Joined: 03 Mar 2019 12:04

Re: BMP280 not showing results

Post by karlbaker »

Ahhh, ok. Thanks for pointing that out. I'll add some and get back to you.
karlbaker
Posts: 13
Joined: 03 Mar 2019 12:04

Re: BMP280 not showing results

Post by karlbaker »

Hi PoltoS,

I have added the channels to the sketch, but that was no help. I also have a DS18B20 already attached to pin 11, and it has been working fine. The BMP280 sensor I added for the first time over the weekend for testing.

The Z-Uno is fining the BMP280 sensor, but no values are being returned. In addition, on the RPi where I have the main RazBerry controller and am capturing the data sent from the channels, no information is coming over from the additional 2 channels created.

Below is the sketch as it is now. I appreciate your help, but am I missing any initialization that needs to be done?

Thanks,

Karl

Code: Select all

#include <ZUNO_definitions.h>
#include <ZUNO_OneWire.h>
#include <ZUNO_DS18B20.h>
#include <ZUNO_BMP280.h>

// pin connection ds18b20
#define PIN_DS18B20 11

OneWire ow(PIN_DS18B20);

// onewire connection temperature sensors
DS18B20Sensor ds1820(&ow); 
// Barometric pressure sensor
ZUNO_BMP280 bmp;

/* set up channels
 * 1. Temperature sensor DS18B20
 * 2. Humidity sensor BMP280
 * 3. Barometric pressure sensor BMP280
*/

ZUNO_SETUP_CHANNELS(ZUNO_SENSOR_MULTILEVEL(ZUNO_SENSOR_MULTILEVEL_TYPE_TEMPERATURE,
                                           SENSOR_MULTILEVEL_SCALE_CELSIUS,
                                           SENSOR_MULTILEVEL_SIZE_TWO_BYTES,
                                           SENSOR_MULTILEVEL_PRECISION_TWO_DECIMALS,
                                           getterTemp),
                    ZUNO_SENSOR_MULTILEVEL(ZUNO_SENSOR_MULTILEVEL_TYPE_RELATIVE_HUMIDITY,
                                           SENSOR_MULTILEVEL_SCALE_PERCENTAGE_VALUE,
                                           SENSOR_MULTILEVEL_SIZE_ONE_BYTE,
                                           SENSOR_MULTILEVEL_PRECISION_ONE_DECIMAL,
                                           getterHumidity),
                    ZUNO_SENSOR_MULTILEVEL(ZUNO_SENSOR_MULTILEVEL_TYPE_BAROMETRIC_PRESSURE,
                                           SENSOR_MULTILEVEL_SCALE_KILOPASCAL,
                                           SENSOR_MULTILEVEL_SIZE_TWO_BYTES,
                                           SENSOR_MULTILEVEL_PRECISION_TWO_DECIMALS,
                                           getterBarometricPressure)
);

byte addr1[8];
boolean foundBmp;
float temperature; // here we will store the temperature
float barometricPressure; // here we will store the barometric pressure
float humidity; // here we will store the humidity
int temp; // here we will convert the temperature for reporting
word hmdy; // here we will convert the humidity for reporting
word barmPrsr; // here we will convert the barometric pressure for reporting

void setup() {
  // put your setup code here, to run once:
   Serial.begin();
   Serial.println("start");
   foundBmp = bmp.begin();
}

void loop() {
  // put your main code here, to run repeatedly:
    ds1820.scanAloneSensor(addr1);
    // obtaining readings from the sensor ds18b20
    temperature = ds1820.getTemperature(addr1);
    // make scaled word value for report
    temp=int(temperature*100);

    if (foundBmp = true) {
      // Get humidity
      humidity = bmp.readHumidityH10()/10;
      hmdy = int(humidity * 100);
      // Get barometric pressure
      barometricPressure = bmp.readPressurePa()/10;
      barmPrsr = int(barometricPressure * 100);
  
    }
        
    Serial.print("Temperature: ");
    Serial.print(temperature);
    Serial.println(" °C");

    if (foundBmp = true) {
      Serial.print("Humidity = ");
      Serial.print(humidity);
      Serial.println(" %");
      Serial.print("Pressure = ");
      Serial.print(barometricPressure);
      Serial.println(" Pa");
    } else {
       Serial.println("Could not find a valid BMP280 sensor, check wiring!");
    }

    // send data to channels
    zunoSendReport(1);     
    zunoSendReport(2);     
    zunoSendReport(3);     
    // send every 30 second
    delay(30000);

}

word getterTemp() {
  return temp;
}

word getterHumidity() {
  return hmdy;
}

word getterBarometricPressure() {
  return barmPrsr;
}
User avatar
PoltoS
Posts: 7571
Joined: 26 Jan 2011 19:36

Re: BMP280 not showing results

Post by PoltoS »

foundBmp = true is wrong. Should be foundBmp == true

And not sure that true is a keyword. You can just write if (foundBmp) {

Do you see the Serial output ? is it correct?

What is shown in the RPi UI? There should be some number. Just 0?
karlbaker
Posts: 13
Joined: 03 Mar 2019 12:04

Re: BMP280 not showing results

Post by karlbaker »

Hi PoltoS,

Sorry for not getting back sooner, was traveling this week.

First, looking at https://z-uno.z-wave.me/reference/ I saw that true is a keyword. But, I also tried the approach you mentioned using if (foundBmp) {

In the serial output I do not see the exception

Code: Select all

Serial.println("Could not find a valid BMP280 sensor, check wiring!");
, just zeros. Here's an example:

Code: Select all

18:10:47.746 -> Temperature: 18.00 °C
18:10:47.746 -> Humidity = 0.00 %
18:10:47.746 -> Pressure = 0.00 Pa
In the RPi UI I see no reference at all of the humidity and barometric pressure, only the temperature is coming over as an unsolicited message.

Is it possible that there is a collision with the temperature sensor on pin 11 that is using OneWire? From what I have read connecting to I2C should be pretty much plug and play.

Thanks for your help.

Karl
karlbaker
Posts: 13
Joined: 03 Mar 2019 12:04

Re: BMP280 not showing results

Post by karlbaker »

Hi PoltoS,

Here's another update: I saw that my code was not completely correct, and fixed it. I now recive the message:

Code: Select all

19:16:43.197 -> Temperature: 17.75 °C
19:16:43.197 -> Could not find a valid BMP280 sensor, check wiring!
At least this is some progress, but not what is wanted. I have wired the BMP280 in this manner: SCK on the BMP280 to SCK (Pin 9) on the z-uno, and SDI to SDA (pin 10). I chose this way referencing teh Adafruit sensor breakout document and https://z-uno.z-wave.me/Reference/Wire.

Karl
karlbaker
Posts: 13
Joined: 03 Mar 2019 12:04

Re: BMP280 not showing results

Post by karlbaker »

Hi PoltoS,

I finally figured out what was wrong, my soldering is not the best, so I re-soldered the sensor and now am receiving barometric pressure.

My next step is to add the barometric pressure as an additional channel to send as an unsolicited report. I'm testing along the way, and am adding the channels once I have a sensor working properly.

Thanks again for your help.

Karl
Post Reply