I am building this recent project and see it uses a BME280 module. “ESP32/ESP8266 Insert Data into MySQL Database using PHP and Arduino IDE” I have a BMP180 module and gather it should be able to work in this project instead of BME280. I have altered all wording in the script to BMP180 and have downloaded the zipped libraries to support the BMP180.
However the code won’t compile and comes back with errors such as…
Arduino: 1.8.9 (Windows Store 1.8.21.0) (Windows 10), Board: "NodeMCU 1.0 (ESP-12E Module), 80 MHz, Flash, Disabled, All SSL ciphers (most compatible), 4M (no SPIFFS), v2 Lower Memory, Disabled, None, Only Sketch, 115200" esp8266_msql2:52:1: error: 'Adafruit_BMP180' does not name a type Adafruit_BMP180 bmp; // I2C ^ C:\Users\Paul\Documents\Arduino\Iotplayground2\esp8266_msql2\esp8266_msql2.ino: In function 'void setup()': esp8266_msql2:70:17: error: 'bmp' was not declared in this scope bool status = bmp.begin(0x76); ^ C:\Users\Paul\Documents\Arduino\Iotplayground2\esp8266_msql2\esp8266_msql2.ino: In function 'void loop()': esp8266_msql2:90:81: error: 'BMP' was not declared in this scope + "&location=" + sensorLocation + "&value1=" + String(BMP.readTemperature()) ^ esp8266_msql2:91:49: error: 'bmp' was not declared in this scope + "&value2=" + String(bmp.readHumidity()) + "&value3=" + String(bmp.readPressure()/100.0F) + ""; ^ exit status 1 'Adafruit_BMP180' does not name a type This report would have more information with "Show verbose output during compilation" option enabled in File -> Preferences.
Can anyone see what I have done wrong or offer any suggestions??
The code doesn’t work with the BMP180 sensor by default. You need to install the BMP180 library in your Arduino IDE: github.com/adafruit/Adafruit_BMP085_Unified
Then, you need to follow the example and make all the necessary changes to make it work with that sensor (import the right library, init the sensor, etc): github.com/adafruit/Adafruit_BMP085_Unified/blob/master/examples/sensorapi/sensorapi.pde
Hi, I have downloaded the BMP085 unified into the Arduino IDE. I cannot see the however what is required to make the BMP180 sensor work, where is that information located?? I have looked all over the github.com/adafruit/Adafruit_BMP085_Unified/blob/master/examples/sensorapi/sensorapi.pde.
You need to follow that exact example:
- github.com/adafruit/Adafruit_BMP085_Unified/blob/master/examples/sensorapi/sensorapi.pde
However, I simply recommend to try to compile that exact example first and see if you can read the sensor with that sketch. Does it work?
Then to merge with my database example, import those libraries:
#include <Wire.h> #include <Adafruit_Sensor.h> #include <Adafruit_BMP085_U.h>
Prepare it:
Adafruit_BMP085_Unified bmp = Adafruit_BMP085_Unified(10085);
Start the sensor (in the setup):
/* Initialise the sensor */ if(!bmp.begin()) { /* There was a problem detecting the BMP085 ... check your connections */ Serial.print("Ooops, no BMP085 detected ... Check your wiring or I2C ADDR!"); while(1); }
For example, to get the temperature:
float temperature; bmp.getTemperature(&temperature);
After adding all those lines, can you compile it?