Problems with Wire (I2C) [Solved]

Hi, I received my cores a couple of days ago and started tinkering around with it.
Now I wanted to port some of my Arduino Uno Apps to SparkCore. This App uses 2 Sensors via I2C protocol (Wire) which should be supported by the Cores. After flashing the Code to a core it freezes with a call of the Wire library, like endTransmission() or requestFrom(). The same code runs on the Arduino perfectly fine. So I’m sure my circuit is correct and the adresses and stuff for wire also. What else can go wrong?

P.S. The freezes can be interrupted by reset, but flashing the core is impossible via wifi, so I have to do a factory reset everytime.
P.P.S The Wire library also freezes when nothing is connected to Core

1 Like

Hello @Taron
Could you post your code here so that we could be in a better position to help?

I quickly wrote together a minimal example:

    void setup() {
    delay(10000); //10sec delay to be able to connect serial
    pinMode(7, OUTPUT);
    digitalWrite(7, HIGH); // just light the blue led to indicate loop is starting
    Serial.println(">>>>>>>>>>>>>>>>>>>>>>>>");  // just to be sure things are working

void loop() {
    byte address = 0x27; //adress of HIH-6130

The serial output is:


Then the core froze. No circuit was connected to the core.

1 Like

@Taron I’m able to replicate this bug on my side as well. @satishgn and I are looking into it right now. Will post as soon as we are able to resolve this. Thanks!

We have found out the cause of this issue. Should be resolved within a couple of days.


Nice to hear. Thanks

This explains all the problems I’ve been having. I was blaming my code flashing issues on the cloud, but it looks like this must have been the cause. I’m currently working on interfacing a wii nunchuck to the core and it uses wire extensively. Factory resetting is the only way I can re-flash.

@satishgn @mohit Any updates?

* Code for read data from Wii nunchuck., base on * File : ArduinoNunchuk.pde
* by : K.Worapoht
* Hardware: Arduino, POP-168 , AVR ATMega168 , * connect SDA to PC4 (An4) and SCL PC5 (An5)
* from:
//#include <Wire.h>
//#define nunchuck_ID 0xA4 >> 1
#define nunchuck_ID 0x52//0xA4		//0x52

unsigned char buffer[6];// array to store arduino output
int cnt = 0;

void nunchuck_init() {
	Wire.beginTransmission(nunchuck_ID);// transmit to device 0x52
	Wire.write(0x40); // sends memory address
	Wire.write(0x00); // sends sent a zero.
	Wire.endTransmission(); // stop transmitting

void send_zero() {
	Wire.beginTransmission(nunchuck_ID);// transmit to device 0x52
	Wire.write(0x00); // sends one byte
	Wire.endTransmission(); // stop transmitting

// Print the input data we have recieved // accel data is 10 bits long
// so we read 8 bits, then we have to add // on the last 2 bits.
void print() {
	unsigned char joy_x_axis;
	unsigned char joy_y_axis;
	int accel_x_axis;
	int accel_y_axis;
	int accel_z_axis;
	unsigned char z_button;
	unsigned char c_button;
	joy_x_axis = buffer[0]; 
	joy_y_axis = buffer[1]; 
	accel_x_axis = (buffer[2]) << 2;
	accel_y_axis = (buffer[3]) << 2; 
	accel_z_axis = (buffer[4]) << 2;
	// byte outbuf[5] contains bits for z and c buttons
	// it also contains the least significant bits for the accelerometer data
	// so we have to check each bit of byte outbuf[5]
	if ((buffer[5] & 0x01)!=0) {
		z_button = 1;
	} else {
		z_button = 0;
	if ((buffer[5] & 0x02)!=0){
		c_button = 1;
	} else{
		c_button = 0;
	accel_x_axis += ((buffer[5]) >> 2) & 0x03;
	accel_y_axis += ((buffer[5]) >> 4) & 0x03;
	accel_z_axis += ((buffer[5]) >> 6) & 0x03;
	Serial.print(joy_x_axis, DEC);
	Serial.print(joy_y_axis, DEC);
	Serial.print(accel_x_axis, DEC);
	Serial.print(accel_y_axis, DEC);
	Serial.print(accel_z_axis, DEC);
	Serial.print(z_button, DEC);
	Serial.print(c_button, DEC);

// Encode data to format that most wiimote drivers except
// only needed if you use one of the regular wiimote drivers
char nunchuk_decode_byte(char x) {
	x = (x ^ 0x17) + 0x17;
	return x;

void setup() {
	Wire.begin(); // join i2c bus with address 0x52
	nunchuck_init(); // send the initilization handshake
	delay(10000); //was 100
	Serial.println("welcome to nunchucknorris");

void loop() {
	Wire.requestFrom(nunchuck_ID, 6);// request data from nunchuck
	while (Wire.available()) {
		buffer[cnt] = nunchuk_decode_byte(; // receive byte as an integer
	// If we recieved the 6 bytes, then go print them
	if (cnt >= 5) {
	cnt = 0;
	send_zero(); // send the request for next bytes
1 Like

Hi @aylr,

It’s possible that the 10 second delay in your setup function is causing your core to time out with respect to the cloud. Right now the core checks its connection every 15 seconds, and it’s possible it thinks it went offline. We’re working on a fix for this bug, but it’s possible reducing the delay might help?


I was working on interfacing SparkCore via I2C to an LCD module. Was going nuts trying to get old code that had worked on other chips to fly with Spark. Finally found that I needed to shift the address left one bit when using the Write library in the cloud vs. other Arduino stuff.

This link says that address passed to Write.beginTransmission() is not to be shifted… but it must be to work with Spark:

I blamed everything else I was doing before I detected this problem. :frowning:

Of course, the Read/Write bit needs to be proper in the LSB position, as well. But I was only writing, so zero there worked just fine.

Is this fixed yet? Or how do you get this working exactly?

I have the same problems at the moment.

The Spark Wire implementation no longer requires the address to be shifted.

1 Like

Please reference this post that announced the fix for a little background on the issue:

1 Like