Teensy 3.2 and Adafruit BMP280 problem

Status
Not open for further replies.

NealA

New member
Serial Monitor will not read temperature or barometric pressure. Altitude reads 44380 m.

BMP280 VIN==> Teensy 3.3V
BMP280 BND==> Teensy GND
BMP280 SDI==> Teensy 18 (A4)
BMP280 SCK==> Teensy 19 (A5)

I am using the following code:

/* Arduino Tutorial - Testing the Adafruits BMP280 Presure & Temperature Sensor
I2C Connection: Vin: 5V/3V, GND: GND, SCK: A5 (SCL), SDI: A4 (SDA)
Dev: Michalis Vasilakis // Date: 8/3/206 // Info: www.ardumotive.com */

#include <Wire.h>
#include "SPI.h" //Why? Because library supports SPI and I2C connection
#include <Adafruit_Sensor.h>
#include "Adafruit_BMP280.h"

//Setup connection of the sensor
Adafruit_BMP280 bmp; // I2C
/*//For SPI connection!
#define BMP_SCK 13
#define BMP_MISO 12
#define BMP_MOSI 11
#define BMP_CS 10
//Adafruit_BMP280 bme(BMP_CS); // hardware SPI
//Adafruit_BMP280 bme(BMP_CS, BMP_MOSI, BMP_MISO, BMP_SCK);
*/

//Variables
float pressure; //To store the barometric pressure (Pa)
float temperature; //To store the temperature (oC)
int altimeter; //To store the altimeter (m) (you can also use it as a float variable)

void setup() {
bmp.begin(); //Begin the sensor
Serial.begin(9600); //Begin serial communication at 9600bps
Serial.println("Adafruit BMP280 test:");
}

void loop() {
//Read values from the sensor:
pressure = bmp.readPressure();
temperature = bmp.readTemperature();
altimeter = bmp.readAltitude (1050.35); //Change the "1050.35" to your city current barrometric pressure (https://www.wunderground.com)

//Print values to serial monitor:
Serial.print(F("Pressure: "));
Serial.print(pressure);
Serial.print(" Pa");
Serial.print("\t");
Serial.print(("Temp: "));
Serial.print(temperature);
Serial.print(" oC");
Serial.print("\t");
Serial.print("Altimeter: ");
Serial.print(altimeter); // this should be adjusted to your local forcase
Serial.println(" m");
delay(2000);
}

TIA

NealA
 
Try changing bmp.begin(); to this:
Code:
  if (!bmp.begin()) {  
    Serial.println("Could not find a valid BMP280 sensor, check wiring!");
    while (1);
  }
Just to make sure that the Teensy can "see" the BMP280.

And what does it print for pressure and temperature?

Pete
 
Thanks Pete. I did the substitution. Now I get nothing on the serial monitor.

With my current sketch the serial monitor reads: Pressure: 0.00 Pa Temperature: 0.00 oC Altitude: 44300 m

NealA
 
Oh, I missed something. The bmp.begin() is before the Serial.begin(). It may be failing but unable to print anything.
Try this:
Code:
void setup() {
  Serial.begin(9600); //Begin serial communication at 9600bps
  while(!Serial);
  if (!bmp.begin()) {  
    Serial.println("Could not find a valid BMP280 sensor, check wiring!");
    while (1);
  }
  Serial.println("Adafruit BMP280 test:");
}

Pete
 
Pete:

Substituted

void setup() {
bmp.begin(); //Begin the sensor
Serial.begin(9600); //Begin serial communication at 9600bps
Serial.println("Adafruit BMP280 test:");
}

with:
void setup() {
Serial.begin(9600); //Begin serial communication at 9600bps
while(!Serial);
if (!bmp.begin()) {
Serial.println("Could not find a valid BMP280 sensor, check wiring!");
while (1);
}
Serial.println("Adafruit BMP280 test:");
}

Serial Monitor now reads: Could not find a valid BMP280 sensor, check wiring!

Thanks

NealA
 
The adafruit BMP380 board has 10k pullups on the two I2C pins which may not be sufficient. Try adding pullup resistors of about 4k7 ohms to both A4 and A5.

Pete
 
NealA - I use Teensy 4.1 with BMP280 and working well. Why you use for power pin VIN? and not 3.3V? Vin id primary for input power.

my sketch:
#include <Wire.h>
#include <SPI.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_BME280.h>
#define BME280_ADRESA (0x76) // Teensy 4.1 I2C Pin 19-SCL a 18-SDA
Adafruit_BME280 bme;

void setup() {

Serial.begin(115200);

if (!bme.begin(BME280_ADRESA)) {
Serial.println("BME280 is not connected!");
while (1);
}
}

void loop() {

Serial.print("Tem: ");
Serial.print(bme.readTemperature());
Serial.println(" deg.Celsus");
Serial.print("Hum.: ");
Serial.print(bme.readHumidity());
Serial.println(" %");
Serial.print("Press.: ");
Serial.print(bme.readPressure() / 100.0F);
Serial.println(" hPa.");
Serial.println();
delay(500);
}



-js-
 
Status
Not open for further replies.
Back
Top