Good evening guys! Hope you are well
I'm doing a project that uses a BMP280. When I tested this code with an Arduino Uno, it worked well. But, when I tried using the ESP32 I have these problems:
/*
In file included from sketch\BMP280_-_CODIGO.ino.cpp:1:0:
C:\Users\Bru\Documents\Arduino\libraries\I2C-Sensor-Lib_iLib\src/i2c.h: In constructor 'WirePlus::WirePlus()':
C:\Users\Bru\Documents\Arduino\libraries\I2C-Sensor-Lib_iLib\src/i2c.h:70:12: error: 'PORTC' was not declared in this scope
bitSet(PORTC, 4); // deactivate internal pull-ups for twi
^
C:\Users\Bru\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.4\cores\esp32/Arduino.h:89:30: note: in definition of macro 'bitSet'
#define bitSet(value, bit) ((value) |= (1UL << (bit)))
^
In file included from C:\Users\Bru\Desktop\BMP280_-_CODIGO\BMP280_-_CODIGO.ino:2:0:
C:\Users\Bru\Documents\Arduino\libraries\I2C-Sensor-Lib_iLib\src/i2c.h:73:5: error: 'TWBR' was not declared in this scope
TWBR = ((F_CPU / 400000L) - 16) / 2; // see twi_init in Wire/utility/twi.c
^
exit status 1
Error compiling for the ESP32 Dev Module
*/
I tested a MPU6050 in this ESP32 and it worked well. But the code I tried for the BMP280 didn't have the same lucky.
The code is:
"
#include <Wire.h>
#include "i2c.h"
#include "i2c_Sensor.h";
#include "i2c_BMP280.h"
BMP280 bmp280;
void setup()
{
Serial.begin(9600);
Serial.print("Situacao do BMP280: ");
if (bmp280.initialize()) Serial.println("BMP280 DETECTADO"); //Detected
else
{
Serial.println("BMP280 não detectado"); //Not detected
while (1) {}
}
//Medida para setar os dados
bmp280.setEnabled(0);
bmp280.triggerMeasurement();
}
void loop()
{
//Espera medicao
bmp280.awaitMeasurement();
//Declara temperatura e pega ela
float temperature;
bmp280.getTemperature(temperature);
//Pega a pressao em pascal
float pascal;
bmp280.getPressure(pascal);
static float meters, metersold;
bmp280.getAltitude(meters);
metersold = (metersold * 10 + meters)/11;
bmp280.triggerMeasurement();
Serial.print(" Alt média: ");
Serial.print(metersold);
Serial.print(" m; Alt atual: ");
Serial.print(meters);
Serial.print(" Pressao: ");
Serial.print(pascal);
Serial.print(" Pa; T: ");
Serial.print(temperature);
Serial.println(" C");
delay(100);
}
''
Do you have any suggestions that I could do to solve it?
From now, thank you for your time!
Att, Bruno
BMP280 - code
-
- Posts: 1
- Joined: Thu Feb 25, 2021 12:42 am
Jump to
- English Forum
- Explore
- News
- General Discussion
- FAQ
- Documentation
- Documentation
- Sample Code
- Discussion Forum
- Hardware
- ESP-IDF
- ESP-BOX
- ESP-ADF
- ESP-MDF
- ESP-WHO
- ESP-SkaiNet
- ESP32 Arduino
- IDEs for ESP-IDF
- ESP-AT
- ESP IoT Solution
- ESP RainMaker
- Rust
- ESP8266
- Report Bugs
- Showcase
- Chinese Forum 中文社区
- 活动区
- 乐鑫活动专区
- 讨论区
- 全国大学生物联网设计竞赛乐鑫答疑专区
- ESP-IDF 中文讨论版
- 《ESP32-C3 物联网工程开发实战》书籍讨论版
- 中文文档讨论版
- ESP-AT 中文讨论版
- ESP-BOX 中文讨论版
- ESP IoT Solution 中文讨论版
- ESP-ADF 中文讨论版
- ESP Mesh 中文讨论版
- ESP Cloud 中文讨论版
- ESP-WHO 中文讨论版
- ESP-SkaiNet 中文讨论版
- ESP 生产支持讨论版
- 硬件问题讨论
- 项目展示
Who is online
Users browsing this forum: No registered users and 84 guests
- All times are UTC
- Top
- Delete cookies
About Us
Espressif Systems is a fabless semiconductor company providing cutting-edge low power WiFi SoCs and wireless solutions for wireless communications and Internet of Things applications. ESP8266EX and ESP32 are some of our products.