1 2 Previous Next 18 Replies Latest reply on Sep 10, 2015 4:49 PM by Beakman

    Edison Arduino i2c


      Sorry for yet another post about getting i2c to work, but here goes.  Since I was unable to get my Adafruit type i2c LCD display working on the Edison, I decided to try something simpler or so I thought... a Sparkfun SEN-11931 i2c tmp102 temperature sensor.


      This sensor can be hard configured to use i2c addresses 0x48 or 0x49. Needless to say, it works fine on an Arduino UNO connected to A4/A5 using this sketch.


      //Arduino 1.0+ Only

      //Arduino 1.0+ Only



      //©2011 bildr

      //Released under the MIT License - Please reuse change and share

      //Simple code for the TMP102, simply prints temperature via serial



      #include <Wire.h>

      int tmp102Address = 0x48;


      void setup(){





      void loop(){


        float celsius = getTemperature();

        Serial.print("Celsius: ");




        float fahrenheit = (1.8 * celsius) + 32; 

        Serial.print("Fahrenheit: ");



        delay(2000); //just here to slow down the output. You can remove this



      float getTemperature(){



        byte MSB = Wire.read();

        byte LSB = Wire.read();


        //it's a 12bit int, using two's compliment for negative

        int TemperatureSum = ((MSB << 8) | LSB) >> 4;


        float celsius = TemperatureSum*0.0625;

        return celsius;



      However, even though it compiles and uploads OK, nothing at all prints to Arduino's Serial Monitor screen when it's running on the Edison Arduino board. Using a scope, I confirmed the Edison-Arduino is sending out clock on A5 and data on A4, so I know the script is running and I have the right pins. BTW, I scoped it with the sensor disconnected.


      I have to assume the issue lies in the Wire.h library as implemented in the Edison-Arduino IDE which has:


      #define I2C2 0x4819c000

      #define I2C1 0x00000000



      From other posts, I am led to believe 'I2C2 0x4819c000' equates to BUS ID 6. For one thing, I don't understand how this translates to ID 6?


      In any case, how can I get the above script to run on an Edsion-Arduino?  The sensor itself doesn't care what bus it is on, right? It only cares about the i2c address.

        • 1. Re: Edison Arduino i2c

          The Edison is an x86, 32-bit machine. Maybe instead of int, you should try byte or uint8_t for your device address. Can you verify that you are able to read the WHO_AM_I egister of your sensor. The A4/A5 on the Arduino breakout board use the I2C6 port, one of two I2C ports on the Edison. Do you have the proper pullups on the I2C lines? The Edison has internal pullups which might be interfering with you signal, but if you can see the trace, it sounds like your device address is wrong or messed up.

          • 2. Re: Edison Arduino i2c

            I can read the temp sensor's i2c address on my Arduino UNO using Nick Gammon's i2c Scanner sketch. It says it's hex 48 (decimal 72). But when I try to run the i2c Scanner sketch on my Edison-Arduino it doesn't do anything.  Uploads OK but no output.


            The only library it loads is wire.h just like the above sketch.  So I think the issue is in that library, which apparently has been specially modified for the Edison-Arduino.


            Standard wire.h has:


            #ifndef TwoWire_h
            #define TwoWire_h

            #include <inttypes.h>
            #include "Stream.h"

            #define BUFFER_LENGTH 32


            but Edison-Arduino wire.h has:


            #ifndef TwoWire_h
            #define TwoWire_h

            #include "Stream.h"
            #include "variant.h"

            #define BUFFER_LENGTH 32
            #define I2C2 0x4819c000
            #define I2C1 0x00000000
            #define WIRE_INTERFACES_COUNT 1


            So, I'm still puzzled by #define I2C2 0x4819c000 and how that translates to Bus ID 6.


            Frankly, I have found very few tried & true Arduino sketches that run on the Edison-Arduino, except for simple sketches that don't involve any IO.

            • 3. Re: Edison Arduino i2c

              Hi, I intend to post some code (but havn't yet)......


              I converted some Uno based code that I wrote that does the following;


              1. Talks to adafruit Ultimate GPS via Serial1 (Had to convert from software serial - #define ss Serial1 was enough (and don't init software serial :-)

              2. Talks to an I2c 16/2 LCD display

              3. Backlight control of display is controlled by a pot.

              4. Reads a (nicely debounced if I say so myself) button to change what gets displayed on LCD.

              5. For GPS decode uses TinyGPS - and I stole his smartdelay function from his examples. (http://arduiniana.org/libraries/tinygps/)


              On the whole it went pretty well - It was a 2-stage conversion because on my UNO I was using the adafuit libraries - so converted to Edison plus tinyGPS!


              I am still validating the code - currently my edison is playing up - segfault - but ran out of diagnosis time.


              It did prove the LCD via I2c is working fine - and the routines to pull data from the GPS are working fine.


              So FWIW, the conversion from UNO to Edison went fairly well - took me about an hour.



              • 4. Re: Edison Arduino i2c

                Spoke too soon - just about to make new post on issues with the code - signature points to I2c


                Reason edison was 'playing up' was because / was full of journals - have reconfigured journal to put journals in volatile so problem sort of gone away (Understand new yocto image coming soon to properly fix issue).


                Journals were created (I believe) by the sketch which cause a lot of i2c issues - (and I moved from Due to Edison because of the issues with i2c on the Due :-(   )


                Incidently - having looked at the edison wire.cpp code I am puzzled - the wire.begin seems to ignore any slave address given- can anyone confirm that the current wire implementation in edison is master (no address) mode only? (or have I lost the ability to read code?) - or is the design of the wire implementation to be master with GC for out of band transmissions to the edison master?



                • 5. Re: Edison Arduino i2c

                  When I hooked up an MPU9150 sensor breakout board to the Edison/Arduino breakout board using A4/A5 for SDA/SCL, 3V3 power and GND, I was able to run an Arduino sketch written and working for the 3V3 8 MHz Arduino Pro Mini without modification. The Edison/Arduino breakout board should behave just like an Arduino UNO if you are using the Edison Arduino IDE.

                  • 6. Re: Edison Arduino i2c

                    onehorse - I don't have a MPU9150 but was wondering if you could try the following Arduino sketch?  It's something I use to confirm i2c addresses. It works fine on my UNO's but not on my Edison-Arduino breakout board.  I would really appreciate hearing how it works for you, since you're having a lot more success than me.


                    // I2C Scanner

                    // Written by Nick Gammon

                    // Date: 20th April 2011


                    #include <Wire.h>


                    void setup() {

                      Serial.begin (115200);


                      // Leonardo: wait for serial port to connect

                      while (!Serial)




                      Serial.println ();

                      Serial.println ("I2C scanner. Scanning ...");

                      byte count = 0;



                      for (byte i = 8; i < 120; i++)


                        Wire.beginTransmission (i);

                        if (Wire.endTransmission () == 0)


                          Serial.print ("Found address: ");

                          Serial.print (i, DEC);

                          Serial.print (" (0x");

                          Serial.print (i, HEX);

                          Serial.println (")");


                          delay (1);  // maybe unneeded?

                          } // end of good response

                      } // end of for loop

                      Serial.println ("Done.");

                      Serial.print ("Found ");

                      Serial.print (count, DEC);

                      Serial.println (" device(s).");

                    }  // end of setup


                    void loop() {}

                    • 7. Re: Edison Arduino i2c

                      I will try it this weekend when I recover my Edison and Arduino breakout board from another work site.


                      In the mean time, here is an I2C scanner I have been using with success, but I haven't tried it on the Edison lately. See if it gives you any different result.


                      // scan for i2c devices
                        byte error, address;
                        int nDevices;
                        nDevices = 0;
                        for(address = 1; address < 127; address++ )
                          // The i2c_scanner uses the return value of
                          // the Write.endTransmisstion to see if
                          // a device did acknowledge to the address.
                          error = Wire.endTransmission();
                          if (error == 0)
                            Serial.print("I2C device found at address 0x");
                            if (address<16)
                            Serial.println("  !");
                          else if (error==4)
                            Serial.print("Unknow error at address 0x");
                            if (address<16)
                        if (nDevices == 0)
                          Serial.println("No I2C devices found\n");
                      • 8. Re: Edison Arduino i2c

                        Just to make sure, you are using the Edison-specific Arduino IDE with the Edison-specific Wire.h library, aren't you?

                        • 9. Re: Edison Arduino i2c

                          Hey, thanks! Yes, I am definitely using the modified Arduino IDE from Intel's downloads on the Edison and its built-in Wire.h library.


                          I tried two different i2c devices with your program on my Edison-Arduino breakout board and only get "scanning, no i2c devices found".  So then I tried your program on my UNO and it shows the i2c addresses just fine.  Of course, it's using its own unmodified Wire.h library.


                          One thing I haven't done is try pullup resistors on SDA and SCL, although the devices I tried are supposed to have their own pullups and do work OK on an UNO.

                          • 10. Re: Edison Arduino i2c

                            I tried adding 10K pullup resistors to SDA and SCL but it made no difference - still no i2c devices found. I went with 10K instead of say 4.7K, because my devices are supposed to already have pullups built-in to them.


                            I'm still puzzled over this issue of BUS ID 6.  How does one do that in an Arduino sketch? Or is that more likely part of the Wire.h library?  And if so, where?  Has the modified Wire.h library for the Edison-Arduino magically handled the change to BUS ID 6 somewhere in not so obvious code?

                            • 11. Re: Edison Arduino i2c

                              Yes, it's magic! Or software...


                              In the Edison Arduino library they made a default choice to assign I2C6 (SDA/SCL) to A4/A5 on the Arduino breakout board. This should make it work like any other Arduino UNO. The GY-80 already has pullup resistors so that is not your problem. Of course, I don't know what is 'cause it should work!


                              On the adapter board we made I wired up SDA/SCL inadvertently to I2C1 (who would have though 6 would be default, 1 comes before 6!) before I had the Arduino or Mini breakout board schematics. We had to change the default to I2C1 which was straightforward to do in the Wire library. But you should not need to do this.


                              I will try again this weekend with the latest Edison Arduino IDE and the Arduino breakout board and see if it still works like it did before. I'll let you know what I find.

                              • 12. Re: Edison Arduino i2c

                                Since I couldn't get any of my i2c LCD displays working on the Edison-Arduino, the other day I ordered a Grove (i2c) RGB-LCD. It arrived this afternoon, and while it works just fine using JavaScript (node.js) on the Edison-Arduino, it behaves the same as all my other i2c devices trying to use it through the Arduino IDE - "no i2c devices found".  In any case, this proves my connections, hardware and pullups are OK.


                                But here is another mystery - I keep reading about needing to use BUS ID 6 on the Edison instead of 0 like the Galileo uses.  But this JavaScript is using 0 NOT 6 and it works. In fact, it works no matter what BUS ID I use.  Maybe something was changed in the mraa/upm libraries after all the posting about BUS ID's.


                                //Load i2clcd module

                                var LCD = require('jsupm_i2clcd');

                                //Initialize Jhd1313m1 at 0x62 (RGB_ADDRESS) and 0x3E (LCD_ADDRESS)

                                var myLcd = new LCD.Jhd1313m1 (0, 0x3E, 0x62); // BUS ID = 0


                                myLcd.write('Hello World'); 

                                • 13. Re: Edison Arduino i2c

                                  Hi toadaze;


                                  Have you been able to use I2C and LCD displays with your IDE?




                                  • 14. Re: Edison Arduino i2c



                                    I am trying to configure Intel Edison breakout board with Adafruit Ultimate GPS to track the live location of the device.


                                    I tried some code but it was giving an error regarding Software Serial

                                    I am a complete beginner and hoping some help from your side


                                    Can you please explain how to solve SoftwareSerial issue?


                                    Connections between Edison break out board and Adafruit GPS Ultimate:


                                    Vin J20- pin 2 System 3.3V Output

                                    GND J19- pin 3 GND

                                    Rx J20- pin 4 GP45

                                    Tx J20- pin 5 GP47


                                    Are these connections fine for tracking the live location?


                                    Thanks in advance

                                    1 2 Previous Next