Hi,
I have a sketch that works on an Uno but will not compile when trying to upload to an mrk wifi 1010. The problem seems to be with the i2c library I am using found here:
I am trying to connect a 262-BMP280 barometer:
Here is the sketch:
#include <Wire.h>
#include "i2c.h"
#include "i2c_BMP280.h"
BMP280 bmp280;
String EAR = "RIGHT";
void setup()
{
Serial.begin(57600);
bmp280.initialize();
// 1-0-0 122Hz
// 2-0-0 96Hz
// 4-0-0 68Hz
// 16-0-0 28Hz
/*
val > 15 VAL_CTRL_OSRS_P16
val > 7 VAL_CTRL_OSRS_P08
val > 3 VAL_CTRL_OSRS_P04
val > 1 VAL_CTRL_OSRS_P02
val > 0 VAL_CTRL_OSRS_P01
*/
bmp280.setPressureOversampleRatio(1); // Ultra-high resolution?
/*
val > 15 VAL_FILTER_16;
val > 7 VAL_FILTER_08;
val > 3 VAL_FILTER_04;
val > 1 VAL_FILTER_02;
*/
bmp280.setFilterRatio(); // (disabled?) Infinite Impulse Response filter
/*
ms > 3000 VAL_SB_4000;
ms > 1500 VAL_SB_2000;
ms > 750 VAL_SB_1000;
ms > 350 VAL_SB_0500;
ms > 180 VAL_SB_0250;
ms > 90 VAL_SB_0125;
ms > 31 VAL_SB_0062;
*/
bmp280.setStandby(); // ((fastest) Oversampling: 0.5
// onetime-measure:
bmp280.setEnabled(0);
bmp280.triggerMeasurement();
}
void loop()
{
bmp280.awaitMeasurement();
float pascal;
bmp280.getPressure(pascal);
bmp280.triggerMeasurement();
Serial.println(EAR + " " + pascal);
}
And here is the error message:
Arduino: 1.8.8 (Windows 10), Board: "Arduino MKR WiFi 1010"
In file included from sketch\i2c_BMP280.ino.cpp:1:0:
C:\Users\cdjd4\Documents\Arduino\libraries\I2C-Sensor-Lib_iLib\src/i2c.h: In constructor 'WirePlus::WirePlus()':
C:\Users\cdjd4\AppData\Local\Arduino15\packages\arduino\hardware\samd\1.6.20\cores\arduino/Arduino.h:116:37: error: no match for 'operator|=' (operand types are '_EPortType' and 'long unsigned int')
#define bitSet(value, bit) ((value) |= (1UL << (bit)))
^
C:\Users\cdjd4\Documents\Arduino\libraries\I2C-Sensor-Lib_iLib\src/i2c.h:70:5: note: in expansion of macro 'bitSet'
bitSet(PORTC, 4); // deactivate internal pull-ups for twi
^
C:\Users\cdjd4\AppData\Local\Arduino15\packages\arduino\hardware\samd\1.6.20\cores\arduino/Arduino.h:116:37: note: candidate is:
#define bitSet(value, bit) ((value) |= (1UL << (bit)))
^
C:\Users\cdjd4\Documents\Arduino\libraries\I2C-Sensor-Lib_iLib\src/i2c.h:70:5: note: in expansion of macro 'bitSet'
bitSet(PORTC, 4); // deactivate internal pull-ups for twi
^
C:\Users\cdjd4\AppData\Local\Arduino15\packages\arduino\hardware\samd\1.6.20\cores\arduino/Arduino.h:116:37: note: operator|=(_EPortType&, long unsigned int) <built-in>
#define bitSet(value, bit) ((value) |= (1UL << (bit)))
^
C:\Users\cdjd4\Documents\Arduino\libraries\I2C-Sensor-Lib_iLib\src/i2c.h:70:5: note: in expansion of macro 'bitSet'
bitSet(PORTC, 4); // deactivate internal pull-ups for twi
^
C:\Users\cdjd4\AppData\Local\Arduino15\packages\arduino\hardware\samd\1.6.20\cores\arduino/Arduino.h:116:37: note: no known conversion for argument 1 from '_EPortType' to '_EPortType&'
#define bitSet(value, bit) ((value) |= (1UL << (bit)))
^
C:\Users\cdjd4\Documents\Arduino\libraries\I2C-Sensor-Lib_iLib\src/i2c.h:70:5: note: in expansion of macro 'bitSet'
bitSet(PORTC, 4); // deactivate internal pull-ups for twi
^
C:\Users\cdjd4\AppData\Local\Arduino15\packages\arduino\hardware\samd\1.6.20\cores\arduino/Arduino.h:116:37: error: no match for 'operator|=' (operand types are '_EPortType' and 'long unsigned int')
#define bitSet(value, bit) ((value) |= (1UL << (bit)))
^
C:\Users\cdjd4\Documents\Arduino\libraries\I2C-Sensor-Lib_iLib\src/i2c.h:71:5: note: in expansion of macro 'bitSet'
bitSet(PORTC, 5); // as per note from atmega8 manual pg167
^
C:\Users\cdjd4\AppData\Local\Arduino15\packages\arduino\hardware\samd\1.6.20\cores\arduino/Arduino.h:116:37: note: candidate is:
#define bitSet(value, bit) ((value) |= (1UL << (bit)))
^
C:\Users\cdjd4\Documents\Arduino\libraries\I2C-Sensor-Lib_iLib\src/i2c.h:71:5: note: in expansion of macro 'bitSet'
bitSet(PORTC, 5); // as per note from atmega8 manual pg167
^
C:\Users\cdjd4\AppData\Local\Arduino15\packages\arduino\hardware\samd\1.6.20\cores\arduino/Arduino.h:116:37: note: operator|=(_EPortType&, long unsigned int) <built-in>
#define bitSet(value, bit) ((value) |= (1UL << (bit)))
^
C:\Users\cdjd4\Documents\Arduino\libraries\I2C-Sensor-Lib_iLib\src/i2c.h:71:5: note: in expansion of macro 'bitSet'
bitSet(PORTC, 5); // as per note from atmega8 manual pg167
^
C:\Users\cdjd4\AppData\Local\Arduino15\packages\arduino\hardware\samd\1.6.20\cores\arduino/Arduino.h:116:37: note: no known conversion for argument 1 from '_EPortType' to '_EPortType&'
#define bitSet(value, bit) ((value) |= (1UL << (bit)))
^
C:\Users\cdjd4\Documents\Arduino\libraries\I2C-Sensor-Lib_iLib\src/i2c.h:71:5: note: in expansion of macro 'bitSet'
bitSet(PORTC, 5); // as per note from atmega8 manual pg167
^
In file included from C:\Users\cdjd4\Documents\Arduino\i2c_BMP280\i2c_BMP280.ino:5:0:
C:\Users\cdjd4\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;
^
exit status 1
Error compiling for board Arduino MKR WiFi 1010.
This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.
I must admit that c/c++ are not my main languages, I mostly work with c# and this is my first arduino project. I have spent the last week looking at this and could not find any answers which I think might be due to my lack of experience with the language. Any help or pointers would be most appreciated.