AVR library problems with Genuino 101

Hi all.

Im trying to use a e-Health shield from Cooking Hacks with a Genuino 101: https://www.cooking-hacks.com/documentation/tutorials/ehealth-biometric-sensor-platform-arduino-raspberry-pi-medical/

In Arduino UNO works fine, but when i change with Genuino 101 and I try to compile one of the example from the library of e-health, appears some error messages(i configure the board correctly):

Arduino:1.6.8 (Linux), Tarjeta:“Arduino/Genuino 101”

In file included from /home/dgonzalez/sketchbook/libraries/eHealth/eHealth.cpp:41:0:
/home/dgonzalez/sketchbook/libraries/eHealth/utils/i2c.h:3:20: fatal error: avr/io.h: No existe el archivo o el directorio
#include <avr/io.h>
compilation terminated.
exit status 1
Error compilación en tarjeta Arduino/Genuino 101.

Este reporte podría tener más información con
“Mostrar salida detallada durante la compilación”
opción habilitada en Archivo → Preferencias.

I search information about use Genuino 101, and i think that dont work with avr library: http://forum.arduino.cc/index.php?topic=391402.0;wap2

So how can i solve this problem?




I looked up the website and let me tell you, this sensor board is incredible. For the Star Trek geeks out there, you could make your own real live Tricorder with this board!

The issue you have run into is that the libraries you are trying to use are meant to be compiled with the Arduino Uno which is based on the avr architecture. The Arduino/Genuino 101 is not avr. This is common issue posted on the forum and I one I ran into as well.

I looked at the the code in the utils/i2c.h library on the eHealth shield site you referenced, and part of what I found in these code fragments:

// This library provides the high-level functions needed to use the I2C
// serial interface supported by the hardware of several AVR processors.
#include <avr/io.h>
#include <avr/interrupt.h>


I2C Functions

void i2cInit(void)
// set i2c bit rate to 40KHz
// enable TWI (two-wire interface)
sbi(TWCR, TWEN); // Enable TWI

indicate that registers specific to the uno chip are being used to program I2C. So I believe the programmers have implemented their own i2c library perhaps for reasons of efficiency?

But I don’t think all is lost, If you have all the hardware, why not try to access it through the standard arduino I2C libraries in the supported in the arduino IDE for the arduino/genuino101 package and not use the eHealth shield util/i2c.h library? You will have to rewrite code, but this it what it will take.

I also see that they have implemented software from the Raspberry Pi, and this is a broadcom chip based board, perhaps there are some hints on how to approach your issue if you look at how that code is written? I have looked at this code at it looks to be written in a a processor independent manner, such that there are using a generic I2C interface to communicate with the board! They do not use a special util/i2c.h library at all.

See this code fragment from the Rasp Pi eHealth.cpp library:

// Public Methods *

//! Name: initPositionSensor() *
//! Description: Initializes the position sensor and configure some values. *
//! Param : void *
//! Returns: void *
//! Example: eHealth.initPositionSensor(); *

void eHealthClass::initPositionSensor(void)
byte c;
/* Set up the interrupt pins, they’re set as active high, push-pull /
pinMode(int1Pin, INPUT);
digitalWrite(int1Pin, LOW);
pinMode(int2Pin, INPUT);
digitalWrite(int2Pin, LOW);
Read the WHO_AM_I register, this is a good test of communication */
c = readRegister(0x0D); // Read WHO_AM_I register
if (c == 0x2A) { // WHO_AM_I should always be 0x2A
initMMA8452(scale, dataRate); // init the accelerometer if communication is good
printf(“MMA8452Q is online…\n”);
} else {
printf(“Could not connect to MMA8452Q: 0x%X\n”,c);
//while (1); // Loop forever if communication doesn’t happen

That Wire.begin() statement is pure generic I2C, so with the I2C api for the arduino/genuino 101 you should be able to replicate this code!

Also if you look further down, don’t fear the readRegisters command! It is just fetching info back from the sensors on the eHealth board and not on the Rasp. PI or Uno. Therefore not specific to these architectures.

//! Read i registers sequentially, starting at address into the dest byte array.
void eHealthClass::readRegisters(char address, int i, char * dest)

MMA8452_ADDRESS refers in a 3-axis accelerometer chip and nothing particular to the broadcom or avr architecture.

To me it actually looks like the Rasp. Pi code might work better for this than the arduino code because I can’t see any architecture specific code there

I think with some i2c experimentation and digging through the code you will be able to access your eHealth shield directly with i2c. The promise of the e-Health shield/board look to be worth the effort to me.

You should also post your question to the forum on the CookingHacks site your reference, I see there were some similar concerns with compiling the software for other boards, and more help may be available there.
See this post:


Good luck and keep us updated!


I just saw this post and I have a similar problem with the IRemote.h library, could somebody walk me throw to see if I can adjust this library to so it works with the arduino 101??

Thank in advances!

best regards!