HB1750 et attiny85

Bonjour, je voudrais savoir si je peux faire fonctionné un module HB1750 en I2C sur un attiny85 ?

J'ai testé sur un arduino nano est fonctionne mais j'ai des erreurs quand je passe le code sur attiny85.

#include <Wire.h>
#include <BH1750.h>

BH1750 lightMeter;

int mouvement = 2;
int relais = 3;

void setup()
{
  //Serial.begin(9600);
  Wire.begin();
  lightMeter.begin(BH1750::CONTINUOUS_LOW_RES_MODE);
  pinMode(mouvement, INPUT_PULLUP);
  pinMode(relais, OUTPUT);
  digitalWrite(relais, HIGH);
}

void loop()
{
  int etat_mouvement = digitalRead(mouvement);
  //Serial.print("Mouvement détecter: ");
  //Serial.println(etat_mouvement)

  float lux = lightMeter.readLightLevel();
  //Serial.print("Light: ");
  //Serial.print(lux);
  //Serial.println(" lx");
  //delay(1000);  
  
  if(etat_mouvement == 1 && lux > 700) {digitalWrite(relais, LOW);} else {digitalWrite(relais, HIGH);}
}

BH1750?

Bonjour,

C'est quoi ces erreurs?
Tu utilises quel core pour les attiny?
Sur quelles pins est connecté le BH1750?

Pour les erreurs:

Arduino : 1.8.19 (Windows 10), Carte : "ATtiny25/45/85, ATtiny85, Internal 8 MHz"

C:\Users\steph\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.5\libraries\Wire\src\utility\twi.c: In function 'twi_init':

C:\Users\steph\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.5\libraries\Wire\src\utility\twi.c:88:16: error: 'SDA' undeclared (first use in this function)

   digitalWrite(SDA, 1);

                ^~~

C:\Users\steph\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.5\libraries\Wire\src\utility\twi.c:88:16: note: each undeclared identifier is reported only once for each function it appears in

C:\Users\steph\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.5\libraries\Wire\src\utility\twi.c:89:16: error: 'SCL' undeclared (first use in this function); did you mean 'SPL'?

   digitalWrite(SCL, 1);

                ^~~

                SPL

In file included from c:\users\steph\appdata\local\arduino15\packages\arduino\tools\avr-gcc\7.3.0-atmel3.6.1-arduino7\avr\include\avr\io.h:99:0,

                 from C:\Users\steph\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.5\libraries\Wire\src\utility\twi.c:26:

C:\Users\steph\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.5\libraries\Wire\src\utility\twi.c:92:7: error: 'TWSR' undeclared (first use in this function); did you mean 'ACSR'?

   cbi(TWSR, TWPS0);

       ^

C:\Users\steph\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.5\libraries\Wire\src\utility\twi.c:92:3: note: in expansion of macro 'cbi'

   cbi(TWSR, TWPS0);

   ^~~

C:\Users\steph\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.5\libraries\Wire\src\utility\twi.c:92:13: error: 'TWPS0' undeclared (first use in this function); did you mean 'TWSR'?

   cbi(TWSR, TWPS0);

             ^

C:\Users\steph\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.5\libraries\Wire\src\utility\twi.c:92:3: note: in expansion of macro 'cbi'

   cbi(TWSR, TWPS0);

   ^~~

C:\Users\steph\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.5\libraries\Wire\src\utility\twi.c:93:13: error: 'TWPS1' undeclared (first use in this function); did you mean 'TWPS0'?

   cbi(TWSR, TWPS1);

             ^

C:\Users\steph\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.5\libraries\Wire\src\utility\twi.c:93:3: note: in expansion of macro 'cbi'

   cbi(TWSR, TWPS1);

   ^~~

C:\Users\steph\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.5\libraries\Wire\src\utility\twi.c:94:3: error: 'TWBR' undeclared (first use in this function); did you mean 'TWSR'?

   TWBR = ((F_CPU / TWI_FREQ) - 16) / 2;

   ^~~~

   TWSR

C:\Users\steph\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.5\libraries\Wire\src\utility\twi.c:102:3: error: 'TWCR' undeclared (first use in this function); did you mean 'TWBR'?

   TWCR = _BV(TWEN) | _BV(TWIE) | _BV(TWEA);

   ^~~~

   TWBR

In file included from c:\users\steph\appdata\local\arduino15\packages\arduino\tools\avr-gcc\7.3.0-atmel3.6.1-arduino7\avr\include\avr\io.h:99:0,

                 from C:\Users\steph\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.5\libraries\Wire\src\utility\twi.c:26:

C:\Users\steph\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.5\libraries\Wire\src\utility\twi.c:102:14: error: 'TWEN' undeclared (first use in this function); did you mean 'TWCR'?

   TWCR = _BV(TWEN) | _BV(TWIE) | _BV(TWEA);

              ^

C:\Users\steph\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.5\libraries\Wire\src\utility\twi.c:102:26: error: 'TWIE' undeclared (first use in this function); did you mean 'TWEN'?

   TWCR = _BV(TWEN) | _BV(TWIE) | _BV(TWEA);

                          ^

C:\Users\steph\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.5\libraries\Wire\src\utility\twi.c:102:38: error: 'TWEA' undeclared (first use in this function); did you mean 'TWEN'?

   TWCR = _BV(TWEN) | _BV(TWIE) | _BV(TWEA);

                                      ^

C:\Users\steph\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.5\libraries\Wire\src\utility\twi.c: In function 'twi_disable':

C:\Users\steph\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.5\libraries\Wire\src\utility\twi.c:114:3: error: 'TWCR' undeclared (first use in this function); did you mean 'EECR'?

   TWCR &= ~(_BV(TWEN) | _BV(TWIE) | _BV(TWEA));

   ^~~~

   EECR

In file included from c:\users\steph\appdata\local\arduino15\packages\arduino\tools\avr-gcc\7.3.0-atmel3.6.1-arduino7\avr\include\avr\io.h:99:0,

                 from C:\Users\steph\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.5\libraries\Wire\src\utility\twi.c:26:

C:\Users\steph\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.5\libraries\Wire\src\utility\twi.c:114:17: error: 'TWEN' undeclared (first use in this function); did you mean 'TWCR'?

   TWCR &= ~(_BV(TWEN) | _BV(TWIE) | _BV(TWEA));

                 ^

C:\Users\steph\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.5\libraries\Wire\src\utility\twi.c:114:29: error: 'TWIE' undeclared (first use in this function); did you mean 'TWEN'?

   TWCR &= ~(_BV(TWEN) | _BV(TWIE) | _BV(TWEA));

                             ^

C:\Users\steph\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.5\libraries\Wire\src\utility\twi.c:114:41: error: 'TWEA' undeclared (first use in this function); did you mean 'TWEN'?

   TWCR &= ~(_BV(TWEN) | _BV(TWIE) | _BV(TWEA));

                                         ^

C:\Users\steph\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.5\libraries\Wire\src\utility\twi.c:117:16: error: 'SDA' undeclared (first use in this function)

   digitalWrite(SDA, 0);

                ^~~

C:\Users\steph\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.5\libraries\Wire\src\utility\twi.c:118:16: error: 'SCL' undeclared (first use in this function); did you mean 'SPL'?

   digitalWrite(SCL, 0);

                ^~~

                SPL

C:\Users\steph\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.5\libraries\Wire\src\utility\twi.c: In function 'twi_setAddress':

C:\Users\steph\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.5\libraries\Wire\src\utility\twi.c:130:3: error: 'TWAR' undeclared (first use in this function); did you mean 'TIFR'?

   TWAR = address << 1;

   ^~~~

   TIFR

C:\Users\steph\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.5\libraries\Wire\src\utility\twi.c: In function 'twi_setFrequency':

C:\Users\steph\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.5\libraries\Wire\src\utility\twi.c:141:3: error: 'TWBR' undeclared (first use in this function); did you mean 'TIFR'?

   TWBR = ((F_CPU / frequency) - 16) / 2;

   ^~~~

   TIFR

C:\Users\steph\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.5\libraries\Wire\src\utility\twi.c: In function 'twi_readFrom':

C:\Users\steph\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.5\libraries\Wire\src\utility\twi.c:204:7: error: 'TWDR' undeclared (first use in this function); did you mean 'DWDR'?

       TWDR = twi_slarw;

       ^~~~

       DWDR

C:\Users\steph\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.5\libraries\Wire\src\utility\twi.c:209:13: error: 'TWCR' undeclared (first use in this function); did you mean 'TWDR'?

     } while(TWCR & _BV(TWWC));

             ^~~~

             TWDR

In file included from c:\users\steph\appdata\local\arduino15\packages\arduino\tools\avr-gcc\7.3.0-atmel3.6.1-arduino7\avr\include\avr\io.h:99:0,

                 from C:\Users\steph\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.5\libraries\Wire\src\utility\twi.c:26:

C:\Users\steph\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.5\libraries\Wire\src\utility\twi.c:209:24: error: 'TWWC' undeclared (first use in this function); did you mean 'TWCR'?

     } while(TWCR & _BV(TWWC));

                        ^

C:\Users\steph\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.5\libraries\Wire\src\utility\twi.c:210:16: error: 'TWINT' undeclared (first use in this function)

     TWCR = _BV(TWINT) | _BV(TWEA) | _BV(TWEN) | _BV(TWIE); // enable INTs, but not START

                ^

C:\Users\steph\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.5\libraries\Wire\src\utility\twi.c:210:29: error: 'TWEA' undeclared (first use in this function); did you mean 'TWWC'?

     TWCR = _BV(TWINT) | _BV(TWEA) | _BV(TWEN) | _BV(TWIE); // enable INTs, but not START

                             ^

C:\Users\steph\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.5\libraries\Wire\src\utility\twi.c:210:41: error: 'TWEN' undeclared (first use in this function); did you mean 'TWEA'?

     TWCR = _BV(TWINT) | _BV(TWEA) | _BV(TWEN) | _BV(TWIE); // enable INTs, but not START

                                         ^

C:\Users\steph\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.5\libraries\Wire\src\utility\twi.c:210:53: error: 'TWIE' undeclared (first use in this function); did you mean 'TWEN'?

     TWCR = _BV(TWINT) | _BV(TWEA) | _BV(TWEN) | _BV(TWIE); // enable INTs, but not START

                                                     ^

C:\Users\steph\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.5\libraries\Wire\src\utility\twi.c:213:65: error: 'TWSTA' undeclared (first use in this function); did you mean 'TWEA'?

     TWCR = _BV(TWEN) | _BV(TWIE) | _BV(TWEA) | _BV(TWINT) | _BV(TWSTA);

                                                                 ^

C:\Users\steph\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.5\libraries\Wire\src\utility\twi.c: In function 'twi_writeTo':

C:\Users\steph\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.5\libraries\Wire\src\utility\twi.c:301:7: error: 'TWDR' undeclared (first use in this function); did you mean 'DWDR'?

       TWDR = twi_slarw;

       ^~~~

       DWDR

C:\Users\steph\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.5\libraries\Wire\src\utility\twi.c:306:13: error: 'TWCR' undeclared (first use in this function); did you mean 'TWDR'?

     } while(TWCR & _BV(TWWC));

             ^~~~

             TWDR

In file included from c:\users\steph\appdata\local\arduino15\packages\arduino\tools\avr-gcc\7.3.0-atmel3.6.1-arduino7\avr\include\avr\io.h:99:0,

                 from C:\Users\steph\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.5\libraries\Wire\src\utility\twi.c:26:

C:\Users\steph\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.5\libraries\Wire\src\utility\twi.c:306:24: error: 'TWWC' undeclared (first use in this function); did you mean 'TWCR'?

     } while(TWCR & _BV(TWWC));

                        ^

C:\Users\steph\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.5\libraries\Wire\src\utility\twi.c:307:16: error: 'TWINT' undeclared (first use in this function)

     TWCR = _BV(TWINT) | _BV(TWEA) | _BV(TWEN) | _BV(TWIE); // enable INTs, but not START

                ^

C:\Users\steph\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.5\libraries\Wire\src\utility\twi.c:307:29: error: 'TWEA' undeclared (first use in this function); did you mean 'TWWC'?

     TWCR = _BV(TWINT) | _BV(TWEA) | _BV(TWEN) | _BV(TWIE); // enable INTs, but not START

                             ^

C:\Users\steph\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.5\libraries\Wire\src\utility\twi.c:307:41: error: 'TWEN' undeclared (first use in this function); did you mean 'TWEA'?

     TWCR = _BV(TWINT) | _BV(TWEA) | _BV(TWEN) | _BV(TWIE); // enable INTs, but not START

                                         ^

C:\Users\steph\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.5\libraries\Wire\src\utility\twi.c:307:53: error: 'TWIE' undeclared (first use in this function); did you mean 'TWEN'?

     TWCR = _BV(TWINT) | _BV(TWEA) | _BV(TWEN) | _BV(TWIE); // enable INTs, but not START

                                                     ^

C:\Users\steph\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.5\libraries\Wire\src\utility\twi.c:310:65: error: 'TWSTA' undeclared (first use in this function); did you mean 'TWEA'?

     TWCR = _BV(TWINT) | _BV(TWEA) | _BV(TWEN) | _BV(TWIE) | _BV(TWSTA); // enable INTs

                                                                 ^

C:\Users\steph\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.5\libraries\Wire\src\utility\twi.c: In function 'twi_reply':

C:\Users\steph\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.5\libraries\Wire\src\utility\twi.c:397:5: error: 'TWCR' undeclared (first use in this function); did you mean 'EECR'?

     TWCR = _BV(TWEN) | _BV(TWIE) | _BV(TWINT) | _BV(TWEA);

     ^~~~

     EECR

In file included from c:\users\steph\appdata\local\arduino15\packages\arduino\tools\avr-gcc\7.3.0-atmel3.6.1-arduino7\avr\include\avr\io.h:99:0,

                 from C:\Users\steph\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.5\libraries\Wire\src\utility\twi.c:26:

C:\Users\steph\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.5\libraries\Wire\src\utility\twi.c:397:16: error: 'TWEN' undeclared (first use in this function); did you mean 'TWCR'?

     TWCR = _BV(TWEN) | _BV(TWIE) | _BV(TWINT) | _BV(TWEA);

                ^

C:\Users\steph\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.5\libraries\Wire\src\utility\twi.c:397:28: error: 'TWIE' undeclared (first use in this function); did you mean 'TWEN'?

     TWCR = _BV(TWEN) | _BV(TWIE) | _BV(TWINT) | _BV(TWEA);

                            ^

C:\Users\steph\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.5\libraries\Wire\src\utility\twi.c:397:40: error: 'TWINT' undeclared (first use in this function); did you mean 'TWIE'?

     TWCR = _BV(TWEN) | _BV(TWIE) | _BV(TWINT) | _BV(TWEA);

                                        ^

C:\Users\steph\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.5\libraries\Wire\src\utility\twi.c:397:53: error: 'TWEA' undeclared (first use in this function); did you mean 'TWEN'?

     TWCR = _BV(TWEN) | _BV(TWIE) | _BV(TWINT) | _BV(TWEA);

                                                     ^

C:\Users\steph\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.5\libraries\Wire\src\utility\twi.c: In function 'twi_stop':

C:\Users\steph\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.5\libraries\Wire\src\utility\twi.c:412:3: error: 'TWCR' undeclared (first use in this function); did you mean 'EECR'?

   TWCR = _BV(TWEN) | _BV(TWIE) | _BV(TWEA) | _BV(TWINT) | _BV(TWSTO);

   ^~~~

   EECR

In file included from c:\users\steph\appdata\local\arduino15\packages\arduino\tools\avr-gcc\7.3.0-atmel3.6.1-arduino7\avr\include\avr\io.h:99:0,

                 from C:\Users\steph\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.5\libraries\Wire\src\utility\twi.c:26:

C:\Users\steph\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.5\libraries\Wire\src\utility\twi.c:412:14: error: 'TWEN' undeclared (first use in this function); did you mean 'TWCR'?

   TWCR = _BV(TWEN) | _BV(TWIE) | _BV(TWEA) | _BV(TWINT) | _BV(TWSTO);

              ^

C:\Users\steph\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.5\libraries\Wire\src\utility\twi.c:412:26: error: 'TWIE' undeclared (first use in this function); did you mean 'TWEN'?

   TWCR = _BV(TWEN) | _BV(TWIE) | _BV(TWEA) | _BV(TWINT) | _BV(TWSTO);

                          ^

C:\Users\steph\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.5\libraries\Wire\src\utility\twi.c:412:38: error: 'TWEA' undeclared (first use in this function); did you mean 'TWEN'?

   TWCR = _BV(TWEN) | _BV(TWIE) | _BV(TWEA) | _BV(TWINT) | _BV(TWSTO);

                                      ^

C:\Users\steph\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.5\libraries\Wire\src\utility\twi.c:412:50: error: 'TWINT' undeclared (first use in this function); did you mean 'TWIE'?

   TWCR = _BV(TWEN) | _BV(TWIE) | _BV(TWEA) | _BV(TWINT) | _BV(TWSTO);

                                                  ^

C:\Users\steph\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.5\libraries\Wire\src\utility\twi.c:412:63: error: 'TWSTO' undeclared (first use in this function)

   TWCR = _BV(TWEN) | _BV(TWIE) | _BV(TWEA) | _BV(TWINT) | _BV(TWSTO);

                                                               ^

C:\Users\steph\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.5\libraries\Wire\src\utility\twi.c: In function 'twi_releaseBus':

C:\Users\steph\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.5\libraries\Wire\src\utility\twi.c:444:3: error: 'TWCR' undeclared (first use in this function); did you mean 'EECR'?

   TWCR = _BV(TWEN) | _BV(TWIE) | _BV(TWEA) | _BV(TWINT);

   ^~~~

   EECR

In file included from c:\users\steph\appdata\local\arduino15\packages\arduino\tools\avr-gcc\7.3.0-atmel3.6.1-arduino7\avr\include\avr\io.h:99:0,

                 from C:\Users\steph\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.5\libraries\Wire\src\utility\twi.c:26:

C:\Users\steph\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.5\libraries\Wire\src\utility\twi.c:444:14: error: 'TWEN' undeclared (first use in this function); did you mean 'TWCR'?

   TWCR = _BV(TWEN) | _BV(TWIE) | _BV(TWEA) | _BV(TWINT);

              ^

C:\Users\steph\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.5\libraries\Wire\src\utility\twi.c:444:26: error: 'TWIE' undeclared (first use in this function); did you mean 'TWEN'?

   TWCR = _BV(TWEN) | _BV(TWIE) | _BV(TWEA) | _BV(TWINT);

                          ^

C:\Users\steph\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.5\libraries\Wire\src\utility\twi.c:444:38: error: 'TWEA' undeclared (first use in this function); did you mean 'TWEN'?

   TWCR = _BV(TWEN) | _BV(TWIE) | _BV(TWEA) | _BV(TWINT);

                                      ^

C:\Users\steph\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.5\libraries\Wire\src\utility\twi.c:444:50: error: 'TWINT' undeclared (first use in this function); did you mean 'TWIE'?

   TWCR = _BV(TWEN) | _BV(TWIE) | _BV(TWEA) | _BV(TWINT);

                                                  ^

C:\Users\steph\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.5\libraries\Wire\src\utility\twi.c: In function 'twi_handleTimeout':

C:\Users\steph\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.5\libraries\Wire\src\utility\twi.c:475:29: error: 'TWBR' undeclared (first use in this function); did you mean 'TIFR'?

     uint8_t previous_TWBR = TWBR;

                             ^~~~

                             TIFR

C:\Users\steph\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.5\libraries\Wire\src\utility\twi.c:476:29: error: 'TWAR' undeclared (first use in this function); did you mean 'TWBR'?

     uint8_t previous_TWAR = TWAR;

                             ^~~~

                             TWBR

In file included from C:\Users\steph\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.5\libraries\Wire\src\utility\twi.c:27:0:

C:\Users\steph\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.5\libraries\Wire\src\utility\twi.c: In function 'TWI_vect':

C:\Users\steph\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.5\libraries\Wire\src\utility\twi.c:503:5: warning: 'TWI_vect' appears to be a misspelled 'signal' handler, missing '__vector' prefix [-Wmisspelled-isr]

 ISR(TWI_vect)

     ^

In file included from c:\users\steph\appdata\local\arduino15\packages\arduino\tools\avr-gcc\7.3.0-atmel3.6.1-arduino7\avr\include\compat\twi.h:36:0,

                 from C:\Users\steph\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.5\libraries\Wire\src\utility\twi.c:29:

C:\Users\steph\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.5\libraries\Wire\src\utility\twi.c:505:10: error: 'TWSR' undeclared (first use in this function); did you mean 'ACSR'?

   switch(TW_STATUS){

          ^

In file included from c:\users\steph\appdata\local\arduino15\packages\arduino\tools\avr-gcc\7.3.0-atmel3.6.1-arduino7\avr\include\avr\io.h:99:0,

                 from C:\Users\steph\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.5\libraries\Wire\src\utility\twi.c:26:

C:\Users\steph\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.5\libraries\Wire\src\utility\twi.c:505:10: error: 'TWS7' undeclared (first use in this function); did you mean 'TWSR'?

   switch(TW_STATUS){

          ^

C:\Users\steph\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.5\libraries\Wire\src\utility\twi.c:505:10: error: 'TWS6' undeclared (first use in this function); did you mean 'TWS7'?

   switch(TW_STATUS){

          ^

C:\Users\steph\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.5\libraries\Wire\src\utility\twi.c:505:10: error: 'TWS5' undeclared (first use in this function); did you mean 'TWS6'?

   switch(TW_STATUS){

          ^

C:\Users\steph\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.5\libraries\Wire\src\utility\twi.c:505:10: error: 'TWS4' undeclared (first use in this function); did you mean 'TWS5'?

   switch(TW_STATUS){

          ^

C:\Users\steph\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.5\libraries\Wire\src\utility\twi.c:505:10: error: 'TWS3' undeclared (first use in this function); did you mean 'TWS4'?

   switch(TW_STATUS){

          ^

C:\Users\steph\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.5\libraries\Wire\src\utility\twi.c:510:7: error: 'TWDR' undeclared (first use in this function); did you mean 'TWSR'?

       TWDR = twi_slarw;

       ^~~~

       TWSR

C:\Users\steph\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.5\libraries\Wire\src\utility\twi.c:530:10: error: 'TWCR' undeclared (first use in this function); did you mean 'TWDR'?

          TWCR = _BV(TWINT) | _BV(TWSTA)| _BV(TWEN) ;

          ^~~~

          TWDR

In file included from c:\users\steph\appdata\local\arduino15\packages\arduino\tools\avr-gcc\7.3.0-atmel3.6.1-arduino7\avr\include\avr\io.h:99:0,

                 from C:\Users\steph\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.5\libraries\Wire\src\utility\twi.c:26:

C:\Users\steph\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.5\libraries\Wire\src\utility\twi.c:530:21: error: 'TWINT' undeclared (first use in this function)

          TWCR = _BV(TWINT) | _BV(TWSTA)| _BV(TWEN) ;

                     ^

C:\Users\steph\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.5\libraries\Wire\src\utility\twi.c:530:34: error: 'TWSTA' undeclared (first use in this function); did you mean 'TWS3'?

          TWCR = _BV(TWINT) | _BV(TWSTA)| _BV(TWEN) ;

                                  ^

C:\Users\steph\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.5\libraries\Wire\src\utility\twi.c:530:46: error: 'TWEN' undeclared (first use in this function); did you mean 'TWINT'?

          TWCR = _BV(TWINT) | _BV(TWSTA)| _BV(TWEN) ;

                                              ^

exit status 1

Erreur de compilation pour la carte ATtiny25/45/85

Ce rapport pourrait être plus détaillé avec
l'option "Afficher les résultats détaillés de la compilation"
activée dans Fichier -> Préférences.

parametre

C'est les pins 5 et 7

Apparemment tu utilises un core attiny qui ne gère pas l'i2c (sur l'attiny85 c'est géré par soft).
Utilise le core de Spence Konde

Il faut désinstaller le core attiny installé actuellement.

Je trouve pas le core attiny que j'ai installé et je trouve pas le core Spence Konde dans la bibliothèque librairie

Quand tu regardes dans le gestionnaire de cartes tu doit trouver une entrée pour le attiny qui est installée.
Pour installer le core de Spence Konde il faut suivre les instructions du paragraphe installation de la doc.

Bonjour

c'est ici :

Un core n'est pas une bibliothèque (library), il faut l'ajouter par le menu 'Préférences'

Tu utilises l'IDE 1.8 ou 2.0 ?

J'utilise à 1.8. J'ai réussi pour le core par conte je choisi quoi dans la liste déroulante ?

Si c'est un attiny85 seul (pas un digispark) tu choisis ATtiny25/45/85 (No bootloader)

Le téléversement sait bien passé. je teste le fonctionnement avec attiny85 un peut plus tard

Après mettre planté de pin pour le détecteur de mouvement et relais et supprimer le délais de 1s sa marche parfaitement.

Merci pour votre aide

Bravo, bonne continuation.

Merci, je travail sur gros projet de domotique et pour ce qu'ils ont envie de voir.

Mon site: Domotique pour la maison

Beau projet. :smiley:

Merci mais il y a du taf.

Par conte j'ai un nouveau problème.

Quand je teste le code sur un arduino uno ou nano tous fonctionne bien par conte quand je le teste sur attiny85 la plus rien ne marche

#include <Wire.h>
#include <BH1750.h>

BH1750 lightMeter;

int mouvement = 3;
int relais = 4;
int com_nanuel = 1;
int seuil_luminosite = A0;
boolean etat_BP;

void setup()
{
  Serial.begin(9600);
  Wire.begin();
  lightMeter.begin(BH1750::CONTINUOUS_LOW_RES_MODE);
  pinMode(mouvement, INPUT_PULLUP);
  pinMode(com_nanuel, INPUT_PULLUP);
  pinMode(relais, OUTPUT);
  digitalWrite(relais, HIGH);
  etat_BP = false;
}

void loop()
{
  int etat_mouvement = digitalRead(mouvement);
  Serial.print("Mouvement détecter: ");
  Serial.print(etat_mouvement);
  Serial.print("\t");

  float lux = lightMeter.readLightLevel();
  Serial.print("Light: ");
  Serial.print(lux);
  Serial.print(" lx");
  Serial.print("\t");

  int potentiometre = analogRead(seuil_luminosite);
  float unite = map(potentiometre, 0, 1023, 0, 65535);
  Serial.print("Seuil de luminosité: ");
  Serial.print(unite);
  Serial.print(" lx");
  Serial.print("\t");

  int etat_com_manuel = digitalRead(com_nanuel);
  Serial.print(etat_com_manuel);
  Serial.print("\t");

  if(etat_com_manuel == 0) {etat_BP = !etat_BP;}
  Serial.println(etat_BP);

  /*if(etat_BP == 1)
  {Serial.println("Relais actif");}
  else if(etat_mouvement == 1 && lux < unite)
  {Serial.println("Relais actif");}
  else
  {Serial.println("Relais inactif");}*/

  if(etat_mouvement == 1 && lux < unite)
  {digitalWrite(relais, LOW);}
  else if(etat_BP == 1)
  {digitalWrite(relais, LOW);}
  else
  {digitalWrite(relais, HIGH);}

  delay(1000); 
}

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.