element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • 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 & Tria Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • About Us
  • 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
      • Japan
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Vietnam
      • 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 I2C does not send all data
  • 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
  • Replies 3 replies
  • Subscribers 401 subscribers
  • Views 325 views
  • Users 0 members are here
  • i2c
Related

I2C does not send all data

Former Member
Former Member over 12 years ago

I am using a Arduino Nano Rev 3.1 with Arduino.exe 1.0.4 with a I2C LED control chip

I need to send the chip address, a LED address and 2 bytes of data.  I found the Wire.h library and a bunch of web pages and tutorials but I can’t make it work. I am beginning to wonder if the Nano I am using is damaged.

The reference  for Wire.h indicate there will be pull ups on the clock and data, but I did not have them and added resistors.

The reference for Wire.h indicates it will append a 1 as the most significant address bit on the address, my first address bit is always a zero even if I set the address to 0x80.

My sketch sends the address and 3 data bytes.  All I see on the scope is an address byte without the MSB set, my control byte, the first byte of data, then end of message.

I am looking for any advice, is it software, is it a damaged Nano.

 

/******************************************************

Arduino Nano I2C test

5/4/2013

*******************************************************/

// Arduino Nano A4 is I2C SDA

// Arduino Nano A5 is I2C SCL

//Nano is a rev 3.1 Arduino.exe is 1.0.4

#include "Wire.h"

 

void setup()             // run once, when the sketch starts

{

  Wire.begin();          //start wire library for I2C

  delay(20);

}

 

void loop(void)

{

int i=0, j=0, k=0;

digitalWrite(2, LOW);   // chip enable

 

while(1)

    {

    SendLED();

    delay(5);

   }

}

 

void SendLED(void)

{

  1. Wire.beginTransmission(0);    //chip address
  2. Wire.write(3);                //send LED address
  3. Wire.write(15);               //send low data byte
  4. Wire.write(63);               //send hi data byte
  5. Wire.endTransmission();       //end command

}

  • Sign in to reply
  • Cancel
Parents
  • shabaz
    shabaz over 12 years ago

    Hi David,

     

    I didn't read the entire code, but the first key thing is that the address is not correct. As I understand, the documentation says that it expects a 7-bit address (which it will left-shift by one bit position, and then the LSB controls the read/write operation).

    Setting it to 0x80 is not good, because the left-shift operation will make it become zero.

    If your LED driver is expecting address 0x80, then the value to use is 0x40; it will get left-shifted to become 0x80.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • Former Member
    Former Member over 12 years ago in reply to shabaz

    Thank you shabaz for the tip about the address getting shifted.

    I entered 0x40  for the address and the address showed up on the data but I was still not getting all 4 bytes showing up on the data lines.  I reviewed the instructions for the salve device and found that address 0x40 was a reset command.  I changed the address to 0x41 and moved A1 on the chip to be a high and I got 4 bytes of I2C data and the chip worked as expected.

    Thanks David

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
Reply
  • Former Member
    Former Member over 12 years ago in reply to shabaz

    Thank you shabaz for the tip about the address getting shifted.

    I entered 0x40  for the address and the address showed up on the data but I was still not getting all 4 bytes showing up on the data lines.  I reviewed the instructions for the salve device and found that address 0x40 was a reset command.  I changed the address to 0x41 and moved A1 on the chip to be a high and I got 4 bytes of I2C data and the chip worked as expected.

    Thanks David

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
Children
  • shabaz
    shabaz over 12 years ago in reply to Former Member

    Excellent, glad it works!

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
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