i tried the following code with the arduino uno it works perfectly but when trying with the stm32 I2C connections in any of the SCL and SDA is shows "Could not find a valid BMP3 sensor, check wiring!" #include <Wire.h> #include <SPI.h> #include <Adafruit_Sensor.h> #include "Adafruit_BMP3XX.h"
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 BMP3 sensor, check wiring!");
while (1);
}
// Set up oversampling and filter initialization
bmp.setTemperatureOversampling(BMP3_OVERSAMPLING_32X);
bmp.setPressureOversampling(BMP3_OVERSAMPLING_32X);
bmp.setIIRFilterCoeff(BMP3_IIR_FILTER_COEFF_127);
bmp.setOutputDataRate(BMP3_ODR_200_HZ);
}
void loop() {
if (! bmp.performReading()) {
Serial.println("Failed to perform reading :(");
return;
}
Serial.print("Temperature = ");
Serial.print(bmp.temperature);
Serial.println(" *C");
when i use this it works normally could some one help me please i think the problem is in the libary but i don't know how to correct it . thanks in advance
i am trying the i2c scanning but no device found this is i2c scan code i use
// --------------------------------------
// i2c_scanner
//
// Modified from Arduino Playground - I2cScanner
// --------------------------------------
#include <Wire.h>
// Set I2C bus to use: Wire, Wire1, etc. #define WIRE Wire
void setup() {
WIRE.begin();
Serial.begin(9600);
while (!Serial)
delay(10);
Serial.println("\nI2C Scanner");
}
void loop() {
byte error, address;
int nDevices;
Serial.println("Scanning...");
nDevices = 0;
for(address = 1; address < 127; address++ )
{
// The i2c_scanner uses the return value of
// the Write.endTransmisstion to see if
// a device did acknowledge to the address.
WIRE.beginTransmission(address);
error = WIRE.endTransmission();
if (error == 0)
{
Serial.print("I2C device found at address 0x");
if (address<16)
Serial.print("0");
Serial.print(address,HEX);
Serial.println(" !");
nDevices++;
}
else if (error==4)
{
Serial.print("Unknown error at address 0x");
if (address<16)
Serial.print("0");
Serial.println(address,HEX);
}
First of all, I think you were right the first time, to connect Vin on the 388 board to 5V. It should work fine and will relieve any demand on the Blue Pill's tiny regulator. The 388 board has it's own regulator and so the I/O pins will still operate at 3.3V as is compatible with the STM32 IC.
You seem to be on the right pins. You could also use the symbolic names provided by the STM32 core:
You said that "it detect the I2C address" but you also said "the serial monitor does not display anything". That is a puzzle. Then how do you know it detected an address?
I suggest checking all your baud rate settings, and post clear close up images of all your devices and wiring here.
Another thing, you keep posting code with no code tags. Please read the forum instructions on how to post code, how to correct postings that you have failed to format using code tags.
Looking at the code, that is hard to understand. Either it should print this:
Failed to perform reading
or
Temperature =
Any you certainly got it to print something using the I2C scanner.
Which STM32 core are you using? There are quite a few.
Try adding a delay() here:
if (! bmp.performReading()) {
Serial.println("Failed to perform reading :(");
delay( 2000 ) ; // prevent a possible crash from a recursive call of loop()
return;
}
It is true. But if you are a naive user, just go looking, it would be the official STM core that you would find and use. But yes, it would be better to specify which one.
True of course. Also, for a naive user, it would risk prompting the question "how do I find out which core I am using?". That he has not been struggling with "Serial1" tends to indicate at least it is not the "Roger Clark" core.
You do have to make sure the correct USB serial port options are chosen at upload - it's not like hardware ports that are always there. USB serial is an option with either the Maple-Clark core or the ST one.
Ok i would tag them but about the serial monitor i run the I2C testing code it detects the device but when I run the bmp388 code that normally works on the Arduino uno it doesn't shows anything on the serial monitor i hope it is more clearer for you to understand