Hi,
I've seen other people having similar issues but I'm unsure how to adapt their solutions to my problem, what I am trying to do is read sensor data off of this IMU with this code supplied by the manufacturer:
#include <Wire.h>
#include "DFRobot_BMP280.h"
DFRobot_BMP280 bmp280;
void setup() {
Serial.begin(9600);
Serial.println("BMP280 demo");
if (!bmp280.begin()) {
Serial.println("Could not find a valid BMP280 sensor!");
while (1);
}
}
void loop() {
Serial.print("Temperature = ");
Serial.print(bmp280.readTemperatureValue());
Serial.println(" *C");
Serial.print("Pressure = ");
Serial.print(bmp280.readPressureValue());
Serial.println(" Pa");
Serial.print("Altitude = ");
Serial.print(bmp280.readAltitudeValue(1013.25)); // this should be adjusted to your local forcase
Serial.println(" m");
Serial.println();
delay(2000);
}
But I keep getting this error:
Arduino: 1.8.3 (Windows 10), Board: "Arduino/Genuino Uno"
altitude_10dof:20: error: cannot declare variable 'bmp280' to be of abstract type 'DFRobot_BMP280'
DFRobot_BMP280 bmp280;
^
In file included from \\uol.le.ac.uk\root\student\home\s\sb715\My Documents\Arduino\altitude_10dof\altitude_10dof.ino:18:0:
\\uol.le.ac.uk\root\student\home\s\sb715\My Documents\Arduino\libraries\DFRobot_BMP280-master/DFRobot_BMP280.h:31:7: note: because the following virtual functions are pure within 'DFRobot_BMP280':
class DFRobot_BMP280 {
^
\\uol.le.ac.uk\root\student\home\s\sb715\My Documents\Arduino\libraries\DFRobot_BMP280-master/DFRobot_BMP280.h:225:19: note: virtual void DFRobot_BMP280::writeReg(uint8_t, uint8_t*, uint16_t)
virtual void writeReg(uint8_t reg, uint8_t *pBuf, uint16_t len) = 0;
^
\\uol.le.ac.uk\root\student\home\s\sb715\My Documents\Arduino\libraries\DFRobot_BMP280-master/DFRobot_BMP280.h:226:19: note: virtual void DFRobot_BMP280::readReg(uint8_t, uint8_t*, uint16_t)
virtual void readReg(uint8_t reg, uint8_t *pBuf, uint16_t len) = 0;
^
\\uol.le.ac.uk\root\student\home\s\sb715\My Documents\Arduino\altitude_10dof\altitude_10dof.ino: In function 'void loop()':
altitude_10dof:34: error: 'class DFRobot_BMP280' has no member named 'readTemperatureValue'
Serial.print(bmp280.readTemperatureValue());
^
altitude_10dof:38: error: 'class DFRobot_BMP280' has no member named 'readPressureValue'
Serial.print(bmp280.readPressureValue());
^
altitude_10dof:42: error: 'class DFRobot_BMP280' has no member named 'readAltitudeValue'
Serial.print(bmp280.readAltitudeValue(1013.25)); // this should be adjusted to your local forcase
^
exit status 1
cannot declare variable 'bmp280' to be of abstract type 'DFRobot_BMP280'
This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.
I have all the library's requested so I'm unsure why it's unable to declare this variable
Any help would be much appreciated
Thanks,
Scott