0

BMP388/Micro-SD Breakout board+ data reading issue using SPI
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

BMP388/Micro-SD Breakout board+ data reading issue using SPI

by Mopikel on Mon Aug 12, 2019 10:56 am

Hi everyone,

I encountered an issue when trying to set up a Micro-SD breakout board+ to record in a text file readings from a BMP388 module.

So first, here's the hardware used for the project:
-----Main hardware-----
Arduino MEGA2560
BMP388, interfaced using SPI
Micro-SD breakout board+, interfaced using SPI

-----Secondary hardware-----
A buzzer and a SG90 servo.

Software:
-----Libraries-----
Wire.h
SPI.h
Adafruit_Sensor.h
Adafruit_BMP3XX.h
Servo.h
SD.h

Issue:
If I don't initialize the SD card, the BMP388 module outputs correct readings (the first reading is always off, but it gets correct afterwards).
When I add
Code: Select all | TOGGLE FULL SIZE
SD.begin([cspin]);
the readings I get from the BMP388 get weird (serial output text below):
Code: Select all | TOGGLE FULL SIZE
BMP388 test
BMP388 first reading
Temperature = 22.40 *C
Pressure = 818.00 hPa
Approx. Altitude = 1836.75 m

BMP388 second reading
Temperature = 24.50 *C
Pressure = 1021.51 hPa
Approx. Altitude = 1.59 m

SD card initialized
Temperature = 165.27 *C
Pressure = -690.75 hPa
Approx. Altitude = nan m

Highest altitude
0.00

Paratrigger: 0

Temperature = 165.27 *C
Pressure = -690.75 hPa
Approx. Altitude = nan m

Highest altitude
0.00

Paratrigger: 0


If you have any idea about this, please let me now,
Thank you :)

P.S: full code attached below, commented to separate code used for each component:
Parachute_Depoy_System.ino
(3.84 KiB) Downloaded 4 times

Mopikel
 
Posts: 6
Joined: Wed Aug 01, 2018 7:31 am

Re: BMP388/Micro-SD Breakout board+ data reading issue using

by Mopikel on Fri Aug 16, 2019 10:23 am

Update:
I tried changing libraries, turning on and off the CS pins manually, changing the order of the code in the setup loop and here's what I found:
Here's the serial output text when initializing the SD card before the BMP388 module, using the built-in SD library and the SdFat library:
Code: Select all | TOGGLE FULL SIZE
Could not find a valid BMP3 sensor, check wiring!

If you have any ideas, please let me know!
Thanks :)

Mopikel
 
Posts: 6
Joined: Wed Aug 01, 2018 7:31 am

Re: BMP388/Micro-SD Breakout board+ data reading issue using

by adafruit_support_carter on Mon Aug 19, 2019 12:48 pm

For the BMP388, are you using hardware SPI?
Code: Select all | TOGGLE FULL SIZE
Adafruit_BMP3XX bmp(BMP_CS);

or software SPI?
Code: Select all | TOGGLE FULL SIZE
Adafruit_BMP3XX bmp(BMP_CS, BMP_MOSI, BMP_MISO,  BMP_SCK);

adafruit_support_carter
 
Posts: 12971
Joined: Tue Nov 29, 2016 2:45 pm

Re: BMP388/Micro-SD Breakout board+ data reading issue using

by Mopikel on Mon Aug 19, 2019 1:34 pm

Hi,
I get your point, I've been using software SPI on the hardware SPI pins, I'm going to try hardware SPI :)

Mopikel
 
Posts: 6
Joined: Wed Aug 01, 2018 7:31 am

Re: BMP388/Micro-SD Breakout board+ data reading issue using

by adafruit_support_carter on Mon Aug 19, 2019 1:42 pm

Sounds like the two libraries aren't sharing the SPI bus nicely. Can you recreate this with a very simple sketch and post the full code that demonstrates the issue. Sounds like it could just be an empty loop() and nothing but calls to .begin() in setup(). And then just change the order of the calls and the issue shows up?

adafruit_support_carter
 
Posts: 12971
Joined: Tue Nov 29, 2016 2:45 pm

Re: BMP388/Micro-SD Breakout board+ data reading issue using

by Mopikel on Mon Aug 19, 2019 1:48 pm

Hi,
Using the hardware SPI command resolved the issue, all readings are normal, I was using software SPI even though I plugged the sensor on the hardware SPI pins. Do you still want a small part of code demonstrating the issue?

Mopikel
 
Posts: 6
Joined: Wed Aug 01, 2018 7:31 am

Re: BMP388/Micro-SD Breakout board+ data reading issue using

by adafruit_support_carter on Mon Aug 19, 2019 1:51 pm

Yes please. Alternatively you can open an issue here:
https://github.com/adafruit/Adafruit_BMP3XX/issues

It sounds like using the BMP3xx library with software SPI in conjunction with something else using hardware SPI is not working.

adafruit_support_carter
 
Posts: 12971
Joined: Tue Nov 29, 2016 2:45 pm

Re: BMP388/Micro-SD Breakout board+ data reading issue using

by Mopikel on Mon Aug 19, 2019 2:07 pm

Hi,
Here's the code demonstrating the issue, commented with all infos about the tests performed
BMP3XX_software_SPI_issue.ino
(2.61 KiB) Downloaded 2 times

Mopikel
 
Posts: 6
Joined: Wed Aug 01, 2018 7:31 am

Re: BMP388/Micro-SD Breakout board+ data reading issue using

by adafruit_support_carter on Mon Aug 19, 2019 2:21 pm

Thanks. I opened an issue for this:
https://github.com/adafruit/Adafruit_BMP3XX/issues/6

adafruit_support_carter
 
Posts: 12971
Joined: Tue Nov 29, 2016 2:45 pm

Re: BMP388/Micro-SD Breakout board+ data reading issue using

by adafruit_support_carter on Mon Aug 19, 2019 3:09 pm

Are you using the same SCLK/MOSI/MISO pins for the two devices? They can only be either hardware SPI or software SPI, but not both.

adafruit_support_carter
 
Posts: 12971
Joined: Tue Nov 29, 2016 2:45 pm

Re: BMP388/Micro-SD Breakout board+ data reading issue using

by Mopikel on Mon Aug 19, 2019 4:54 pm

Mopikel wrote:I was using software SPI even though I plugged the sensor on the hardware SPI pins.

Yes I was using both on the same pins, I switched everything to hardware SPI mode and it works just fine, hence my question about sending the demo code :)

Mopikel
 
Posts: 6
Joined: Wed Aug 01, 2018 7:31 am

Re: BMP388/Micro-SD Breakout board+ data reading issue using

by adafruit_support_carter on Mon Aug 19, 2019 6:07 pm

Yah, it can only be one or the other. SW or HW. Unless you set thing up on separate pins.

adafruit_support_carter
 
Posts: 12971
Joined: Tue Nov 29, 2016 2:45 pm

Please be positive and constructive with your questions and comments.