BME 280 and Argon

Hey everyone
I hope im posting this in the right spot. I just got my first Particle argon board in today I also ordered BME280 (https://www.amazon.com/gp/product/B01N47LZ4P/ref=ppx_yo_dt_b_asin_title_o00_s00?ie=UTF8&psc=1)

I am working with the Adafruit_BME280
code.

I am having trouble getting this device to work. Im beginning to wonder if this chip will even work with this code? Im a total noob when it comes to hardware and i bought this to start learning so its possible i dont have something hooked up right as well.

Has anyone had any luck/experiences with this chip?

I got a BME280 going on a Xenon last night, which should be the same as an Argon. One difference is that my sensor is only 4 pin (Vcc,GND, SCL, SDA) which maps directly to the pins on the Xenon. Looking at this link:
http://wiki.sunfounder.cc/index.php?title=BMP280_Pressure_Sensor_Module
I think yours can run in SPI or I2C mode. If you just use the 4 connections I did then it will run as I2C.

The code I used is below. I didn’t have a serial cable on it, so have used Particle.publish for the debugging logs. The address (0x76) was found when I previously had that sensor on an arduino, though the above link suggests this is a common address for BME280 boards. If you are in any doubt, run an I2C scanner. I also have a soil moisture sensor on that device, so just ignore those bits of code:

/* Soil sensor and BME280 running on a xenon
 *
 * Soil sensor connects to A2, with power connected to D5. Allows us to power up the device.
 * With a constant current, it corrodes quickly on one side.
 *
 * BME280 is a I2C device. 2 pins power, SCL and SDA connections straight to Xenon
 */

#include <Adafruit_Sensor.h>
#include <Adafruit_BME280.h>
Adafruit_BME280 bme;
float pres, temp, humid;

#define SOILPIN A2
#define SOILPWR D5      // Power the soil sensor off D5 - stops it rusting when running all the time

// Set up BME
#define BME_ADDRESS 0x76    // Use i2c_scanner to determine address

// Also monitoring battery level
float batVolts;
int batInt;
int soilValue;



void setup() {
    Particle.publish("Start", "BME280 and Soil Sensor Test");
    Particle.variable("Battery", &batInt, INT);
    
    // Start I2C
    Wire.begin();

    if(bme.begin(BME_ADDRESS)) {
        Particle.publish("Start", "BME Sensor found", PRIVATE);
    } else {
        Particle.publish("Start", "Warning: No BME sensor found", PRIVATE);
    }
    pinMode(SOILPIN,INPUT);
    pinMode(SOILPWR,OUTPUT);
    
    // Ensure soil sensor power is off
    digitalWrite(SOILPWR, LOW);
    delay(2000);
}

void loop() {
    batVolts = analogRead(BATT) * 0.0011224;
    batInt = (int)(batVolts*100);
    //Serial.println("Another message");
    //Log.info("A general logging message");
    Particle.publish("battery",String::format("%.2f",batVolts), PRIVATE);
    

   
    // Read soil sensor values and publish
    int s = readSoil();
    Particle.publish("soilMoisture", String::format("%d", s), PRIVATE);

    // Read the BME
    temp = bme.readTemperature();
    humid = bme.readHumidity();
    pres = bme.readPressure() / 100.0F;
    
    // Publish as events
    Particle.publish("humidity", String::format("%0.2f",humid), PRIVATE);
    Particle.publish("temperature", String::format("%0.2f",temp), PRIVATE);
    Particle.publish("pressure", String::format("%0.2f", pres), PRIVATE);
  
    delay(10000);
}

int readSoil() {
    // Turn on the sensor and wait 2 seconds
    digitalWrite(SOILPWR, HIGH);
    delay(2000);
    
    int v=analogRead(SOILPIN);
    
    // Power off sensor
    digitalWrite(SOILPWR, LOW);
    
    return v;
}

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.