I2C verification errors in Arduino IDE for MKR Boards

Hey
I am consistently getting a compiler message when trying to use the basic examples in the Blues Wireless Notecard library 1.83 in Arduino IDE desktop and in the Arduino cloud, messages are the same. Target device is a MKRZERO.
UPDATE: I tried compiling for other MKR boards as the target and the same issue. For other board types like the adafruit feather it compiles fine.

Log error is consistent for all combinations of headers, with and without Arduino and Wire includes.

In file included from C:\Users\dexte\Documents\Arduino\libraries\Blues_Wireless_Notecard\src\NoteI2c_Arduino.cpp:1:0:
C:\Users\dexte\Documents\Arduino\libraries\Blues_Wireless_Notecard\src\NoteI2c_Arduino.hpp:16:29: error: expected ‘)’ before ‘&’ token
NoteI2c_Arduino(TwoWire & i2c_bus);
^

Sketch and full logs below.

Any help appreciated at this point thanks!

#include <Arduino.h>

#include <Notecard.h>


#define serialDebug Serial


#define productUID "my.product.ID"


Notecard notecard;


void setup (void) {

  serialDebug.begin(115200);

  while (!serialDebug) {

    ; // wait for serial port to connect. Needed for native USB

  }

  notecard.begin();

  notecard.setDebugOutputStream(serialDebug);


  J *req = notecard.newRequest("hub.set");

  JAddStringToObject(req, "product", productUID);

  JAddStringToObject(req, "mode", "continuous");

  notecard.sendRequest(req);

}


void loop (void) {


}

Full log

In file included from C:\Users\dexte\Documents\Arduino\libraries\Blues_Wireless_Notecard\src\NoteI2c_Arduino.cpp:1:0:
C:\Users\dexte\Documents\Arduino\libraries\Blues_Wireless_Notecard\src\NoteI2c_Arduino.hpp:16:29: error: expected ‘)’ before ‘&’ token
NoteI2c_Arduino(TwoWire & i2c_bus);
^
In file included from C:\Users\dexte\Documents\Arduino\libraries\Blues_Wireless_Notecard\src\NoteI2c_Arduino.cpp:1:0:
C:\Users\dexte\Documents\Arduino\libraries\Blues_Wireless_Notecard\src\NoteI2c_Arduino.hpp:23:5: error: ‘TwoWire’ does not name a type; did you mean ‘TwoWire_h’?
TwoWire & _i2cPort;
^~~~~~~
TwoWire_h
C:\Users\dexte\Documents\Arduino\libraries\Blues_Wireless_Notecard\src\NoteI2c_Arduino.cpp:43:1: error: prototype for ‘NoteI2c_Arduino::NoteI2c_Arduino(arduino::TwoWire&)’ does not match any in class ‘NoteI2c_Arduino’
NoteI2c_Arduino::NoteI2c_Arduino
^~~~~~~~~~~~~~~
In file included from C:\Users\dexte\Documents\Arduino\libraries\Blues_Wireless_Notecard\src\NoteI2c_Arduino.cpp:1:0:
C:\Users\dexte\Documents\Arduino\libraries\Blues_Wireless_Notecard\src\NoteI2c_Arduino.hpp:13:7: error: candidates are: constexpr NoteI2c_Arduino::NoteI2c_Arduino(const NoteI2c_Arduino&)
class NoteI2c_Arduino final : public NoteI2c
^~~~~~~~~~~~~~~
C:\Users\dexte\Documents\Arduino\libraries\Blues_Wireless_Notecard\src\NoteI2c_Arduino.hpp:13:7: error:                 constexpr NoteI2c_Arduino::NoteI2c_Arduino()
C:\Users\dexte\Documents\Arduino\libraries\Blues_Wireless_Notecard\src\NoteI2c_Arduino.cpp: In destructor ‘virtual NoteI2c_Arduino::~NoteI2c_Arduino()’:
C:\Users\dexte\Documents\Arduino\libraries\Blues_Wireless_Notecard\src\NoteI2c_Arduino.cpp:57:5: error: ‘_i2cPort’ was not declared in this scope
_i2cPort.end();
^~~~~~~~
C:\Users\dexte\Documents\Arduino\libraries\Blues_Wireless_Notecard\src\NoteI2c_Arduino.cpp:57:5: note: suggested alternative: ‘Port’
_i2cPort.end();
^~~~~~~~
Port
C:\Users\dexte\Documents\Arduino\libraries\Blues_Wireless_Notecard\src\NoteI2c_Arduino.cpp: In member function ‘virtual const char* NoteI2c_Arduino::receive(uint16_t, uint8_t*, uint16_t, uint32_t*)’:
C:\Users\dexte\Documents\Arduino\libraries\Blues_Wireless_Notecard\src\NoteI2c_Arduino.cpp:77:9: error: ‘_i2cPort’ was not declared in this scope
i2cPort.beginTransmission(static_cast<uint8_t>(device_address));
^~~~~~~~
C:\Users\dexte\Documents\Arduino\libraries\Blues_Wireless_Notecard\src\NoteI2c_Arduino.cpp:77:9: note: suggested alternative: ‘Port’
i2cPort.beginTransmission(static_cast<uint8_t>(device_address));
^~~~~~~~
Port
C:\Users\dexte\Documents\Arduino\libraries\Blues_Wireless_Notecard\src\NoteI2c_Arduino.cpp:114:18: error: in argument to unary !
if (!response_length) {
^~~~~~~~~~~~~~~
C:\Users\dexte\Documents\Arduino\libraries\Blues_Wireless_Notecard\src\NoteI2c_Arduino.cpp: In member function ‘virtual bool NoteI2c_Arduino::reset(uint16_t)’:
C:\Users\dexte\Documents\Arduino\libraries\Blues_Wireless_Notecard\src\NoteI2c_Arduino.cpp:159:5: error: ‘_i2cPort’ was not declared in this scope
_i2cPort.end();
^~~~~~~~
C:\Users\dexte\Documents\Arduino\libraries\Blues_Wireless_Notecard\src\NoteI2c_Arduino.cpp:159:5: note: suggested alternative: ‘Port’
_i2cPort.end();
^~~~~~~~
Port
C:\Users\dexte\Documents\Arduino\libraries\Blues_Wireless_Notecard\src\NoteI2c_Arduino.cpp: In member function ‘virtual const char* NoteI2c_Arduino::transmit(uint16_t, uint8_t*, uint16_t)’:
C:\Users\dexte\Documents\Arduino\libraries\Blues_Wireless_Notecard\src\NoteI2c_Arduino.cpp:175:5: error: 'i2cPort’ was not declared in this scope
i2cPort.beginTransmission(static_cast<uint8_t>(device_address));
^~~~~~~~
C:\Users\dexte\Documents\Arduino\libraries\Blues_Wireless_Notecard\src\NoteI2c_Arduino.cpp:175:5: note: suggested alternative: ‘Port’
i2cPort.beginTransmission(static_cast<uint8_t>(device_address));
^~~~~~~~
Port
C:\Users\dexte\Documents\Arduino\libraries\Blues_Wireless_Notecard\src\NoteI2c_Arduino.cpp: In instantiation of ‘NoteI2c* make_note_i2c(T&) [with T = arduino::TwoWire]’:
C:\Users\dexte\Documents\Arduino\libraries\Blues_Wireless_Notecard\src\Notecard.h:84:37:   required from here
C:\Users\dexte\Documents\Arduino\libraries\Blues_Wireless_Notecard\src\NoteI2c_Arduino.cpp:37:20: error: no matching function for call to ‘NoteI2c_Arduino::NoteI2c_Arduino(arduino::TwoWire&)’
note_i2c = new NoteI2c_Arduino(i2c_parameters);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from C:\Users\dexte\Documents\Arduino\libraries\Blues_Wireless_Notecard\src\NoteI2c_Arduino.cpp:1:0:
C:\Users\dexte\Documents\Arduino\libraries\Blues_Wireless_Notecard\src\NoteI2c_Arduino.hpp:13:7: note: candidate: constexpr NoteI2c_Arduino::NoteI2c_Arduino()
class NoteI2c_Arduino final : public NoteI2c
^~~~~~~~~~~~~~~
C:\Users\dexte\Documents\Arduino\libraries\Blues_Wireless_Notecard\src\NoteI2c_Arduino.hpp:13:7: note:   candidate expects 0 arguments, 1 provided
C:\Users\dexte\Documents\Arduino\libraries\Blues_Wireless_Notecard\src\NoteI2c_Arduino.hpp:13:7: note: candidate: constexpr NoteI2c_Arduino::NoteI2c_Arduino(const NoteI2c_Arduino&)
C:\Users\dexte\Documents\Arduino\libraries\Blues_Wireless_Notecard\src\NoteI2c_Arduino.hpp:13:7: note:   no known conversion for argument 1 from ‘arduino::TwoWire’ to ‘const NoteI2c_Arduino&’
exit status 1

Compilation error: exit status 1
 

Hi @Dexterg,

Welcome to the forums! Outstanding catch, thank you!

I was able to easily reproduce your issue (which only appears on the SAMD BSP). The bug first appeared in v1.8.2, and it has to do with an #include that was removed in that release.

SAMD’s Wire.h (line 30-91) defines TwoWire inside the arduino:: namespace. This is unique to the SAMD implementation, and is the source of the issue. Other platforms (AVR, ESP32, etc.) define TwoWire directly in the global namespace without any namespace wrapper. This also explains why including Wire.h did not fix your problem.

We previously included Notecard.h in NoteI2c_Arduino.hpp, used to include Notecard.h, which used to include Arduino.h. SAMD’s Arduino.h (line 31) has using namespace arduino; which brings all arduino:: symbols into the global namespace

As a fix, I am now including the missing using statement in NoteI2c_Arduino.hpp.

Thanks for the great report!

Zak

Zak, thanks for the kind words and quick response, Ill test it out once released!

I fell back to using the serial input for this application, which worked great. The libraryless example was really useful for testing the sync flow.

Notecard is a great product, thanks to you folks at blues for massively simplifying connectivity for deployed applications.

Best

1 Like

Hey @Dexterg ,

Here is the PR if you want to watch it:

After some testing, I figured out that it is better to #include <Arduino.h> instead of trying to use the using statement. It appears to be a bug (or inconsistency) in Arduino’s SAMD BSP; it does not exist in the Adafruit SAMD BSP.

It is such a low-risk fix, that as soon as the CI runs, I’ll merge it and create a release.

I should have a new release for in by morning.

Thanks again for the report!

Zak

P.S. I added your board to the test matrix. :+1:

2 Likes