Pages: [1]   Go Down
Author Topic: Problems with Wire.endTransmission()  (Read 1006 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Newbie
*
Karma: 0
Posts: 1
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi everybody!
I'd like to read measurements form a digital accelerometer (ADXL345) that implements I2C with Arduino Mega, but I have some problems with the Wire library. Exactly, the "Wire.endTransmission()" command stops the program! I tried my code in another computer and it works properly, but in mine there's nothing to do. To explain better my problem, I'll post here an example code and the output it produces:

CODE:

#include <Wire.h>

void setup() {
Wire.begin();
Serial.begin(9600);
}

void loop() {
Wire.beginTransmission(0x53);
Serial.print("step 1\n");
Wire.endTransmission();
Serial.print("step 2");
Serial.print("\n");
delay(500);
}

OUTPUT:

step1

What should I do to fix this problem?
Thanks to everybody,
Biagio
Logged

0
Offline Offline
Full Member
***
Karma: 1
Posts: 225
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The code works for me (at least on a 328);  I get "step 1" and "step 2" printed on the serial monitor ad infinitum.  This is with nothing connected though.

« Last Edit: October 12, 2009, 07:34:19 pm by lefstin » Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 1
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi,
I using the Arduino Mega and ADXL345 too. I find the same problem. I checked step by step program. It's alway stop at "Wire.endTransmission()" command. I don't know why.
So How can I to fix it. Please help.

thank for everyone helping.
Ping
Logged

Wuppertal/Germany
Offline Offline
God Member
*****
Karma: 1
Posts: 895
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi,
Quote
I tried my code in another computer and it works properly
How are your two machines different ?
Operating  System?

Eberhard
Logged

Wuppertal/Germany
Offline Offline
God Member
*****
Karma: 1
Posts: 895
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

@biagio
You know that your code does not send any data to the device?
You have to send some register-data to the ADXL.
This is not a valid command for the device.  
Code:
Wire.beginTransmission(0x53);
Serial.print("step 1\n");
Wire.endTransmission();
Eberhard
Logged

0
Offline Offline
Sr. Member
****
Karma: 0
Posts: 269
Fzzt! pop Bang!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Something similar to this cropped up ages ago but it is so old it must have gone by now. http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1175112203
Logged

Pages: [1]   Go Up
Jump to: