Beware that this post is related to an SDK in maintenance mode
More Info: Consider nRF Connect SDK for new designs

SPI declaration

Hi all,

I'm using an nRF52-DK for testing the connections of pressure sensors (BME/BMP280), I tested first with arduino, and then I'm using the same code with Platformio in VScode.

The connection and code are the same so I'm not sure what is failing, maybe the declaration of pins.

an example would be:

#include <Wire.h>
#include <SPI.h>
#include <Adafruit_BMP280.h>

#define BMP_SCK  (13)
#define BMP_MISO (12)
#define BMP_MOSI (11)
#define BMP_CS   (10)

Adafruit_BMP280 bmp(BMP_CS, BMP_MOSI, BMP_MISO,  BMP_SCK);

void setup() {
  Serial.begin(9600);
  Serial.println(F("BMP280 test"));

  //if (!bmp.begin(BMP280_ADDRESS_ALT, BMP280_CHIPID)) {
  if (!bmp.begin()) {
    Serial.println(F("Could not find a valid BMP280 sensor, check wiring or "
                      "try a different address!"));
    while (1) delay(10);
  }

}

void loop() {


    Serial.print(F("Pressure = "));
    Serial.print(bmp.readPressure());
    Serial.println(" Pa");
    

    Serial.println();
    delay(2000);
}

In Arduino IDE using Arduino UNO it woks.

In VScode with the nRF52-DK, the Terminal will show "Could not find a valid BMP280 sensor, check wiring or "
"try a different address!"

Can someone help me with this? is there a better way to read the pressure from this sensor?

Parents
  • I'm using Platformio in VScode so the code is the exact same. The board is an nRF52-DK (PCA10040) using SDK 17.1, or a customized board with the nRF52832. I don't have any errors from the code, the problem is that it doesn't detect the pressure sensors.

  • Hello again,

    pgonzaleztrucorp said:
    I'm using Platformio in VScode so the code is the exact same.

    I am unfortunately not familiar with Platformio either, as this is not a Nordic product nor something we support.
    Looking at the attached code it seems to me that your call to bmp.begin() fails, and so you should check with Platformio which drivers it is using behind the scenes, to determine why it is unable to find the sensor.
    Which input parameters should the begin function be called with?
    From your commented out line of code it seems that you should provide the device address to the begin call, while you do not in the failing function call. I cant see that you are providing this address elsewhere either.
    Is this the exact code that worked on the Arduino, or did you change anything in-between?

    Could you also detail your connection between the sensor and the nRF device, and confirm that you have checked the nRF module's datasheet to see if the pins you are attempting to use are available?

    Best regards,
    Karl

Reply
  • Hello again,

    pgonzaleztrucorp said:
    I'm using Platformio in VScode so the code is the exact same.

    I am unfortunately not familiar with Platformio either, as this is not a Nordic product nor something we support.
    Looking at the attached code it seems to me that your call to bmp.begin() fails, and so you should check with Platformio which drivers it is using behind the scenes, to determine why it is unable to find the sensor.
    Which input parameters should the begin function be called with?
    From your commented out line of code it seems that you should provide the device address to the begin call, while you do not in the failing function call. I cant see that you are providing this address elsewhere either.
    Is this the exact code that worked on the Arduino, or did you change anything in-between?

    Could you also detail your connection between the sensor and the nRF device, and confirm that you have checked the nRF module's datasheet to see if the pins you are attempting to use are available?

    Best regards,
    Karl

Children
No Data
Related