Hi all!
The sketch below works fine on a Attiny85 based Digispark board:
#include <DigisparkOLED.h>
#include <Wire.h>
#include <TinyDHT.h>
#define DHTTYPE DHT11
#define DHTPIN 1
DHT dht(DHTPIN, DHTTYPE);
void setup() {
//Inicializa o display
oled.begin();
dht.begin();
oled.setFont(FONT8X16);
}
void loop() {
//Limpa o display
oled.clear();
int8_t h = dht.readHumidity();
int16_t t = dht.readTemperature(0);
if (t == BAD_TEMP || h == BAD_HUM) {
oled.clear();
oled.setCursor(10, 0);
oled.print(F("Erro sensor!"));
delay(2000);
}
else {
//Posiciona o cursor
//oled.setCursor(X em pixels, Y em linhas de 8 pixels comecando com 0);
oled.setCursor(10, 0);
//Seleciona fonte 8x16
oled.print(F("TEMPERATURA"));
oled.setCursor(10, 5);
oled.print(t);
oled.print(" C");
delay(3000);
oled.clear();
oled.setCursor(10, 0);
oled.print(F("UMIDADE"));
oled.setCursor(10, 5);
oled.print(h);
oled.print(" %");
delay(3000);
}
}
I would like to take it to a bare Attiny85 chip, but I´m facing problems with the libraries.
I´m switching:
#include <DigisparkOLED.h>
#include <Wire.h>
to
#include <Tiny4kOLED.h>
#include <TinyWireM.h>
but then I get a bunch of errors that seems to be related to the Wire library (?)
C:\Users\NOTEANTIGO\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6\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\NOTEANTIGO\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6\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\NOTEANTIGO\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6\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\NOTEANTIGO\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6\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\noteantigo\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\NOTEANTIGO\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6\libraries\Wire\src\utility\twi.c:26:
C:\Users\NOTEANTIGO\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6\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\NOTEANTIGO\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6\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\NOTEANTIGO\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6\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
Compilation error: exit status 1
Any hints?
Thanks in advance!