Hey
I am doing a project where I use an Arduino Nano and a pressure and temperature sensor from Adafruit (BMP280).
It turns out that I can't get readings, the monitor either gives a sensor error, or says it isn't connected. I've experimented with two breadboards, two Arduinos and two different sensors. I have already tested the connections with a multimeter and they all have power.
Going to the code, I already tested the example of the library and I also tested code provided by a teacher and from the internet and nothing. I suspect that the IDE is not getting the libraries but I can't be sure.
Thanks in advance for any help
Boa tarde
Estou a fazer um projeto onde utilizo um Arduino Nano e um sensor de pressão e temperatura da Adafruit (BMP280).
Acontece que não consigo obter leituras, o monitor ou dá erro do sensor, ou diz que não está ligado. Já experimentei com duas breadboard, dois arduinos e dois sensores diferentes. Já testei as ligações com um multímetro e todas passam corrente.
Indo para o código, já testei o exemplo da biblioteca e também já testei código fornecido por um professor e que encontrei online e nada. Desconfio que o IDE não esteja a inserir as bibliotecas mas não consigo ter a certeza.
Agradeço desde já qualquer ajuda
/***************************************************************************
This is a library for the BMP280 humidity, temperature & pressure sensor
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 andopen-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>
#include <Adafruit_BMP280.h>
#define BMP_SCK (13)
#define BMP_MISO (12)
#define BMP_MOSI (11)
#define BMP_CS (10)
Adafruit_BMP280 bmp; // I2C
//Adafruit_BMP280 bmp(BMP_CS); // hardware SPI
//Adafruit_BMP280 bmp(BMP_CS, BMP_MOSI, BMP_MISO, BMP_SCK);
void setup() {
Serial.begin(9600);
Serial.println(F("BMP280 test"));
if (!bmp.begin()) {
Serial.println(F("Could not find a valid BMP280 sensor, check wiring!"));
while (1);
}
/* Default settings from datasheet. */
bmp.setSampling(Adafruit_BMP280::MODE_NORMAL, /* Operating Mode. */
Adafruit_BMP280::SAMPLING_X2, /* Temp. oversampling */
Adafruit_BMP280::SAMPLING_X16, /* Pressure oversampling */
Adafruit_BMP280::FILTER_X16, /* Filtering. */
Adafruit_BMP280::STANDBY_MS_500); /* Standby time. */
}
void loop() {
Serial.print(F("Temperature = "));
Serial.print(bmp.readTemperature());
Serial.println(" *C");
Serial.print(F("Pressure = "));
Serial.print(bmp.readPressure());
Serial.println(" Pa");
Serial.print(F("Approx altitude = "));
Serial.print(bmp.readAltitude(1013.25)); /* Adjusted to local forecast! */
Serial.println(" m");
Serial.println();
delay(2000);
}