Hi! So I am facing a problem w getting data from a pressure sensor. Everything works except that when the data comes up, I only nan on every aspect.
I am not quite sure where the problem lies and would love to get some help on that (:
Here is the wiring:
Here is the code:
#include "Adafruit_BMP280.h"
Adafruit_BMP280 bmp;
void setup() {
bmp.begin();
Serial.begin(9600);
Serial.println("Start of measurements");
}
void loop() {
float t = bmp.readTemperature();
float p = bmp.readPressure();
float h = bmp.readAltitude(1012.3);
Serial.print("Temperature = ");
Serial.print(t);
Serial.print(" *C");
Serial.print("Pressure = ");
Serial.print(p);
Serial.print(" Pa");
Serial.print("Altitude = ");
Serial.print(h);
Serial.print(" m");
Serial.println();
delay(2000);
}
Use this Adafruit BMP280 Library example and say what happened.
/***************************************************************************
This is a library for the BMP280 humidity, temperature & pressure sensor
This example shows how to take Sensor Events instead of direct readings
Designed specifically to work with the Adafruit BMP280 Breakout
----> http://www.adafruit.com/products/2651
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
***************************************************************************/
#include <Wire.h>
#include <SPI.h>
This file has been truncated. show original
Hi, thanks for your reply! I have tried the code which you sent but I still can't seem to get any data. when using the code you suggested, the program has an error and says to check the wiring, although I think the wiring is correct...
alaynahassan:
Adafruit_BMP280
You may have a bad pull up resistor on the board. Try adding a pull-up to SDA and SCK. Run the I2C scanner before and again after adding the resistors and let us know what you get.
Hi! Thanks for your reply! Unfortunately, it still did not work and I still keep getting nan for all my values...
You need to solder those header pins on the BMP280 breakout board.
You can't expect to get a proper connection with the pins just pushed in the holes of the PCB.
system
Closed
September 11, 2024, 2:50pm
7
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.