Hello,
two weeks ago I bought a Teensy 4.1 primaily for the built in RTC for time stamping measured values.
Attached a Adafruit BMP390 over the first I2C connection (18/19) to it using the Adafruit_BMP3XX library (Wire.h) and the scetch bmp3xx_simpletest.
I also have an Teensy 3.6 with an Adafruit BMP388 connected and working with the same scetch.
However the T4.1 only shows on the serial:
"Adafruit BMP390
Sekunden,Temp,TempK,Press,PressK,Alt
Failed to perform reading
"
I do not see any hints on the log files (attached) why it does not work out as on T3.6.
If I include i2c_t3.h of course I get compiler errors (Adafruit uses Wire.h).
Any other ideas why it does not work and/or how to get it working?
KR,
Jörg
two weeks ago I bought a Teensy 4.1 primaily for the built in RTC for time stamping measured values.
Attached a Adafruit BMP390 over the first I2C connection (18/19) to it using the Adafruit_BMP3XX library (Wire.h) and the scetch bmp3xx_simpletest.
I also have an Teensy 3.6 with an Adafruit BMP388 connected and working with the same scetch.
However the T4.1 only shows on the serial:
"Adafruit BMP390
Sekunden,Temp,TempK,Press,PressK,Alt
Failed to perform reading
"
Code:
/***************************************************************************
* Sekunden,Temp,TempK,Press,PressK,Alt
*
*
This is a library for the BMP3XX temperature & pressure sensor
Designed specifically to work with the Adafruit BMP388 Breakout
----> http://www.adafruit.com/products/3966
These sensors use I2C or SPI to communicate, 2 or 4 pins are required
to interface.
Adafruit invests time and resources providing this open source code,
please support Adafruit and open-source hardware by purchasing products
from Adafruit!
Written by Limor Fried & Kevin Townsend for Adafruit Industries.
BSD license, all text above must be included in any redistribution
**************************************************************************
*
* Teensy4.1 BMP390 0x77
*
* Adafruit BMP390
* Sekunden,Temp,TempK,Press,PressK,Alt
* Failed to perform reading :(
*/
#include <Wire.h>
#include <Adafruit_Sensor.h>
#include "Adafruit_BMP3XX.h"
#include <SimpleKalmanFilter.h>
const int CounterMax = 90;
// 2s
const int DelayTime = 1000;
// passender
const int CounterAdd = DelayTime / 1000;
SimpleKalmanFilter PressureKalmanFilter(1, 1, 0.01);
SimpleKalmanFilter TempKalmanFilter(1, 1, 0.01);
//SimpleKalmanFilter PressureKalmanFilter(0.5, 0.5, 0.01);
//SimpleKalmanFilter TempKalmanFilter(0.5, 0.5, 0.01);
#define SEALEVELPRESSURE_HPA (1013.25)
Adafruit_BMP3XX bmp;
void setup() {
Serial.begin(115200);
while (!Serial);
Serial.println("Adafruit BMP390");
if (!bmp.begin_I2C()) { // hardware I2C mode, can pass in address & alt Wire
//if (! bmp.begin_SPI(BMP_CS)) { // hardware SPI mode
//if (! bmp.begin_SPI(BMP_CS, BMP_SCK, BMP_MISO, BMP_MOSI)) { // software SPI mode
Serial.println("Could not find a valid BMP3xx sensor, check wiring!");
while (1);
}
// Set up oversampling and filter initialization
bmp.setTemperatureOversampling(BMP3_OVERSAMPLING_2X);
// BMP3_OVERSAMPLING_2X
// BMP3_No_OVERSAMPLING
bmp.setPressureOversampling(BMP3_OVERSAMPLING_32X);
bmp.setIIRFilterCoeff(BMP3_IIR_FILTER_COEFF_3);
//DISABLE);
//COEFF_3);
bmp.setOutputDataRate(BMP3_ODR_25_HZ);
Serial.println("Sekunden,Temp,TempK,Press,PressK,Alt");
}
int Counter = 0;
void loop() {
float Temp, TempK, Press, PressK, Alt;
if (! bmp.performReading()) {
Serial.println("Failed to perform reading :(");
while (1);
return;
}
Serial.print(Counter); Serial.print(",");
Temp = bmp.temperature;
//Serial.print("Temperature = ");
Serial.print(Temp); Serial.print(",");
TempK = TempKalmanFilter.updateEstimate(Temp);
Serial.print(TempK); Serial.print(",");
//Serial.println(" *C");
Press = bmp.pressure / 100.0;
//Serial.print("Pressure = ");
Serial.print(Press); Serial.print(",");
PressK = PressureKalmanFilter.updateEstimate(Press);
Serial.print(PressK); Serial.print(",");
//Serial.println(" hPa");
Alt = bmp.readAltitude(SEALEVELPRESSURE_HPA);
//Serial.print("Approx. Altitude = ");
Serial.println(Alt);
//Serial.print(",");
//Serial.println(" m");
//Serial.println();
switch (Counter) {
case CounterMax:
Serial.println("");
break;
default:
// do not do anything
break;
}
Counter = Counter + CounterAdd;
delay(DelayTime);
}
I do not see any hints on the log files (attached) why it does not work out as on T3.6.
If I include i2c_t3.h of course I get compiler errors (Adafruit uses Wire.h).
Any other ideas why it does not work and/or how to get it working?
KR,
Jörg