Friday, December 19, 2014

Windows IoT on Galileo – Connecting Adafruit 10DOF IMU Breakout Part-2

This blog is the continuation of the previous blog Windows IoT on Galileo – Connecting Adafruit 10DOF IMU Breakout Part-1 and explain you on the changes required on the source code to support with new OS update ( A common OS version for both Galileo Gen 1 and Gen2) and SDK update released on Dec 2014. Updated project is available on the following link in the codeplex. It can support for the older version of OS image for Gen 1 using Galileo SDK and lightning version of OS update for both Gen1 and Gen2 with Microsoft IoT C++ SDK.

Development Environment
·         Supported for both Intel Galileo Gen1 and Gen2
·         OS updated released on 21-Nov-2014 (common .wim for Gen1 and Gen2) for lightning (improved performance on I2C, SPI, and UART etc..)
·         Visual studio 2013 with Windows IoT SDK (Visit: for more details) and Microsoft IoT C++ SDK and its dependent NuGet Package is required.

Make it work
I have got a new Gen 2 board And at the same time I saw the new release on Microsoft connect for both Gen1 and Gen 2 with lighting support. Eagerly attempt the same work explained in the earlier blog with a faster failure result which is unexpected which create more wondering on it. Let me explain the issues I have faced and how I resolved it.
Issue 1: Sketch Aborted! A fatal error has occurred: An error occurred queueing an I2C write of 0 bytes.
It is related to Adafruit source code for the 3 sensors (L3GD20H + LSM303 + BMP180) which I have downloaded from the links shown earlier blog. It is due to unnecessary wire.endTransmission() call after in all the 3 sensors read16() or read8() functions. Wire.endTransmission() - Ends a transmission to a slave device that was begun by beginTransmission()) and transmits the bytes that were queued by write(). I don’t why it is called after in this code.
This endTransmission API calls the I2cTransactionClass::queueWrite() internally which check the bufferBytes == 0 and return error as ERROR_INVALID_PARAMETER and finally This EndTransmission API thrown the exception and causes "Sketch Aborted! A fatal error has occurred: An error occurred queueing an I2C write of 0 bytes. Error: 0x00000057" .
After comment the wire.endTransmission() from the read16() and read8() resolved this issue.
endTransmission() in Older Galileo SDK simply perform I2Cwrite and simpy return NACK and not throwing any exception and also the return value for the endTransmission is not handled in Adafruit code. so it is working in older Galileo SDK.

Issue 2: Sketch Aborted! A fatal error has occurred: Error encountered setting I2C address: 0x77
It is related to Microsoft IoT C++ SDK. One of sensor BMP180 in the board has BMP180 the slave address of 0x77. According to the I2C spec it is valid address. The I2C specification has reserved two sets of eight addresses, 1111XXX (0x78 and above) and 0000XXX (less than 0x8 ). These addresses are used for special purposes. traced the code flow and found that wire.beginTransmission() calls _setSlaveAddress() which in turn calls I2cTransactionClass::setAddress(ULONG slaveAdr) in I2cController.cpp. This function has the bug as shown in the below figure.

The conditional statement for slave address checking includes 0x77 as a special purpose which creates this issue. After changes this code, it worked as expected. Pull request has made to MS-IoTGithub and changes will be updated in next release of Microsoft IoT C++ SDK.

Wednesday, November 26, 2014

Windows IoT on Galileo – Connecting Adafruit 10DOF IMU Breakout Part - 1

This blog explain you on how to connect the Adafruit 10DOF IMU (A combo board provides 3-axis gyro, 3-axis compass, barometric pressure and temperature sensors) to Galileo Gen 1 board using Windows IoT. I bought this sensor board for some other purpose but I found it is also Arduino compatible, so I tried with Galileo and succeeded.

  • ·         Intel Galileo Gen1
  • ·         Visual studio 2013 with Windows IoT SDK (Visit: for more details) and Galileo C++ SDK NuGet Package is required.
10DOF IMU board is connect to Galileo through I2C interface. It needs 5V power and SDA and SCL is also 5V pins. See the below block diagram for the connectivity.

Figure 1) Galileo gen 1 with Adafruit 10 DOF IMU wiring

Figure b) Galileo Gen 1 with 10 DOF IMU module

How to make it work
Since this module has the combination of sensors, you can find the each sensor source code separately from the Adafruit’s github. Here is the links, (only Adafruit_Sensor.h is required)

I created a “Galileo Wiring App” application and included the required .cpp and .h files, which I downloaded from the above listed Adafruit github. I did few modification to resolve some compilation errors and just mapped the code from tester.pde file to main.cpp of my application since it is following the same ArdunioSketch.
This application read the data from sensors and print it on serial port. I used the debug UART for printing messages. Since it is mapped for kernel debugger you have to do some changes in bcd file as mentioned in the topic Allow UART to be used for HardwareSerial (This will change it from kernel debugger use)”  to use it as a serial port in OS. This port is COM2, HardwareSerial Serial1 Object is mapped to COM2. I changed the source code to use this port.

I also noticed that the carriage return (\r) is missed in the println() and caused the printed messages unaligned. So I just added the ‘\r’ on the below code in the path “\packages\Microsoft.IoT.Galileo.Arduino.1.0.6\build\native\include\print.h”. Of course it is part of the “Galileo C++ SDK” package.

Set the serial port terminal application (I am using Tera Term) for the baud rate 115200, 8bit, Parity N, Stop bit 1 and Flow control as N. Run the application from Visual studio through remote debugger. Here is the output on Tera Term.

Figure 3) Application sending sensors data to serial port continuously

Source code
You can find the source code of this application from the below codeplex link.
I am a WinCE guy and Of course this my first experience with Galileo/Ardunio wiring application development and it took less than an hour for this work. It is really a cool stuff. Enjoy  !!!.