Hi,
I try to build a small sensor interface to connect to a GSM module. The TC65 has an external I2C interface. I connected my LilyPad to the I2C connector of the TC65 and encounter some strange responses from the LilyPad.
To verify that my programming does not cause the problem I bought a I2C temperature sensor and connected it to the TC65. The sensor delivers 6 byte of data on a read request. I tested the Sensor with the TC65 and got:
37 8F 39 72 37 8F
After this I implemented a small program that should send the same bytes from the LilyPad to the TC65:
#include <Wire.h>
#define LED_PIN 13
#define SENSOR_ADDRESS 120
byte data[6] = {0x37, 0x8F, 0x39, 0x72, 0x37, 0x8F};
boolean requestPending=false;
void setup() {
// Small Light show to be sure the software is running
pinMode(LED_PIN, OUTPUT);
digitalWrite(LED_PIN, HIGH);
delay(1000);
digitalWrite(LED_PIN, LOW);
delay(100);
digitalWrite(LED_PIN, HIGH);
delay(1000);
digitalWrite(LED_PIN, LOW);
Wire.begin(SENSOR_ADDRESS);
Wire.onRequest(requestEvent);
}
void loop() {
delay(100);
}
void requestEvent(){
Wire.send(data, 6);
}
I started the request with 100kbps I2C baudrate and got:
37 63
I adjusted the baudrate to 400kbps (on the TC65) and got:
37 0F 8F F0 39 00 72 00 37 0F
The black numbers are my data and the red numbers are ... ?
Maybe someone can answer the questions I have.
I thought the default i2c baudrate on the LilyPad is 100kbps is this right ?
Does anyone has an idea what could cause such a problem ? (common GND and PullUps are installed)
Any tips on what to test or to do to investigate the problem ?
Thanks in advance !
Ciao
Matsimoto