Comments (6)
Only call begin()
once for each sensor in setup
. There's no need to call it again to "switch" between them.
from adafruit_bmp280_library.
It's bad that you can't call begin() multiple times. Most, seeing this flaw in the library, said that the implementation was bad and needed some work.
I need to implement a task where there are many I2C devices. Everyone has different pins and different addresses. Without calling begin () again after calling Wire.begin (SDA, SCL), it is not possible to change the sensor initialization address.
An example of my code working:
void initLCD() {
Wire.begin (SDA, SCL); //D2,D1 Выбираем дисплей
}
void getBMP1() {
Wire.begin (14, 12); //D5,D6 Wire.begin(esda, escl);
if (!bmp.begin(0x76)) {
Serial.print("\nДатчик 0x76 не найден. Проверить интерфейс I2C или адрес.");
sendNoDataLCD();
}
else {
temperature = bmp.readTemperature();
pressure_Hg = pressure * 0.0075006F; //1Па = 0.0075006168 мм рт.ст.
sendDataLCD1();
}
}
void getBMP2() {...}
void getBMP3() {
Wire.begin (13, 2); //D7,D4 Wire.begin(esda, escl); где в скобках указаны пины!
if (!bmp.begin(0x77)) Serial.println("\nДатчик 0x77 не найден. Проверить интерфейс I2C или адрес.");
else {
temperature = bmp.readTemperature();
pressure_Hg = pressure * 0.0075006F;
sendDataLCD3();
}
}
void getBMP4() {...}
void sendDataLCD() {
initLCD();
lcd.setCursor(0,0);
lcd.print(temperature, 2);
}
lcd.setCursor(0,1);
lcd.print(pressure_Hg, 1);
lcd.print("mmHg");
}
void sendNoDataLCD() {
initLCD();
lcd.clear();
lcd.setCursor(0,0);
lcd.print(" No Connected ");
}
from adafruit_bmp280_library.
I need to implement a task where there are many I2C devices.
This library supports multiple sensors. Call begin()
once for each instance.
Everyone has different pins and different addresses
Why do they have different pins? Are they not all on the same I2C bus?
The example above is not complete. Where are your void setup()
and void loop()
?
from adafruit_bmp280_library.
This library supports multiple sensors. Call begin() once for each instance.
If I unplug the sensor and plug it back in, it won't work! So I call begin() before every read!
Why do they have different pins? Are they not all on the same I2C bus?
Because no more than two sensors can be connected to one bus.
The example above is not complete. Where are your void setup() and void loop()?
void setup() - like everyone else.
void loop() - calls the measurement script with an interval of once per second. The project is large, it makes no sense to upload it entirely. I have shown the used construction to show that the library is not working properly.
from adafruit_bmp280_library.
you have to use a multiplexor or something, what you're doing is not supported - call begin() once per sensor.
from adafruit_bmp280_library.
@ilya7zz You can try the 2.4.1 release when it becomes available:
https://github.com/adafruit/Adafruit_BMP280_Library/releases/tag/2.4.1
It adds the suggested basic checks for the dynamic memory allocation. Agree that doing that basic check is generally a good idea and worth adding. But no guarantee it will solve the issues for your use case.
from adafruit_bmp280_library.
Related Issues (20)
- Upgraded library to v 1.0.5 has wrong address HOT 2
- Pa or hPa? HOT 6
- Typo correction HOT 3
- Has travis even though it is labeled as not having it in spreadsheet HOT 1
- I can't compile the test code
- BMP 280 for both 0x76 and 0x77 Addresses HOT 1
- Unable to compile in Arduino IDE for WAVGAT UNO R3 HOT 1
- error: 'class Adafruit_BMP280' has no member named 'setI2CAddress' and further errors ... HOT 1
- Min Value swapped with Max Value HOT 3
- Convert to BusIO usage HOT 1
- different chip ID HOT 2
- include I2C bitbang HOT 3
- Adafruit_BMP280 does not initialize config structure, can result in erroneous configuration for SPI 3-wire mode HOT 2
- Failing Gracefully? HOT 5
- ESP32 Core panic when using constructor Adafruit_BMP280(&Wire) and using Adafruit_Sensor HOT 6
- Spelling mistake readTemperature method HOT 2
- not found in library: printSensorDetails HOT 1
- Library is missing dependency list (e.g., Adafruit_I2C) HOT 4
- Library doesn't work for ESP32 and ESP8266 in PlatformIO. #include <SPI.h>^~~~~~~ compilation terminated. HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from adafruit_bmp280_library.