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
    About the element14 Community
  • 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 arduino  DUE and SRF10
  • 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 9 replies
  • Subscribers 417 subscribers
  • Views 1096 views
  • Users 0 members are here
  • arduino
Related

arduino  DUE and SRF10

e14 Contributor
e14 Contributor over 13 years ago

i am trying to configure ARDUINO DUE and SRF10 ultrasonic sensor. i have my code ready but while running the code i am getting the error below. 

assertion "(address & 0x80) == 0" failed: file "../source/twi.c", line 261, function: TWI_StartWrite

Exiting with status 1

 

 

 

 

 

 

 

 

 

 

#include <Wire.h>

 

 

 

 

void setup()

{

  Serial.begin(9600);

  Serial.println("SFR10 test application");

  Wire.begin();                // join i2c bus (address optional for master)

  Serial.println("i2c initialized");

 

 

}

 

 

#define SFR10_ADDRESS 0xE0

 

 

int getDistance(void) {

  // 1. start measurement

  // write to command register (0x00) of SRF10

  Wire.beginTransmission(SFR10_ADDRESS); // transmit to device #112 (0x70)

                               // the address specified in the datasheet is 224 (0xE0)

                               // but i2c adressing uses the high 7 bits so it's 112

  Wire.write(byte(0x00));      // sets register pointer to the command register (0x00) 

  Wire.write(byte(0x51));      // command sensor to measure in "inches" (0x50)

                               // use 0x51 for centimeters

                               // use 0x52 for ping microseconds

  Wire.endTransmission();      // stop transmitting

 

 

 

 

  // 2. wait until measurement is finished

   delay(70);                   // datasheet suggests at least 65 milliseconds

 

 

 

  // 3. read the value

 

  Wire.beginTransmission(SFR10_ADDRESS); // transmit to device #112

  Wire.write(byte(0x02));      // sets register pointer to echo #1 register (0x02)

  Wire.endTransmission();      // stop transmitting

 

 

  Wire.requestFrom(SFR10_ADDRESS, 2);    // request 2 bytes from slave device #112

 

 

  

  // (4.) make a conversion cm

  // already done

 

 

  // 5. return the value in cm

  int reading;

 

  if(2 <= Wire.available())    // if two bytes were received

  {

    reading = Wire.read();  // receive high byte (overwrites previous reading)

    reading = reading << 8;    // shift high byte to be high 8 bits

    reading |= Wire.read(); // receive low byte as lower 8 bits

   

  }

 

 

  return reading;

 

 

}

 

 

void loop()

{

  int distance;

 

  distance=getDistance();

  Serial.println(distance);   // print the reading

 

  delay(200);

  

}

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

    I think from the assertion, it doesn't like that you're using an 8-bit address.

    See here:

    #define SFR10_ADDRESS 0xE0

     

    I think you need to right-shift by 1 bit position (i.e. have a 7-bit address, not an 8-bit address),

    i.e.make it 0x70. It looks from the comments that you're aware of this, but maybe forgot to modify it in the #define statement.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
Reply
  • shabaz
    shabaz over 13 years ago

    I think from the assertion, it doesn't like that you're using an 8-bit address.

    See here:

    #define SFR10_ADDRESS 0xE0

     

    I think you need to right-shift by 1 bit position (i.e. have a 7-bit address, not an 8-bit address),

    i.e.make it 0x70. It looks from the comments that you're aware of this, but maybe forgot to modify it in the #define statement.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
Children
  • e14 Contributor
    e14 Contributor over 13 years ago in reply to shabaz

    but still i am not getting the output..image

    i can transmitt the signal but i am not able to receive the output

    it shows 0cm only

    please help me

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • shabaz
    shabaz over 13 years ago in reply to e14 Contributor

    I've never used an SFR 10, so unfortunately I can't see anything obvious.You may wish to double-check your code matches the datasheet requirements, or see if there is any reference code from the manufacturer you can use.

    • 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 © 2026 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.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube