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;
}