element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • About Us
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Arduino
  • Products
  • More
Arduino
Arduino Forum Learning to find I2C addresses of sensors for Arduino Due
  • Blog
  • Forum
  • Documents
  • Quiz
  • Events
  • Polls
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join Arduino to participate - click to join for free!
Actions
  • Share
  • More
  • Cancel
Forum Thread Details
  • State Suggested Answer
  • Replies 16 replies
  • Answers 2 answers
  • Subscribers 395 subscribers
  • Views 2495 views
  • Users 0 members are here
Related

Learning to find I2C addresses of sensors for Arduino Due

rahimmuh3
rahimmuh3 over 9 years ago

Hi! My name is Rahim M. and I am a full time Mechanical Engineering student at South Mountain Community College.

 

I am currently taking a Engineering Special Projects class involving ANSR and ASCEND for a weather balloon experiment.

 

My classmates and myself have chosen to use the Arduino Due microprocessor for our project because of its immense power and versatility as a processor, but just about everyone on our team is ignorant to the knowledge of how to program with Arduino, especially with I2C addresses.

 

If anyone out there can give us advice on how to begin finding and programming with I2C addresses for our Arduino Due, it would be very much appreciated.

 

I understand that finding I2C addresses is a rather complicated task, especially for beginners, but we really need the knowledge of how to do this in a simple manner as soon as possible.

 

I look forward to hearing from everyone!!!

 

Thank you.

 

Rahim M.

  • Sign in to reply
  • Cancel

Top Replies

  • Former Member
    Former Member over 9 years ago +2 suggested
    Rahim; There are a couple of excellent tutorials on tronixstuff.com specifically about using I2C and Arduino. It looks like you've already been to Adafruit, so no need to mention that. http://tronixstuff…
  • Robert Peter Oakes
    Robert Peter Oakes over 9 years ago +2
    Here are a bunch of Videos and Posts I have produced in the past that also use / describe I2C The Modular Bench Power Supply ++, Arduino UNO and precision ADC, DAC + MDO3000 I2C debugging Fuel Tank BoosterPack…
  • Former Member
    Former Member over 9 years ago +1
    In order to program the Arduino Due microprocessor you have to have Arduino IDE 1.5 or later which can be found here: https://www.arduino.cc/en/Main/Software#toc3 After installing Arduino 1.5 or later…
Parents
  • Former Member
    0 Former Member over 9 years ago

    Rahim;

     

    There are a couple of excellent tutorials on tronixstuff.com specifically about using I2C and Arduino.  It looks like you've already been to Adafruit, so no need to mention that.

    http://tronixstuff.com/2010/10/20/tutorial-arduino-and-the-i2c-bus/

     

    Here is a more general one on SparkFun: https://learn.sparkfun.com/tutorials/i2c

     

    And the I2C/Wire library reference on the Arduino site: https://www.arduino.cc/en/Reference/Wire

     

    When you're reading, the "Two-Wire" or "TWI" protocol is I2C.  Some refer to it as Two-Wire, understandably, as connections just require two wires: SDA (Data) and SCL (Clock).  A couple of gotcha's that you may or may not be aware of.  The Due is a 3V3 uC, unlike most Arduinos, which are 5VDC.  You'll need to reference (Include) the "Wire" library in your programming.  If you're using an IDE besides Arduino (Keil, Atmel Studio, etc.) then check Atmel's website for additional libraries required.

     

    Arduino pins can sink 20mA of sustained current, or 40mA max.  Not a problem using I2C, but if you use other pins be aware of those limitations. 

     

    Use a 9-12VDC/2A power source on the DC jack, when not using the USB port for power.  Any lower voltage and your uC may destabilize.  Much higher and the on-board voltage regulator will get too hot.  You can't really attach a heatsink as the VR is flush-mounted on the PCB.

     

    Best of luck!

    • Cancel
    • Vote Up +2 Vote Down
    • Sign in to reply
    • Verify Answer
    • Reject Answer
    • Cancel
  • rahimmuh3
    0 rahimmuh3 over 9 years ago in reply to Former Member

    Thank you Brian Edwards!!! The link to tronixstuff is really putting things into a better prospective. Right now our team is doing its best to set up code to get the I2C sensors to Read and Write to the Arduino Due one at a time, but we are running into some issues that are holding us back from even getting one sensor to work. We know that there is a issue with the code, but we can not seem to pen-point what the issue is exactly.


    So far, here is the code that we put together in bits and pieces down bellow...If you or someone else can help figure out what's wrong with the code it would be very much appreciated.


    Thanks again.


    Rahim M.



    #include <Wire.h>

     

     

    void setup()

    {

       Serial.begin(57600);

       Wire.begin();

    }

     

     

    #define MPL3115A2_ADDRESS 0x60

     

     

    void loop()

    {

       Serial.println(IIC_Read(0x0C));

    }

    z

    byte IIC_Read(byte regAddr)

    {

      // This function reads one byte over IIC

      Wire.beginTransmission(MPL3115A2_ADDRESS);

      Wire.write(regAddr);  // Address of CTRL_REG1

      Wire.endTransmission(false); // Send data to I2C dev with option for a repeated start. THIS IS NECESSARY and not supported before Arduino V1.0.1!

      Wire.requestFrom(MPL3115A2_ADDRESS, 1); // Request the data...

      return Wire.read();

    }

     

     

    uint8_t I2CReadRegister(uint8_t I2CDestinationAddress, uint8_t Register)

    {

       Wire.beginTransmission(I2CDestinationAddress);

       Wire.write(Register);

       Wire.endTransmission(false);

       Wire.requestFrom(I2CDestinationAddress, 1 );

      

       delay(200);

      

       return Wire.read();

    }

     

     

    void I2CWriteRegister(uint8_t I2CDestinationAddress, uint8_t Register, uint8_t Data)

    {

       Wire.beginTransmission(I2CDestinationAddress);

       Wire.write(Register);

       Wire.write(Data);

       Wire.endTransmission();

    }

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • Former Member
    0 Former Member over 9 years ago in reply to rahimmuh3

    You're welcome Rahim.

     

    First question/observation - In your code what is 'z' in your loop?

     

    void loop()

    {

       Serial.println(IIC_Read(0x0C));

    }

    z      // What is this referencing?

    byte IIC_Read(byte regAddr)

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
Reply
  • Former Member
    0 Former Member over 9 years ago in reply to rahimmuh3

    You're welcome Rahim.

     

    First question/observation - In your code what is 'z' in your loop?

     

    void loop()

    {

       Serial.println(IIC_Read(0x0C));

    }

    z      // What is this referencing?

    byte IIC_Read(byte regAddr)

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
Children
No Data
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube