NUCLEO-G474RE BMP183 Output Problem

Post here first, or if you can't find a relevant section!
enesert
Posts: 11
Joined: Sat May 22, 2021 11:41 am

NUCLEO-G474RE BMP183 Output Problem

Post by enesert »

I want to use BMP183 pressure sensor with NUCLEO-G474RE. I coded it with Arduino IDE. I used Adafruit BMP183 library. When i open the serial monitor, i see wrong values like -600 celcius. I thought its about sensor but i tried it with Arduino, and there was not any problem. I tried all pins but i cant solve that problem. Can you help me? Do you have any suggestions? I add an image of serial monitor and codes.

Image

Image

Image
User avatar
fpiSTM
Posts: 1738
Joined: Wed Dec 11, 2019 7:11 pm
Answers: 91
Location: Le Mans
Contact:

Re: NUCLEO-G474RE BMP183 Output Problem

Post by fpiSTM »

I don't see image.
Could you share your sketch and how you wire the BMP to the board.
enesert
Posts: 11
Joined: Sat May 22, 2021 11:41 am

Re: NUCLEO-G474RE BMP183 Output Problem

Post by enesert »

fpiSTM wrote: Sat May 22, 2021 12:40 pm I don't see image.
Could you share your sketch and how you wire the BMP to the board.

Code: Select all

#include <f401reMap.h>

#include <SPI.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_BMP183.h>

// For hardware SPI:
// Connect SCK to SPI Clock, SDO to SPI MISO, and SDI to SPI MOSI
// See  http://arduino.cc/en/Reference/SPI for your Arduino's SPI pins!
// On UNO, Clock is #13, SDO/MISO is #12 and SDI/MOSI is #11

// You can also use software SPI and define your own pins!
#define BMP183_CLK  pinMap(12)
#define BMP183_SDO  pinMap(13)  // AKA MISO
#define BMP183_SDI  pinMap(14)  // AKA MOSI

// You'll also need a chip-select pin, use any pin!
#define BMP183_CS   pinMap(9)

// initialize with hardware SPI
//Adafruit_BMP183 bmp = Adafruit_BMP183(BMP183_CS);
// or initialize with software SPI and use any 4 pins
Adafruit_BMP183 bmp = Adafruit_BMP183(BMP183_CLK, BMP183_SDO, BMP183_SDI, BMP183_CS);

/**************************************************************************/
/*
    Arduino setup function (automatically called at startup)
*/
/**************************************************************************/
void setup(void) 
{
  Serial.begin(9600);
  Serial.println("BMP183 Pressure Sensor Test"); Serial.println("");
  
  /* Initialise the sensor */
  if(!bmp.begin())
  {
    /* There was a problem detecting the BMP183 ... check your connections */
    Serial.print("Ooops, no BMP183 detected ... Check your wiring!");
    while(1);
  }
}

/**************************************************************************/
/*
    Arduino loop function, called once 'setup' is complete (your own code
    should go here)
*/
/**************************************************************************/
void loop(void) 
{
    /* Display atmospheric pressue in Pascals */
    Serial.print("Pressure:    ");
    Serial.print(bmp.getPressure());
    Serial.print(" Pascals / ");
    Serial.print(bmp.getPressure() / 100);
    Serial.println(" millibar (hPa)");

    /* First we get the current temperature from the BMP085 */
    float temperature;
    temperature = bmp.getTemperature();
    Serial.print("Temperature: ");
    Serial.print(temperature);
    Serial.println(" C");
    
    /* Calculating altitude with reasonable accuracy requires pressure    *
     * sea level pressure for your position at the moment the data is     *
     * converted. If you don't have these values, a 'generic' value of    *
     * 1013.25 mbar can be used (defined as SENSORS_PRESSURE_SEALEVELHPA  *
     * in sensors.h), but this isn't ideal and will give variable         *
     * results from one day to the next.                                  *
     *                                                                    *
     * You can usually find the current SLP value by looking at weather   *
     * websites or from environmental information centers near any major  *
     * airport.                                                           *
     *                                                                    *
     * For example, for Paris, France you can check the current mean      *
     * pressure and sea level at: http://bit.ly/16Au8ol                   */
     

    /* Then convert the atmospheric pressure, SLP and temp to altitude    */
    /* Update this next line with the current SLP for better results      */
    float seaLevelPressure = SENSORS_PRESSURE_SEALEVELHPA; // should be ~1000
    Serial.print("Sea level pressure: "); 
    Serial.print(SENSORS_PRESSURE_SEALEVELHPA);
    Serial.println(" millibar/hPa");
    
    Serial.print("Altitude:    "); 
    Serial.print(bmp.getAltitude(seaLevelPressure)); 
    Serial.println(" m");
    Serial.println("");

    delay(1000);
}

Image

Image

Image
GonzoG
Posts: 403
Joined: Wed Jan 15, 2020 11:30 am
Answers: 27
Location: Prudnik, Poland

Re: NUCLEO-G474RE BMP183 Output Problem

Post by GonzoG »

As it's written on the board: D14 and D15 are SDA, SCL pins. Those are I2C pins.
SPI uses MOSI/MISO pins: D10 and D11.
User avatar
fpiSTM
Posts: 1738
Joined: Wed Dec 11, 2019 7:11 pm
Answers: 91
Location: Le Mans
Contact:

Re: NUCLEO-G474RE BMP183 Output Problem

Post by fpiSTM »

You used the software SPI. Try hw SPI as described in the sketch. Like the uno.
enesert
Posts: 11
Joined: Sat May 22, 2021 11:41 am

Re: NUCLEO-G474RE BMP183 Output Problem

Post by enesert »

fpiSTM wrote: Sat May 22, 2021 3:06 pm You used the software SPI. Try hw SPI as described in the sketch. Like the uno.
Nothing change, it gives same output.
enesert
Posts: 11
Joined: Sat May 22, 2021 11:41 am

Re: NUCLEO-G474RE BMP183 Output Problem

Post by enesert »

GonzoG wrote: Sat May 22, 2021 1:39 pm As it's written on the board: D14 and D15 are SDA, SCL pins. Those are I2C pins.
SPI uses MOSI/MISO pins: D10 and D11.
I tried it, it gives same output.
User avatar
fpiSTM
Posts: 1738
Joined: Wed Dec 11, 2019 7:11 pm
Answers: 91
Location: Le Mans
Contact:

Re: NUCLEO-G474RE BMP183 Output Problem

Post by fpiSTM »

So you set this in your sketch and wire on the correct pins ?

Code: Select all

// You can also use software SPI and define your own pins!
#define BMP183_CLK  13
#define BMP183_SDO  12  // AKA MISO
#define BMP183_SDI   11  // AKA MOSI

// You'll also need a chip-select pin, use any pin!
#define BMP183_CS   9

// initialize with hardware SPI
Adafruit_BMP183 bmp = Adafruit_BMP183(BMP183_CS);
// or initialize with software SPI and use any 4 pins
//Adafruit_BMP183 bmp = Adafruit_BMP183(BMP183_CLK, BMP183_SDO, BMP183_SDI, BMP183_CS);
In you sketch you have #include <f401reMap.h> but this is not part of official library of Adafruit: https://github.com/adafruit/Adafruit_BMP183_Library
Idem for pinMap(), don't know why you get this but seems not correct.

Which core you used?
enesert
Posts: 11
Joined: Sat May 22, 2021 11:41 am

Re: NUCLEO-G474RE BMP183 Output Problem

Post by enesert »

fpiSTM wrote: Sat May 22, 2021 4:57 pm So you set this in your sketch and wire on the correct pins ?

Code: Select all

// You can also use software SPI and define your own pins!
#define BMP183_CLK  13
#define BMP183_SDO  12  // AKA MISO
#define BMP183_SDI   11  // AKA MOSI

// You'll also need a chip-select pin, use any pin!
#define BMP183_CS   9

// initialize with hardware SPI
Adafruit_BMP183 bmp = Adafruit_BMP183(BMP183_CS);
// or initialize with software SPI and use any 4 pins
//Adafruit_BMP183 bmp = Adafruit_BMP183(BMP183_CLK, BMP183_SDO, BMP183_SDI, BMP183_CS);
In you sketch you have #include <f401reMap.h> but this is not part of official library of Adafruit: https://github.com/adafruit/Adafruit_BMP183_Library
Idem for pinMap(), don't know why you get this but seems not correct.

Which core you used?

Yes i did what you said. I deleted that library, i changed the code and pins like what you show. But output is same. I really cant understand why. Im sure sensor is working normal.
enesert
Posts: 11
Joined: Sat May 22, 2021 11:41 am

Re: NUCLEO-G474RE BMP183 Output Problem

Post by enesert »

fpiSTM wrote: Sat May 22, 2021 4:57 pm So you set this in your sketch and wire on the correct pins ?

Code: Select all

// You can also use software SPI and define your own pins!
#define BMP183_CLK  13
#define BMP183_SDO  12  // AKA MISO
#define BMP183_SDI   11  // AKA MOSI

// You'll also need a chip-select pin, use any pin!
#define BMP183_CS   9

// initialize with hardware SPI
Adafruit_BMP183 bmp = Adafruit_BMP183(BMP183_CS);
// or initialize with software SPI and use any 4 pins
//Adafruit_BMP183 bmp = Adafruit_BMP183(BMP183_CLK, BMP183_SDO, BMP183_SDI, BMP183_CS);
In you sketch you have #include <f401reMap.h> but this is not part of official library of Adafruit: https://github.com/adafruit/Adafruit_BMP183_Library
Idem for pinMap(), don't know why you get this but seems not correct.

Which core you used?

Is there any possibility of a problem in this part?

Image
Post Reply

Return to “General discussion”