Adafruit BMP390 over I2C with Wire.h on Teensy 3.6 ok but not for Teensy 4.1

Status
Not open for further replies.

PLCcoder

Member
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 :(
"

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
 

Attachments

  • T36_AdaBMP390.txt
    87 KB · Views: 105
  • T41_AdaBMP390.txt
    82.1 KB · Views: 98
I have seen the same issue with 4.1 and the BMP390 over I2C.
SPI works fine. but I also need to use I2C for my project.

I used a MCP9808 i2C temperature sensor with teensy 4.1 without issue. difference could be the pull up resistors?..... so I added different sizes pullups to the BMP390 and this didn't result in anything working.

I added a question to the Adafruit forum but no answer.

i could be wrong but looks like an issue with the library? or something subtle with the teensy 4.1 ?

If you find anything out please let me know, and i will also post back here if I find a solution.
Regards
Wess
 
Sorry, I was going to order one of them from Adafruit, but they won't ship to my mailbox... And Neither Digikey nor Mouser had them in stock nor found it on Amazon...

SO I ordered a 388 version from Sparkfun. Probably the same software should work (or not work)... Maybe here sometime this next week.

Could be PU resistors. Could be a timing issue. ...
 
difference could be the pull up resistors?..... so I added different sizes pullups to the BMP390 and this didn't result in anything working.

My four cables are only 8cm short/long so at first I did not bother about the two Pull Ups.
However today I tried some values (min, max: https://www.pjrc.com/teensy/td_libs_Wire.html):
  • no Pull Up
  • 2kOhm
  • 4,7kOhm
:(

I am usind the Vin (5V, green SMD-LED is on) on the Adafruit BMP390 not sure how far this is an issue, but worked in the past and I did not worry about level shifting.

I also lowerd the baud rate from 115200 down to 9600.
:(

question marks still remain...
 
I managed to find an old Arduino uno.

Fired up first time with the test sketch with I2C, so the I2C bus is functional on my sensor.

So upto now we have tested:

Teensy 4.1 +SPI with BMP390 = works
Arduino uno + I2C with BMP390 = works
Teensy 4.1 + I2C with MCP9808 = Works (this is a thermometer with 10k pullups.)
Teensy 4.1 + I2C with BMP390 = does not work,
Tested teensy 4.1 with pullups 2k and 4.7K (you) and 2.2k , 4.7K and 10k (me). = not working

Im going to look into if this is another issue like impedance or some setting on the 4.1 thats new to me, i looked at the library but this is a massive amount of code and would need an expert to spot a 4.1 issue in it.
 
Again I could not order one of the Adafruit ones, but ordered a Sparkfun 388 version, which should ship soon. (I ordered too late on New Years Eve) so will probably ship Tomorrow.
 
You could define BMP3XX_DEBUG in the Adafruit_BMP3XX library, and it should print out progress in performReading() that might help you locate the problem. Since the Teensy 4 is so fast you might look for places in the library where delay's might be increased ...
 
Just catching up as been a bit out of it for several days. But I just ordered one from Adafruit and should be Tuesday afternoon.
 
In response to 'manitou' this is what i got when i run the debug, however i don't have the knowledge of the 4.1 to understand what might create the issue.

Defining BMP3XX_DEBUG prints out this in the serial monitor

Adafruit BMP388 / BMP390 test
Reset result: 0
Init result: 0
Valtrim result: 0
T1 = 27483
T2 = 19161
T3 = -7
P1 = 7248
P2 = 5548
P3 = 6
P4 = 1
P5 = 18780
P6 = 23990
P7 = 3
P8 = -6
P9 = 3978
P10 = 6
P11 = -11
Setting sensor settings
Setting power mode
Getting sensor data
Failed to perform reading :(
Setting sensor settings
Failed to perform reading :(
Setting sensor settings
Setting power mode
Getting sensor data
Failed to perform reading :(
Setting sensor settings
Failed to perform reading :(
Setting sensor settings
Setting power mode
Getting sensor data
Failed to perform reading :(
Setting sensor settings
Failed to perform reading :(..............................................
 
With default bmp3xx_simpletest.ion over I2C with Debug enabled.

On a Arduino Uno:
Adafruit BMP388 / BMP390 test
Reset result: 0
Init result: 0
Valtrim result: 0
T1 = 27582
T2 = 19163
T3 = -7
P1 = 7275
P2 = 5592
P3 = 6
P4 = 1
P5 = 18782
P6 = 23696
P7 = 3
P8 = -6
P9 = 4028
P10 = 6
P11 = -11
Setting sensor settings
Setting power mode
Getting sensor data
Temperature = 24.80 *C
Pressure = 974.56 hPa
Approx. Altitude = Setting sensor settings
Setting power mode
Getting sensor data
327.26 m

On the Teensy 4.1:
Adafruit BMP388 / BMP390 test
Reset result: 0
Init result: 0
Valtrim result: 0
T1 = 27582
T2 = 19163
T3 = -7
P1 = 7275
P2 = 5592
P3 = 6
P4 = 1
P5 = 18782
P6 = 23696
P7 = 3
P8 = -6
P9 = 4028
P10 = 6
P11 = -11
Setting sensor settings
Setting power mode
Getting sensor data
Failed to perform reading
Setting sensor settings
Failed to perform reading
Setting sensor settings
Failed to perform reading
Setting sensor settings
Failed to perform reading
Setting sensor settings
Failed to perform reading
Setting sensor settings
Setting power mode
Getting sensor data
Failed to perform reading
Setting sensor settings
Failed to perform reading
Setting sensor settings
Setting power mode
Getting sensor data
Failed to perform reading
Setting sensor settings
Failed to perform reading
Setting sensor settings
Failed to perform reading
Setting sensor settings
Failed to perform reading
Setting sensor settings
Failed to perform reading
Setting sensor settings
Setting power mode
Getting sensor data
Failed to perform reading
Setting sensor settings
Failed to perform reading
Setting sensor settings
Setting power mode
Getting sensor data
Failed to perform reading
Setting sensor settings
Failed to perform reading
Setting sensor settings
Failed to perform reading
Setting sensor settings
Setting power mode
Getting sensor data
Failed to perform reading
Setting sensor settings
Failed to perform reading
Setting sensor settings
Setting power mode
Getting sensor data
Failed to perform reading
Setting sensor settings
Failed to perform reading
Setting sensor settings
Setting power mode
Getting sensor data
Failed to perform reading
Setting sensor settings
Failed to perform reading
Setting sensor settings
Setting power mode
Getting sensor data
Failed to perform reading
Setting sensor settings
Failed to perform reading
Setting sensor settings
Setting power mode
Getting sensor data
Failed to perform reading
Setting sensor settings
Failed to perform reading
Setting sensor settings
Setting power mode
Getting sensor data
Failed to perform reading
Setting sensor settings
Failed to perform reading
Setting sensor settings
Setting power mode
Getting sensor data
Failed to perform reading
Setting sensor settings
Failed to perform reading
Setting sensor settings
Setting power mode
Getting sensor data
Failed to perform reading
Setting sensor settings
Failed to perform reading
Setting sensor settings
Failed to perform reading
Setting sensor settings
Setting power mode
Getting sensor data
Failed to perform reading
Setting sensor settings
Failed to perform reading
Setting sensor settings
Failed to perform reading
Setting sensor settings
Setting power mode
Getting sensor data
Failed to perform reading
Setting sensor settings
Failed to perform reading
Setting sensor settings
Failed to perform reading
Setting sensor settings
Setting power mode
Getting sensor data
Failed to perform reading
Setting sensor settings
Failed to perform reading
Setting sensor settings
Setting power mode
Getting sensor data
Failed to perform reading
Setting sensor settings
Failed to perform reading
Setting sensor settings
Setting power mode
Getting sensor data
Failed to perform reading
Setting sensor settings
Failed to perform reading
Setting sensor settings
Failed to perform reading
Setting sensor settings
Setting power mode
Failed to perform reading
Setting sensor settings
Failed to perform reading
Setting sensor settings
Failed to perform reading
Setting sensor settings

Some how the
Setting power mode
indication is not shown regular from the beginning.
 
You might also check that your library Adafruit_BusIO is up to date as well.

Also you may want to turn on the debug printing in here as well. That is in the file Adafruit_I2CDevice.cpp at the top uncomment the line //#define DEBUG_SERIAL ...
And see where it probably fails.

Beyond that hard to know yet. Could not tell from datasheet how fast it can do I2C interface. I also don't see anywhere where it is set. So I think Wire defaults to maybe 100khz? which should be slow enough.
 
Hi KurtE,

first: All libs are up to date.

With both Debugs enabled the results are:
Kdiff
2021-01-04 18_29_11-T41.txt _-_ Uno.txt - KDiff3.png
2021-01-04 18_30_04-T41.txt _-_ Uno.txt - KDiff3.jpg

First measuring of the Arduino Uno:
2021-01-04 18_33_30-C__Users_max_Documents_Arduino_Uno.txt - Notepad++.png

First measuring of the Teensy 4.1:
2021-01-04 18_34_01-C__Users_max_Documents_Arduino_T41.txt - Notepad++.png

Now the questions are:
1. Why i2cRead delivers: 0x70 instead of 0x10
2. Why i2cWrite delivers: 0x0 instead of 0x9
3. Why "I2CWRITE @ 0x77 :: 0x4," does not result in "I2CREAD @ 0x77 :: 0x40, 0x2D, 0x68, 0xE0, 0x8D, 0x81,"

and were and how to fix it.
 
Maybe a quick thing to try:
Try adding a delay at startup:
Something like:
Code:
void setup() {
  Serial.begin(115200);
  while (!Serial);
  Serial.println("Adafruit BMP390");
  delay(1000); // wait a second to see if the device is slow to startup...
  if (!bmp.begin_I2C()) {   // hardware I2C mode, can pass in address & alt Wire

If that helps, than shorten...

If not, I would maybe try adding some delays in library:
Like where you see the output the debug output: Setting power mode
Try adding a delay to there, before it does anything else... Maybe it is turning on power to device and UNO is slow enough that the device has a chance to respond, but faster device may take some time...
 
Hi KurtE,

tried the 1 Second delay: same, same as above

I do not think that some delays will solve it:
1. is a read (feedback) from the sensor
2. is a the last bit of a write of some bits which is different
3. is a read (temperature, perssure and altitude, 6 bits) from the sensor which are not recieved from the Teensy 4.1

The adjustment of the power is also different, there is still a bit change ongoing:
2021-01-04 21_28_04-Uno_vs._41.txt.jpg

Uno:
I2CREAD @ 0x77 :: 0x3,

Teensy 4.1: several times
I2CREAD @ 0x77 :: 0x13,

In the data sheet page 44 the SCK frequency typ 400, max. 3400kHz
 
Last edited:
Understood, but I know with some sensors that work on a slower platform and not on faster ones, it can often be a timing issue, like you do a write operation to the device to ask it for something and then ask for the results and maybe a delay is needed...

Have you tried the library that Sparkfun points you to with their sensor? https://github.com/MartinL1/BMP388_DEV
I don't know how much different the 388 interface is to the 390.

Their code for reading has calls in to ask the device if the conversion has completed. Again not sure how different they are. Won't have my Sparkfun version until later this week.
 
I have tried delay(40) betweeen the two returns, which did not work out. However 20ms did but with the same errors.

Or is the place wrong?

Adafruit_BMP3XX.cpp
Code:
/**************************************************************************/
/*!
    @brief  Reads 8 bit values over I2C
*/
/**************************************************************************/
int8_t i2c_read(uint8_t reg_addr, uint8_t *reg_data, uint32_t len,
                void *intf_ptr) {
   //Serial.print("I2C read address 0x"); Serial.print(reg_addr, HEX);
   //Serial.print(" len "); Serial.println(len, HEX);

  if (!i2c_dev->write_then_read(&reg_addr, 1, reg_data, len))
    return 1;

  return 0;
}

/**************************************************************************/
/*!
    @brief  Writes 8 bit values over I2C
*/
/**************************************************************************/
int8_t i2c_write(uint8_t reg_addr, const uint8_t *reg_data, uint32_t len,
                 void *intf_ptr) {
   //Serial.print("I2C write address 0x"); Serial.print(reg_addr, HEX);
   //Serial.print(" len "); Serial.println(len, HEX);

  if (!i2c_dev->write((uint8_t *)reg_data, len, false, &reg_addr, 1))
    return 1;

  return 0;
}

As far as I understood the interface is the same for both versions.

using BMP388_I2C_Normal.ino
Only for the first compilation I got the following messages:
Code:
C:\Users\YX\Documents\Arduino\libraries\BMP388_DEV\Device.cpp: In member function 'void Device::notUsingInterrupt(uint8_t)':
C:\Users\YX\Documents\Arduino\libraries\BMP388_DEV\Device.cpp:70:34: warning: invalid conversion from 'uint8_t {aka unsigned char}' to 'IRQ_NUMBER_t' [-fpermissive]
  spi->notUsingInterrupt(pinNumber);
                                  ^
In file included from C:\Users\YX\Documents\Arduino\libraries\BMP388_DEV/Device.h:34:0,
                 from C:\Users\YX\Documents\Arduino\libraries\BMP388_DEV\Device.cpp:29:
C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\SPI/SPI.h:1162:7: note:   initializing argument 1 of 'void SPIClass::notUsingInterrupt(IRQ_NUMBER_t)'
  void notUsingInterrupt(IRQ_NUMBER_t interruptName);

Code:
C:\Program Files (x86)\Arduino\arduino-builder -dump-prefs -logger=machine -hardware C:\Program Files (x86)\Arduino\hardware -hardware C:\Users\YX\AppData\Local\Arduino15\packages -tools C:\Program Files (x86)\Arduino\tools-builder -tools C:\Program Files (x86)\Arduino\hardware\tools\avr -tools C:\Users\YX\AppData\Local\Arduino15\packages -built-in-libraries C:\Program Files (x86)\Arduino\libraries -libraries C:\Users\YX\Documents\Arduino\libraries -fqbn=teensy:avr:teensy41:usb=serial,speed=600,opt=o2std,keys=en-us -ide-version=10813 -build-path C:\Users\YX\AppData\Local\Temp\arduino_build_215017 -warnings=all -build-cache C:\Users\YX\AppData\Local\Temp\arduino_cache_740608 -verbose C:\Users\YX\Documents\Arduino\libraries\BMP388_DEV\examples\BMP388_I2C_Normal\BMP388_I2C_Normal.ino
C:\Program Files (x86)\Arduino\arduino-builder -compile -logger=machine -hardware C:\Program Files (x86)\Arduino\hardware -hardware C:\Users\YX\AppData\Local\Arduino15\packages -tools C:\Program Files (x86)\Arduino\tools-builder -tools C:\Program Files (x86)\Arduino\hardware\tools\avr -tools C:\Users\YX\AppData\Local\Arduino15\packages -built-in-libraries C:\Program Files (x86)\Arduino\libraries -libraries C:\Users\YX\Documents\Arduino\libraries -fqbn=teensy:avr:teensy41:usb=serial,speed=600,opt=o2std,keys=en-us -ide-version=10813 -build-path C:\Users\YX\AppData\Local\Temp\arduino_build_215017 -warnings=all -build-cache C:\Users\YX\AppData\Local\Temp\arduino_cache_740608 -verbose C:\Users\YX\Documents\Arduino\libraries\BMP388_DEV\examples\BMP388_I2C_Normal\BMP388_I2C_Normal.ino
Using board 'teensy41' from platform in folder: C:\Program Files (x86)\Arduino\hardware\teensy\avr
Using core 'teensy4' from platform in folder: C:\Program Files (x86)\Arduino\hardware\teensy\avr
Detecting libraries used...
"C:\\Program Files (x86)\\Arduino\\hardware\\teensy/../tools/arm/bin/arm-none-eabi-g++" -E -CC -x c++ -w -g -Wall -ffunction-sections -fdata-sections -nostdlib -std=gnu++14 -fno-exceptions -fpermissive -fno-rtti -fno-threadsafe-statics -felide-constructors -Wno-error=narrowing -mthumb -mcpu=cortex-m7 -mfloat-abi=hard -mfpu=fpv5-d16 -D__IMXRT1062__ -DTEENSYDUINO=153 -DARDUINO=10813 -DARDUINO_TEENSY41 -DF_CPU=600000000 -DUSB_SERIAL -DLAYOUT_US_ENGLISH "-IC:\\Program Files (x86)\\Arduino\\hardware\\teensy\\avr\\cores\\teensy4" "C:\\Users\\YX\\AppData\\Local\\Temp\\arduino_build_215017\\sketch\\BMP388_I2C_Normal.ino.cpp" -o nul -DARDUINO_LIB_DISCOVERY_PHASE
Alternatives for BMP388_DEV.h: [BMP388_DEV@1.0.3]
ResolveLibrary(BMP388_DEV.h)
  -> candidates: [BMP388_DEV@1.0.3]
"C:\\Program Files (x86)\\Arduino\\hardware\\teensy/../tools/arm/bin/arm-none-eabi-g++" -E -CC -x c++ -w -g -Wall -ffunction-sections -fdata-sections -nostdlib -std=gnu++14 -fno-exceptions -fpermissive -fno-rtti -fno-threadsafe-statics -felide-constructors -Wno-error=narrowing -mthumb -mcpu=cortex-m7 -mfloat-abi=hard -mfpu=fpv5-d16 -D__IMXRT1062__ -DTEENSYDUINO=153 -DARDUINO=10813 -DARDUINO_TEENSY41 -DF_CPU=600000000 -DUSB_SERIAL -DLAYOUT_US_ENGLISH "-IC:\\Program Files (x86)\\Arduino\\hardware\\teensy\\avr\\cores\\teensy4" "-IC:\\Users\\YX\\Documents\\Arduino\\libraries\\BMP388_DEV" "C:\\Users\\YX\\AppData\\Local\\Temp\\arduino_build_215017\\sketch\\BMP388_I2C_Normal.ino.cpp" -o nul -DARDUINO_LIB_DISCOVERY_PHASE
Alternatives for Wire.h: [Wire@1.0]
ResolveLibrary(Wire.h)
  -> candidates: [Wire@1.0]
"C:\\Program Files (x86)\\Arduino\\hardware\\teensy/../tools/arm/bin/arm-none-eabi-g++" -E -CC -x c++ -w -g -Wall -ffunction-sections -fdata-sections -nostdlib -std=gnu++14 -fno-exceptions -fpermissive -fno-rtti -fno-threadsafe-statics -felide-constructors -Wno-error=narrowing -mthumb -mcpu=cortex-m7 -mfloat-abi=hard -mfpu=fpv5-d16 -D__IMXRT1062__ -DTEENSYDUINO=153 -DARDUINO=10813 -DARDUINO_TEENSY41 -DF_CPU=600000000 -DUSB_SERIAL -DLAYOUT_US_ENGLISH "-IC:\\Program Files (x86)\\Arduino\\hardware\\teensy\\avr\\cores\\teensy4" "-IC:\\Users\\YX\\Documents\\Arduino\\libraries\\BMP388_DEV" "-IC:\\Program Files (x86)\\Arduino\\hardware\\teensy\\avr\\libraries\\Wire" "C:\\Users\\YX\\AppData\\Local\\Temp\\arduino_build_215017\\sketch\\BMP388_I2C_Normal.ino.cpp" -o nul -DARDUINO_LIB_DISCOVERY_PHASE
Alternatives for SPI.h: [SPI@1.0]
ResolveLibrary(SPI.h)
  -> candidates: [SPI@1.0]
"C:\\Program Files (x86)\\Arduino\\hardware\\teensy/../tools/arm/bin/arm-none-eabi-g++" -E -CC -x c++ -w -g -Wall -ffunction-sections -fdata-sections -nostdlib -std=gnu++14 -fno-exceptions -fpermissive -fno-rtti -fno-threadsafe-statics -felide-constructors -Wno-error=narrowing -mthumb -mcpu=cortex-m7 -mfloat-abi=hard -mfpu=fpv5-d16 -D__IMXRT1062__ -DTEENSYDUINO=153 -DARDUINO=10813 -DARDUINO_TEENSY41 -DF_CPU=600000000 -DUSB_SERIAL -DLAYOUT_US_ENGLISH "-IC:\\Program Files (x86)\\Arduino\\hardware\\teensy\\avr\\cores\\teensy4" "-IC:\\Users\\YX\\Documents\\Arduino\\libraries\\BMP388_DEV" "-IC:\\Program Files (x86)\\Arduino\\hardware\\teensy\\avr\\libraries\\Wire" "-IC:\\Program Files (x86)\\Arduino\\hardware\\teensy\\avr\\libraries\\SPI" "C:\\Users\\YX\\AppData\\Local\\Temp\\arduino_build_215017\\sketch\\BMP388_I2C_Normal.ino.cpp" -o nul -DARDUINO_LIB_DISCOVERY_PHASE
Using cached library dependencies for file: C:\Users\YX\Documents\Arduino\libraries\BMP388_DEV\BMP388_DEV.cpp
Using cached library dependencies for file: C:\Users\YX\Documents\Arduino\libraries\BMP388_DEV\Device.cpp
Using cached library dependencies for file: C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\Wire\Wire.cpp
Using cached library dependencies for file: C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\Wire\WireIMXRT.cpp
Using cached library dependencies for file: C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\Wire\WireKinetis.cpp
Using cached library dependencies for file: C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\Wire\utility\twi.c
Using cached library dependencies for file: C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\SPI\SPI.cpp
Generating function prototypes...
"C:\\Program Files (x86)\\Arduino\\hardware\\teensy/../tools/arm/bin/arm-none-eabi-g++" -E -CC -x c++ -w -g -Wall -ffunction-sections -fdata-sections -nostdlib -std=gnu++14 -fno-exceptions -fpermissive -fno-rtti -fno-threadsafe-statics -felide-constructors -Wno-error=narrowing -mthumb -mcpu=cortex-m7 -mfloat-abi=hard -mfpu=fpv5-d16 -D__IMXRT1062__ -DTEENSYDUINO=153 -DARDUINO=10813 -DARDUINO_TEENSY41 -DF_CPU=600000000 -DUSB_SERIAL -DLAYOUT_US_ENGLISH "-IC:\\Program Files (x86)\\Arduino\\hardware\\teensy\\avr\\cores\\teensy4" "-IC:\\Users\\YX\\Documents\\Arduino\\libraries\\BMP388_DEV" "-IC:\\Program Files (x86)\\Arduino\\hardware\\teensy\\avr\\libraries\\Wire" "-IC:\\Program Files (x86)\\Arduino\\hardware\\teensy\\avr\\libraries\\SPI" "C:\\Users\\YX\\AppData\\Local\\Temp\\arduino_build_215017\\sketch\\BMP388_I2C_Normal.ino.cpp" -o "C:\\Users\\YX\\AppData\\Local\\Temp\\arduino_build_215017\\preproc\\ctags_target_for_gcc_minus_e.cpp" -DARDUINO_LIB_DISCOVERY_PHASE
"C:\\Program Files (x86)\\Arduino\\tools-builder\\ctags\\5.8-arduino11/ctags" -u --language-force=c++ -f - --c++-kinds=svpf --fields=KSTtzns --line-directives "C:\\Users\\YX\\AppData\\Local\\Temp\\arduino_build_215017\\preproc\\ctags_target_for_gcc_minus_e.cpp"
Sketch wird kompiliert...
"C:\\Program Files (x86)\\Arduino\\hardware\\teensy/../tools/precompile_helper" "C:\\Program Files (x86)\\Arduino\\hardware\\teensy\\avr/cores/teensy4" "C:\\Users\\YX\\AppData\\Local\\Temp\\arduino_build_215017" "C:\\Program Files (x86)\\Arduino\\hardware\\teensy/../tools/arm/bin/arm-none-eabi-g++" -x c++-header -O2 -g -Wall -ffunction-sections -fdata-sections -nostdlib -MMD -std=gnu++14 -fno-exceptions -fpermissive -fno-rtti -fno-threadsafe-statics -felide-constructors -Wno-error=narrowing -mthumb -mcpu=cortex-m7 -mfloat-abi=hard -mfpu=fpv5-d16 -D__IMXRT1062__ -DTEENSYDUINO=153 -DARDUINO=10813 -DARDUINO_TEENSY41 -DF_CPU=600000000 -DUSB_SERIAL -DLAYOUT_US_ENGLISH "-IC:\\Program Files (x86)\\Arduino\\hardware\\teensy\\avr/cores/teensy4" "C:\\Users\\YX\\AppData\\Local\\Temp\\arduino_build_215017/pch/Arduino.h" -o "C:\\Users\\YX\\AppData\\Local\\Temp\\arduino_build_215017/pch/Arduino.h.gch"
Using previously compiled file: C:\Users\YX\AppData\Local\Temp\arduino_build_215017\pch\Arduino.h.gch
"C:\\Program Files (x86)\\Arduino\\hardware\\teensy/../tools/arm/bin/arm-none-eabi-g++" -c -O2 -g -Wall -ffunction-sections -fdata-sections -nostdlib -MMD -std=gnu++14 -fno-exceptions -fpermissive -fno-rtti -fno-threadsafe-statics -felide-constructors -Wno-error=narrowing -mthumb -mcpu=cortex-m7 -mfloat-abi=hard -mfpu=fpv5-d16 -D__IMXRT1062__ -DTEENSYDUINO=153 -DARDUINO=10813 -DARDUINO_TEENSY41 -DF_CPU=600000000 -DUSB_SERIAL -DLAYOUT_US_ENGLISH "-IC:\\Users\\YX\\AppData\\Local\\Temp\\arduino_build_215017/pch" "-IC:\\Program Files (x86)\\Arduino\\hardware\\teensy\\avr\\cores\\teensy4" "-IC:\\Users\\YX\\Documents\\Arduino\\libraries\\BMP388_DEV" "-IC:\\Program Files (x86)\\Arduino\\hardware\\teensy\\avr\\libraries\\Wire" "-IC:\\Program Files (x86)\\Arduino\\hardware\\teensy\\avr\\libraries\\SPI" "C:\\Users\\YX\\AppData\\Local\\Temp\\arduino_build_215017\\sketch\\BMP388_I2C_Normal.ino.cpp" -o "C:\\Users\\YX\\AppData\\Local\\Temp\\arduino_build_215017\\sketch\\BMP388_I2C_Normal.ino.cpp.o"
Compiling libraries...
Compiling library "BMP388_DEV"
Zuvor kompilierte Datei wird verwendet: C:\Users\YX\AppData\Local\Temp\arduino_build_215017\libraries\BMP388_DEV\BMP388_DEV.cpp.o
Zuvor kompilierte Datei wird verwendet: C:\Users\YX\AppData\Local\Temp\arduino_build_215017\libraries\BMP388_DEV\Device.cpp.o
Compiling library "Wire"
Zuvor kompilierte Datei wird verwendet: C:\Users\YX\AppData\Local\Temp\arduino_build_215017\libraries\Wire\Wire.cpp.o
Zuvor kompilierte Datei wird verwendet: C:\Users\YX\AppData\Local\Temp\arduino_build_215017\libraries\Wire\WireKinetis.cpp.o
Zuvor kompilierte Datei wird verwendet: C:\Users\YX\AppData\Local\Temp\arduino_build_215017\libraries\Wire\WireIMXRT.cpp.o
Zuvor kompilierte Datei wird verwendet: C:\Users\YX\AppData\Local\Temp\arduino_build_215017\libraries\Wire\utility\twi.c.o
Compiling library "SPI"
Zuvor kompilierte Datei wird verwendet: C:\Users\YX\AppData\Local\Temp\arduino_build_215017\libraries\SPI\SPI.cpp.o
Compiling core...
Using precompiled core: C:\Users\YX\AppData\Local\Temp\arduino_cache_740608\core\core_e612ed3a92f8769e6d06d6bf8e29c1af.a
Linking everything together...
"C:\\Program Files (x86)\\Arduino\\hardware\\teensy/../tools/arm/bin/arm-none-eabi-gcc" -O2 -Wl,--gc-sections,--relax "-TC:\\Program Files (x86)\\Arduino\\hardware\\teensy\\avr\\cores\\teensy4/imxrt1062_t41.ld" -mthumb -mcpu=cortex-m7 -mfloat-abi=hard -mfpu=fpv5-d16 -o "C:\\Users\\YX\\AppData\\Local\\Temp\\arduino_build_215017/BMP388_I2C_Normal.ino.elf" "C:\\Users\\YX\\AppData\\Local\\Temp\\arduino_build_215017\\sketch\\BMP388_I2C_Normal.ino.cpp.o" "C:\\Users\\YX\\AppData\\Local\\Temp\\arduino_build_215017\\libraries\\BMP388_DEV\\BMP388_DEV.cpp.o" "C:\\Users\\YX\\AppData\\Local\\Temp\\arduino_build_215017\\libraries\\BMP388_DEV\\Device.cpp.o" "C:\\Users\\YX\\AppData\\Local\\Temp\\arduino_build_215017\\libraries\\Wire\\Wire.cpp.o" "C:\\Users\\YX\\AppData\\Local\\Temp\\arduino_build_215017\\libraries\\Wire\\WireIMXRT.cpp.o" "C:\\Users\\YX\\AppData\\Local\\Temp\\arduino_build_215017\\libraries\\Wire\\WireKinetis.cpp.o" "C:\\Users\\YX\\AppData\\Local\\Temp\\arduino_build_215017\\libraries\\Wire\\utility\\twi.c.o" "C:\\Users\\YX\\AppData\\Local\\Temp\\arduino_build_215017\\libraries\\SPI\\SPI.cpp.o" "C:\\Users\\YX\\AppData\\Local\\Temp\\arduino_build_215017/..\\arduino_cache_740608\\core\\core_e612ed3a92f8769e6d06d6bf8e29c1af.a" "-LC:\\Users\\YX\\AppData\\Local\\Temp\\arduino_build_215017" -larm_cortexM7lfsp_math -lm -lstdc++
"C:\\Program Files (x86)\\Arduino\\hardware\\teensy/../tools/arm/bin/arm-none-eabi-objcopy" -O ihex -j .eeprom --set-section-flags=.eeprom=alloc,load --no-change-warnings --change-section-lma .eeprom=0 "C:\\Users\\YX\\AppData\\Local\\Temp\\arduino_build_215017/BMP388_I2C_Normal.ino.elf" "C:\\Users\\YX\\AppData\\Local\\Temp\\arduino_build_215017/BMP388_I2C_Normal.ino.eep"
"C:\\Program Files (x86)\\Arduino\\hardware\\teensy/../tools/arm/bin/arm-none-eabi-objcopy" -O ihex -R .eeprom "C:\\Users\\YX\\AppData\\Local\\Temp\\arduino_build_215017/BMP388_I2C_Normal.ino.elf" "C:\\Users\\YX\\AppData\\Local\\Temp\\arduino_build_215017/BMP388_I2C_Normal.ino.hex"
"C:\\Program Files (x86)\\Arduino\\hardware\\teensy/../tools/stdout_redirect" "C:\\Users\\YX\\AppData\\Local\\Temp\\arduino_build_215017/BMP388_I2C_Normal.ino.lst" "C:\\Program Files (x86)\\Arduino\\hardware\\teensy/../tools/arm/bin/arm-none-eabi-objdump" -d -S -C "C:\\Users\\YX\\AppData\\Local\\Temp\\arduino_build_215017/BMP388_I2C_Normal.ino.elf"
"C:\\Program Files (x86)\\Arduino\\hardware\\teensy/../tools/stdout_redirect" "C:\\Users\\YX\\AppData\\Local\\Temp\\arduino_build_215017/BMP388_I2C_Normal.ino.sym" "C:\\Program Files (x86)\\Arduino\\hardware\\teensy/../tools/arm/bin/arm-none-eabi-objdump" -t -C "C:\\Users\\YX\\AppData\\Local\\Temp\\arduino_build_215017/BMP388_I2C_Normal.ino.elf"
"C:\\Program Files (x86)\\Arduino\\hardware\\teensy/../tools/teensy_post_compile" -file=BMP388_I2C_Normal.ino "-path=C:\\Users\\YX\\AppData\\Local\\Temp\\arduino_build_215017" "-tools=C:\\Program Files (x86)\\Arduino\\hardware\\teensy/../tools/" -board=TEENSY41
Bibliothek BMP388_DEV in Version 1.0.3 im Ordner: C:\Users\max\Documents\Arduino\libraries\BMP388_DEV  wird verwendet
Bibliothek Wire in Version 1.0 im Ordner: C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\Wire  wird verwendet
Bibliothek SPI in Version 1.0 im Ordner: C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\SPI  wird verwendet
"C:\\Program Files (x86)\\Arduino\\hardware\\teensy/../tools/arm/bin/arm-none-eabi-size" -A "C:\\Users\\max\\AppData\\Local\\Temp\\arduino_build_215017/BMP388_I2C_Normal.ino.elf"
Der Sketch verwendet 26144 Bytes (0%) des Programmspeicherplatzes. Das Maximum sind 8126464 Bytes.
Globale Variablen verwenden 45756 Bytes (8%) des dynamischen Speichers, 478532 Bytes für lokale Variablen verbleiben. Das Maximum sind 524288 Bytes.
C:\Program Files (x86)\Arduino\hardware\teensy/../tools/teensy_post_compile -file=BMP388_I2C_Normal.ino -path=C:\Users\max\AppData\Local\Temp\arduino_build_215017 -tools=C:\Program Files (x86)\Arduino\hardware\teensy/../tools -board=TEENSY41 -reboot -port=usb:20000/0/0/1/3/1/1/4 -portlabel=hid#vid_16c0&pid_0478 Bootloader -portprotocol=Teensy

No serial output at all, UNO/Teensy4.1
 
Last edited:
From your debug, it looks like it's receiving the temperature and pressure calibrations (T1, P1, etc).

I've used the BMP280 and BME280 with the teensy, and am about to find a BMP390 to try.
I'm wondering if it's the 24-bit sample and possibly being stored in a default # of integer bytes or casting on the teensy maybe being different.

edit: I may be misremembering how the calibrations stuff works, so what I said may not make sense.

BTW, I found these, and I've had good luck with their boards in the past:
http://www.diymalls.com/MP390-Barometric-Pressure-Altimeter-Sensor?tag=Temperature Sensor

Also, Bosch driver here in case this is helpful:
https://github.com/BoschSensortec/BMP3-Sensor-API
 
Last edited:
I don't know how much different the 388 interface is to the 390.

Their code for reading has calls in to ask the device if the conversion has completed. Again not sure how different they are.

Comparing the memory maps between 388 and 390:
1. reserved register at 0x1F position 0, while 390 has a read/write "short_in" there but only using bit 3..1
2. reserved register at 0x19 position 6, while 390 has a read/write "int_ds" there but only using bit 4..0
3. reserved register at 0x13 position 7..1, while 390 has a read only "fifo_byte_counter_11_8" there
4. read only register at 0x13 position 0, while 390 has a read only "fifo_byte_counter_11_8" there but description in chapter 4.3.10 points out positon 0 is like in register 0x12!
5. 390 has a reseverd register at 0x0F
6. reserved register at 0x01, while 390 has a read only 7bit Revision ID (minor 3..0, major 7..4) there
7. 388: reserved register at 0x10 "Event" position 7..1 and position 0 read only "por_detected"
while on 390: position 1 read only "itf_act_pt"
 
For the 388 on a Teensy 3.6 the results are:
Code:
Adafruit BMP388 test
	I2CWRITE @ 0x77 :: 0x3, 
	I2CREAD  @ 0x77 :: 0x70, 
	I2CWRITE @ 0x77 :: 0x7E, 0xB6, 
	I2CWRITE @ 0x77 :: 0x2, 
	I2CREAD  @ 0x77 :: 0x0, 
Reset result: 0
	I2CWRITE @ 0x77 :: 0x0, 
	I2CREAD  @ 0x77 :: 0x50, 
	I2CWRITE @ 0x77 :: 0x3, 
	I2CREAD  @ 0x77 :: 0x10, 
	I2CWRITE @ 0x77 :: 0x7E, 0xB6, 
	I2CWRITE @ 0x77 :: 0x2, 
	I2CREAD  @ 0x77 :: 0x0, 
	I2CWRITE @ 0x77 :: 0x31, 
	I2CREAD  @ 0x77 :: 0x2A, 0x6B, 0x8, 0x49, 0xF6, 0x7, 0x0, 0xB4, 0xF5, 0x23, 0x0, 0x12, 0x64, 0x45, 0x7A, 0xF3, 0xF6, 0x2B, 0x40, 0x12, 0xC4, 
Init result: 0
	I2CWRITE @ 0x77 :: 0x31, 
	I2CREAD  @ 0x77 :: 0x2A, 0x6B, 0x8, 0x49, 0xF6, 0x7, 0x0, 0xB4, 0xF5, 0x23, 0x0, 0x12, 0x64, 0x45, 0x7A, 0xF3, 0xF6, 0x2B, 0x40, 0x12, 0xC4, 
	I2CWRITE @ 0x77 :: 0x30, 
	I2CREAD  @ 0x77 :: 0xD4, 
Valtrim result: 0
T1 = 27434
T2 = 18696
T3 = -10
P1 = 7
P2 = -2636
P3 = 35
P4 = 0
P5 = 25618
P6 = 31301
P7 = -13
P8 = -10
P9 = 16427
P10 = 18
P11 = -60
Setting sensor settings
	I2CWRITE @ 0x77 :: 0x1B, 
	I2CREAD  @ 0x77 :: 0x0, 
	I2CWRITE @ 0x77 :: 0x1B, 0x3, 
	I2CWRITE @ 0x77 :: 0x1C, 
	I2CREAD  @ 0x77 :: 0x0, 0x0, 0x0, 0x0, 
	I2CWRITE @ 0x77 :: 0x1C, 0x1A, 0x1D, 0x2, 0x1F, 0x4, 0x11, 
Setting power mode
	I2CWRITE @ 0x77 :: 0x1B, 
	I2CREAD  @ 0x77 :: 0x3, 
	I2CWRITE @ 0x77 :: 0x1B, 
	I2CREAD  @ 0x77 :: 0x3, 
	I2CWRITE @ 0x77 :: 0x1B, 0x13, 
Getting sensor data
	I2CWRITE @ 0x77 :: 0x4, 
	I2CREAD  @ 0x77 :: 0x0, 0x0, 0x80, 0x0, 0x0, 0x80, 
Temperature = 23.71 *C
Pressure = 817.37 hPa
Approx. Altitude = 
Setting sensor settings
	I2CWRITE @ 0x77 :: 0x1B, 
	I2CREAD  @ 0x77 :: 0x13, 
	I2CWRITE @ 0x77 :: 0x1B, 0x13, 
	I2CWRITE @ 0x77 :: 0x1C, 
	I2CREAD  @ 0x77 :: 0x1A, 0x2, 0x0, 0x4, 
	I2CWRITE @ 0x77 :: 0x1C, 0x1A, 0x1D, 0x2, 0x1F, 0x4, 0x11, 
Setting power mode
	I2CWRITE @ 0x77 :: 0x1B, 
	I2CREAD  @ 0x77 :: 0x13, 
	I2CWRITE @ 0x77 :: 0x1B, 
	I2CREAD  @ 0x77 :: 0x13, 
	I2CWRITE @ 0x77 :: 0x1B, 0x3, 
	I2CWRITE @ 0x77 :: 0x1B, 
	I2CREAD  @ 0x77 :: 0x13, 
	I2CWRITE @ 0x77 :: 0x1B, 0x13, 
Getting sensor data
	I2CWRITE @ 0x77 :: 0x4, 
	I2CREAD  @ 0x77 :: 0xC0, 0x27, 0x71, 0x20, 0xAC, 0x80, 
341.00 m
Setting sensor settings
	I2CWRITE @ 0x77 :: 0x1B, 
	I2CREAD  @ 0x77 :: 0x3, 
	I2CWRITE @ 0x77 :: 0x1B, 0x3, 
	I2CWRITE @ 0x77 :: 0x1C, 
	I2CREAD  @ 0x77 :: 0x1A, 0x2, 0x0, 0x4, 
	I2CWRITE @ 0x77 :: 0x1C, 0x1A, 0x1D, 0x2, 0x1F, 0x4, 0x11, 
Setting power mode
	I2CWRITE @ 0x77 :: 0x1B, 
	I2CREAD  @ 0x77 :: 0x3, 
	I2CWRITE @ 0x77 :: 0x1B, 
	I2CREAD  @ 0x77 :: 0x3, 
	I2CWRITE @ 0x77 :: 0x1B, 0x13, 
Getting sensor data
	I2CWRITE @ 0x77 :: 0x4, 
	I2CREAD  @ 0x77 :: 0xC0, 0x27, 0x71, 0x20, 0xAC, 0x80, 
Temperature = 24.47 *C
Pressure = 972.96 hPa
Approx. Altitude = 
Setting sensor settings
	I2CWRITE @ 0x77 :: 0x1B, 
	I2CREAD  @ 0x77 :: 0x13, 
	I2CWRITE @ 0x77 :: 0x1B, 0x13, 
	I2CWRITE @ 0x77 :: 0x1C, 
	I2CREAD  @ 0x77 :: 0x1A, 0x2, 0x0, 0x4, 
	I2CWRITE @ 0x77 :: 0x1C, 0x1A, 0x1D, 0x2, 0x1F, 0x4, 0x11, 
Setting power mode
	I2CWRITE @ 0x77 :: 0x1B, 
	I2CREAD  @ 0x77 :: 0x13, 
	I2CWRITE @ 0x77 :: 0x1B, 
	I2CREAD  @ 0x77 :: 0x13, 
	I2CWRITE @ 0x77 :: 0x1B, 0x3, 
	I2CWRITE @ 0x77 :: 0x1B, 
	I2CREAD  @ 0x77 :: 0x13, 
	I2CWRITE @ 0x77 :: 0x1B, 0x13, 
Getting sensor data
	I2CWRITE @ 0x77 :: 0x4, 
	I2CREAD  @ 0x77 :: 0x60, 0x27, 0x71, 0xD8, 0xAB, 0x80, 
340.90 m
 
First you are not crazy. Received my BMP390 from Adafruit today and hooked it up to a Teensy 4.0 and got the same results that you showed in your post #13. Tried a couple of things but was failing but then I went to the Issues page of the Github library and ran across this Issue: Limited reading performance due to strange `delay(40)` in code there response was anything less than helpful - basically go ask Bosch.

Ran across this before so I went ahead and comment the delay(40) out and lo and behold started getting data:
Code:
Temperature = 22.46 *C
Pressure = 1014.60 hPa
Approx. Altitude = -11.21 m

Temperature = 22.45 *C
Pressure = 1014.60 hPa
Approx. Altitude = -11.20 m

Temperature = 22.42 *C
Pressure = 1014.64 hPa
Approx. Altitude = -11.59 m
I believe we ran across something like this before but will have to do some research to figure out the final fix.

EDIT: Going through the manual and the code see no reason for the 40ms delay.
 
Last edited:
Just as a quick follow up to yesterday's post I just tested the sketch on the Uno, Due, Mega and a Teensy 3.5 with the delay(40) removed and it seemed to work with an issue.
 
Just as a quick follow up to yesterday's post I just tested the sketch on the Uno, Due, Mega and a Teensy 3.5 with the delay(40) removed and it seemed to work with an issue.

I have been laughing at the solution to this, i spent a reasonable amount of time altering and changing the delay40; and looking for any changes.............
I just never thought to comment it out !! :eek:

Thank you and much appreciated, i will follow up on my Adafruit post with the answer for others.
 
Status
Not open for further replies.
Back
Top