Adafruit_MAX31855 won't compile on Arduino MRK Zero

I have a brand new Arduino MKR Zero. I want to use a Adafruit MAX31855 board to measure temperature but it won't compile the example code. I tried the example code on a MEGA and it works great so it isn't the board. The Zero is recognized fine in the IDE and I can compile a blank sketch so it works. So then I try just
#include <SPI.h>
compiles fine.

then I try
#include <SPI.h>
#include "Adafruit_MAX31855.h"

and it fails with a long error screen. These are the first 2 lines in the Adafruit MAX31855 example code. So it definitely is the #include "Adafruit_MAX31855.h" line. I'm pretty sure the MKR Zero has a SPI input so that isn't an issue. Right now Idon't even have anything connected to the board yet. I just want it to compile.

the error message is very long but I can give you some of it. More if you need it.

This is from the top.

Arduino: 1.8.13 (Windows 10), Board: "Arduino MKR Zero"

In file included from C:\Users\jrkeme\AppData\Local\Arduino15\packages\arduino\tools\CMSIS-Atmel\1.2.0/CMSIS/Device/ATMEL/samd21/include/samd21.h:69:0,
from C:\Users\jrkeme\AppData\Local\Arduino15\packages\arduino\tools\CMSIS-Atmel\1.2.0/CMSIS/Device/ATMEL/samd.h:105,
from C:\Users\jrkeme\AppData\Local\Arduino15\packages\arduino\hardware\samd\1.8.14\cores\arduino/WVariant.h:22,
from C:\Users\jrkeme\AppData\Local\Arduino15\packages\arduino\hardware\samd\1.8.14\variants\mkrzero/variant.h:24,

This goes on for a while. The first sign of an issue is later

In file included from C:\Users\jrkeme\Documents\Arduino\libraries\arduino_488392\Adafruit_I2CDevice.cpp:1:0:
C:\Users\jrkeme\Documents\Arduino\libraries\arduino_488392/Adafruit_I2CDevice.h:9:36: error: 'TwoWire' has not been declared
Adafruit_I2CDevice(uint8_t addr, TwoWire theWire = &Wire);
^~~~~~~
C:\Users\jrkeme\Documents\Arduino\libraries\arduino_488392/Adafruit_I2CDevice.h:28:3: error: 'TwoWire' does not name a type; did you mean 'TwoWire_h'?
TwoWire _wire;
^~~~~~~
TwoWire_h
C:\Users\jrkeme\Documents\Arduino\libraries\arduino_488392/Adafruit_I2CDevice.h:9:55: error: could not convert '& Wire' from 'arduino::TwoWire
' to 'int
'
Adafruit_I2CDevice(uint8_t addr, TwoWire *theWire = &Wire);

any idea?

Thanks
Jason

arduino_488392 is an unusual library name. I'd expect to find Adafruit_I2CDevice.h in the Adafruit_BusIO library.

Just a stab in the dark, but since the error is about I2C stuff, have you tried manually including Wire.h along with SPI.h?

no. but I will right now. Thanks.
I'm good enough with Arduino stuff but not when errors come up that I'm not familiar with. I've used I2C and SPI on other projects but the MKR Zero seems more finicky than the bulletproof Mega.

unfortunately it didn't work.
same error. the ending of the error message is a follows.

size_t recv = _wire->requestFrom((uint8_t)_addr, (uint8_t)len, (uint8_t)stop);
^~~~~
Wire
C:\Users\jrkeme\Documents\Arduino\libraries\arduino_488392\Adafruit_I2CDevice.cpp: In member function 'bool Adafruit_I2CDevice::setSpeed(uint32_t)':
C:\Users\jrkeme\Documents\Arduino\libraries\arduino_488392\Adafruit_I2CDevice.cpp:246:3: error: '_wire' was not declared in this scope
_wire->setClock(desiredclk);
^~~~~
C:\Users\jrkeme\Documents\Arduino\libraries\arduino_488392\Adafruit_I2CDevice.cpp:246:3: note: suggested alternative: 'Wire'
_wire->setClock(desiredclk);
^~~~~
Wire
exit status 1
Error compiling for board Arduino MKR Zero.

That library name still sticks out like a sore thumb. I wonder if something's not installed properly?

Yup, something's not installed properly. While I don't have a MKR Zero, it occurred to me that's no obstacle to compiling a sketch for one.

Sketch

#include <SPI.h>
#include "Adafruit_MAX31855.h"

void setup() {
}

void loop() {
}

Compile result

arduino-cli compile -b arduino:samd:mkrzero --warnings all --output-dir /home/me/tmp --no-color (in directory: /home/me/Documents/sketchbook/MKR_Zero/test)
Sketch uses 14104 bytes (5%) of program storage space. Maximum is 262144 bytes.
Global variables use 3068 bytes (9%) of dynamic memory, leaving 29700 bytes for local variables. Maximum is 32768 bytes.
Used library              Version Path
SPI                       1.0     /home/me/.arduino15/packages/arduino/hardware/samd/1.8.14/libraries/SPI
Adafruit MAX31855 library 1.4.2   /home/me/Documents/sketchbook/libraries/Adafruit_MAX31855_library
Adafruit BusIO            1.16.0  /home/me/Documents/sketchbook/libraries/Adafruit_BusIO
Wire                      1.0     /home/me/.arduino15/packages/arduino/hardware/samd/1.8.14/libraries/Wire
Used platform Version Path
arduino:samd  1.8.14  /home/me/.arduino15/packages/arduino/hardware/samd/1.8.14
Compilation finished successfully.

him. maybe I can locate another PC to try it on

OK. I tried a different PC. And it compiled OK. So it looks like it’s something wrong with my own PC. Thanks for the help guys. They are messages is so long and vague. I wasn’t sure what it was but it seems like somethings not installed right. Thanks again.

OK I'm an idiot. The Adafruit BusIO library was old and needed to be updated. Problem solved. Thanks everyone.
Jason

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.