attiny icon indicating copy to clipboard operation
attiny copied to clipboard

I2C not working corretly on ATTiny85 clone

Open bill-orange opened this issue 4 years ago • 0 comments

I am using the Arduino 1.8.9 IDE on a ATTiny85 clone.

I can compile properly. I can serial print to NotePad using keyboard.h. I can blink LEDs successfully.

What I can not do is successfully implement I2C. I do not know how to troubleshoot the problem.

If I use I2C scanner, the device is detected but I get back address 0x40 for a BME280. Clearly this is wrong. The address is 0x76.

If I try reading the BME280 (at any address), I get decimal 12378. Something is definitely wrong. I am very familiar with the ESP8266 family but I am too new with this device to work toward a solution by myself.

#include <Wire.h>
#include <DigiKeyboard.h>
#include <TinyBME280.h>

// ATtiny85 Pins
int const sda = PB0;
int const scl = PB2;

void setup()
{
  Wire.begin();  
  BME280setI2Caddress(0x40);
  //BME280setI2Caddress(0x76);
  BME280setup();

  DigiKeyboard.delay(3000);
}

void loop()
{
int32_t tempc;  
  tempc = BME280temperature();
  DigiKeyboard.print("temp: "); DigiKeyboard.println(tempc);

  DigiKeyboard.delay(5000);           // wait 5 seconds for next scan
}

Thoughts? Suggestion? How do I troubleshoot this?

bill-orange avatar Dec 15 '19 16:12 bill-orange