it has address 0xB8(dec-184) > 127
trying with the following code, every string printed is zero…
#include <Wire.h>
#define I2CADDR 0xb8
#define READCMD 0x03
#define REGSTADDR 0x00
#define REGCOUNT 4
#define REGADDR 0x0B
void setup() {
Wire.begin(); // wake up I2C bus
Serial.begin(9600);
}
void loop() {
byte buf[10];
//
// Read Command
//
Wire.beginTransmission(I2CADDR);
Wire.write(READCMD);
Wire.write(REGSTADDR);
Wire.write(REGCOUNT);
Wire.endTransmission();
//
// Waiting
//
delay(2); //>1.5ms
//
// Read
//
Wire.requestFrom(I2CADDR, 2 + REGCOUNT + 2); // COMMAND + DATA + REGCOUNT + CRCLSB + CRCMSB
int i = 0;
for (; i < 2 + REGCOUNT + 2; i++)
buf[i] = Wire.read();
for (i=0; i < 2 + REGCOUNT + 2; i++)
Serial.println(buf[i]);
delay(3000);
}
Other then that, I don’t see where it is failing since I don’t have such module to try it out.
Do you have proper PullUps resistors on the bus ?
Other then that, I don’t see where it is failing since I don’t have such module to try it out.
Do you have proper PullUps resistors on the bus ?
it has address 0xB8(dec-184) > 127
I2C_Write(AM2320_address + I2C_write_cmd);
Other then that, I don’t see where it is failing since I don’t have such module to try it out.
Do you have proper PullUps resistors on the bus ?
Default speed on the STM32 is set to 250kbps instead of 100kbps on AVR.
However most modules operate up to 400kpbs, so this is not normally an issue, but its something to bear in mind.
Default speed on the STM32 is set to 250kbps instead of 100kbps on AVR.
However most modules operate up to 400kpbs, so this is not normally an issue, but its something to bear in mind.
Go into /STM32F1/libraries/wire.cpp and at the bottom change
TwoWire Wire(PB6, PB7, SOFT_FAST);
Go into /STM32F1/libraries/wire.cpp and at the bottom change
TwoWire Wire(PB6, PB7, SOFT_FAST);
I think this is a major omission now that new boards are capable of higher speeds and some devices e.g. Accelermoeters benefit if you can read their data as fast as possible.
As I excpet some libraries may have hard coded references to Wire in them, it would make sense to add a new function to Wire of setSpeed(int speedInKHz)
Or possibly add an optional argument to Wire.begin(int address, int speedInKHz)
Do you have any other ideas ?
Or possibly add an optional argument to Wire.begin(int address, int speedInKHz)

