Attiny con display oled

Una buona giornata a tutti,
ho bisogno del vostro aiuto, sto provando "e non ci riesco" a far andare un display oled con un Attiny85,
spiego cosa sto facendo:
Programmo l'Attiny con un Arduino uno "programmato come programmatore" collegamenti controllati più volte, display provato con Arduino uno e funziona,
anche l'Attiny testato su altro progetto e funziona,

il display e questo
https://it.aliexpress.com/item/32896971385.html?spm=a2g0o.productlist.0.0.7ae42d93FnGnEl&algo_pvid=5915cae1-2e76-4c1e-af5f-fbb34aebfc4f&algo_expid=5915cae1-2e76-4c1e-af5f-fbb34aebfc4f-0&btsid=695f46f8-2c7f-4a5d-a990-f450443cf489&ws_ab_test=searchweb0_0,searchweb201602_8,searchweb201603_53

per provare il display con Attiny ho scaricato da questo sito

il programma ed le relative librerie,
le librerie sono inserite nella cartella del progetto,

la programmazione va a buon fine, ma il display non mostra niente, come morto,
l'indirizzo I2c l'ho controllato con Arduino scanner,

posto il programma con cui sto provando,

#include "TinyWireM.h"
#include "USI_TWI_Master.h"
#include "SSD1306_minimal.h"
#include <avr/pgmspace.h>

#define DEG "\xa7" "C"

SSD1306_Mini oled;

//byte array of bitmap 5x24px
const unsigned char  img_thermometer[] PROGMEM = {

  0x00, 0xfe, 0x03, 0xfe, 0x50,
  0x00, 0xff, 0x00, 0xff, 0x55,
  0x60, 0x9f, 0x80, 0x9f, 0x65,

};

//byte array of bitmap 17x16 px
const unsigned char  img_heart_small[] PROGMEM = {

  0x00, 0x00, 0xc0, 0xe0, 0xe0, 0xe0, 0xc0, 0x80, 0x80, 0x80, 0xc0, 0xe0, 0xe0, 0xe0, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x03, 0x07, 0x0f, 0x1f, 0x3f, 0x1f, 0x0f, 0x07, 0x03, 0x01, 0x00, 0x00, 0x00
};

//byte array of bitmap 17x16 px
const unsigned char  img_heart_big[] PROGMEM = {

  0xe0, 0xf0, 0xf8, 0xf8, 0xf8, 0xf8, 0xf0, 0xe0, 0xe0, 0xe0, 0xf0, 0xf8, 0xf8, 0xf8, 0xf8, 0xf0, 0xe0, 0x00, 0x01, 0x03, 0x07, 0x0f, 0x1f, 0x3f, 0x7f, 0xff, 0x7f, 0x3f, 0x1f, 0x0f, 0x07, 0x03, 0x01, 0x00
};

//Byte array of bitmap of 76 x 56 px:
const unsigned char img_logo [] PROGMEM = {
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x3f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x07, 0x00, 0x30, 0xfc, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x0f, 0x07, 0xc3, 0xe3, 0xe3, 0xe3, 0xe3, 0xc3, 0x07, 0x0f, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfc, 0xf0, 0xe1, 0xc3, 0xc7, 0xc7, 0xc7, 0xc7, 0x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 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x8f, 0x8f, 0x8f, 0x8f, 0x8f, 0x8f, 0xc0, 0xc0, 0xf0, 0xff, 0xff, 0xf9, 0xf1, 0x01, 0x01, 0x01, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf9, 0xf1, 0x01, 0x01, 0x01, 0xff, 0xff, 0xff, 0xff, 0xff, 0x01, 0x01, 0x03, 0xe3, 0xf1, 0xf1, 0xf1, 0xf1, 0x01, 0x03, 0xff, 0xff, 0xff, 0xff, 0x07, 0x03, 0xe1, 0xf1, 0xf1, 0xf1, 0xf1, 0xe1, 0x03, 0x07, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xe0, 0xe0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xe3, 0xe3, 0xe0, 0xe0, 0xe0, 0xe3, 0xe3, 0xf7, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xe3, 0xe3, 0xe0, 0xe0, 0xe0, 0xe3, 0xe3, 0xf7, 0xff, 0xff, 0xf0, 0xe0, 0xf0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0, 0xe0, 0xff, 0xff, 0xff, 0xff, 0xf8, 0xf0, 0xf1, 0xe3, 0xe3, 0xe3, 0xe3, 0xf1, 0xf0, 0xf8, 0xff, 0xff, 0xff, 0xff
};


void splash() {

  oled.startScreen();
  oled.clear();

  oled.drawImage( img_logo, 20, 0, 76, 7 );
  oled.cursorTo(0, 7);
  oled.printString( "http://CoPiino.cc");

  delay(5000);

  oled.clear();
  oled.cursorTo(15, 1);
  oled.printString( "SSD1306+ATTiny");

  oled.cursorTo(30, 3);
  oled.printString( "Library");


  oled.cursorTo(0, 7);
  oled.printString( "http://CoPiino.cc");



}


void heartBeat() {
  static char big = 1;
  static long startTime = 0;
  long currentTime;

  // get current time
  currentTime = millis();

  // update if 1000ms passed
  if ((currentTime - startTime) > 200) {
    startTime = currentTime;


    // ---
    big = 1 - big;
    if (big) {
      oled.drawImage( img_heart_big, 10, 5, 17, 2);
    } else {
      oled.drawImage( img_heart_small, 10, 5, 17, 2);
    }

  }
}


void prepareDisplay() {

  unsigned int i, k;
  unsigned char ch[5];

  oled.clear();
  oled.startScreen();


  oled.cursorTo(0, 0);
  oled.printString( "ATTiny");
  oled.cursorTo(5, 1);
  oled.printString( "Standard Font");
  oled.cursorTo(10, 2);
  oled.printString( "abcdef...xyz");

  oled.drawImage( img_thermometer, 50, 4, 5, 3 );
  oled.cursorTo(60, 5);
  oled.printString( "+15" DEG );
  oled.cursorTo(67, 6);
  oled.printString( "63%");

  oled.drawImage( img_heart_small, 10, 5, 17, 2);


}

char getTemperature() {
  return random(-30, 30);
}

char getHumidity() {
  return random(0, 99);
}

void setup() {
  pinMode(3, INPUT);

  oled.init(0x3D);
  oled.clear();

  delay(1000);

  splash();

  delay(8000);

  prepareDisplay();

}


void loop() {

  static long startTime = 0;
  long currentTime;


  // get current time
  currentTime = millis();

  // update if 1000ms passed
  if ((currentTime - startTime) > 1000) {
    startTime = currentTime;
    char buf[10];

    // ---
    // update temperature
    char temperature = getTemperature();

    sprintf(buf, "%+0.2hd" DEG , temperature);

    // set cursor
    oled.cursorTo(60, 5);

    // print to display
    oled.printString( buf );


    // ---
    // update humidity
    char humidity = getHumidity();

    sprintf(buf, "%0.2hd\%", humidity);

    // set cursor
    oled.cursorTo(6, 11);
    oled.printString("Antonio");

    // print to display
    //oled.printString( buf );



  }

  heartBeat();


}

non riesco a capire dove sbaglio,
chiedo cortesemente un aiuto per risolvere il problema

Una buona giornata a tutti
scusatemi se insisto,
ma proprio non riesco a fa r andare questo display (SSD1306 128 x 64) con un Attiny
ho provato con varie librerie ma non mi fanno vedere niente,

mentre con Arduino uno tutto OK,

in rete ho trovato anche chi usa la libreria U8g2, in effetti negli esempi c'è questo display, anche qui il caricamento va a buon fine ma non si vede niente,

per cortesia c'è qualcuno che a avuto a che fare con questi display e mi può dare qualche suggerimento per risolvere il problema?

mille grazie a chi mi può aiutare

Ma le resistenze di pull-up sulle linee del I2C le hai messe ? Perché non so se ci sono sul modulo del OLED ... ::slight_smile:

Guglielmo

P.S.: Personalmente mi trovo molto bene con QUESTA libreria ... probabilmente devi adattarla per la TinyWire che si usa sugli ATtiny :wink:

Ciao Guglielmo, grazie di avermi risposto

Ma le resistenze di pull-up sulle linee del I2C le hai messe ?

si ci sono,
anche perché con Arduino uno funziona,

quella libreria l'ho usata per testare l'oled con Arduino uno,
ma per Attiny non va, l'Ide non ne vuole sapere per l'Attiny

per modificare la libreria, la vedo dura sono cose da maghi,

Ma così tanto per dire, attiny85 quanta ram ha rispetto ad atmega328?
Sicuramente ne ha meno e potrebbe creare problemi. Non ho aperto la lib per guardarci dentro quindi non so quanto ram statica consuma.

Se il display ha font interni usando quelli si risparmi molta ram ma questo vuole dire niente grafica.

Da una ricerca rapida sulla rete attiny85 ha 512Byte di ram e atmega328 2048byte.

Poi credo, non ho fatto i conti ma ricordo che i2c è limitato a 100k. La libreria linkata da gpb01 di default usa i2c a 400k.

ma per Attiny non va, l'Ide non ne vuole sapere per l'Attiny

Ma la libreria che usi per il display è compatibile con attiny85?

Ciao.

>milefori: ... girando tra vari siti, mi è capitato proprio ora sottomano QUESTO progetto ... ATtiny85 e OLED come il tuo ... prova a scaricarti il progetto e vedere cosa usano :wink:

Guglielmo

P.S.: Nota che loro le pull-up le mettono eccome !
P.P.S.: Per l'I2C lo fanno via software in bit banging :wink:

Ciao ragazzi

Maurotec

Ma la libreria che usi per il display è compatibile con attiny85?

per quello che riesco a capire si
ti posto le librerie con l'esempio

Guglielmo
ho scaricato quel progetto
non me lo compila per Attiny85

SSD1306_minimal.cpp (15.8 KB)

SSD1306_minimal.h (6.09 KB)

TinyWireM.cpp (3.61 KB)

TinyWireM.h (2.9 KB)

USI_TWI_Master.cpp (13.2 KB)

USI_TWI_Master.h (4.7 KB)

weather.ino (6.65 KB)

Viste le lib, breve sguardo e non trovo nulla di strano. L'attiny lavora a 16MHZ con il quarzo giusto?

Ciao.

milefori:
Guglielmo
ho scaricato quel progetto
non me lo compila per Attiny85

Impossibile, hai sbagliato qualche cosa, comunque ... NON doveri far girare quel progetto, te lo dovevi STUDIARE e capire come controlla l'OLED !!!

Guglielmo

Maurotec

L'attiny lavora a 16MHZ con il quarzo giusto?

NO 8MHZ oscillatore interno

Guglielmo

te lo dovevi STUDIARE e

OK ci provo

intanto mille grazie per il tempo che mi dedicate

Rieccomi qui, scusatemi ma non va,
ora con il progetto che mi a suggerito Guglielmo si compila ma non manda niente a display,
e come non avesse l'indirizzo,

e l'unica istruzione dove mettere l'indirizzo e:

ssd1306xled.h 
#ifndef SSD1306_SA
#define SSD1306_SA 0x3D //x78 Slave address
#endif

ma sembra come non ci fosse,

posto tutto il progetto,
magari qualche buona anima mi può dire dove sbaglio

font6x8.h (4.44 KB)

font8x16.h (9 KB)

img0_128x64c1.h (5.59 KB)

img1_128x64c1.h (6.45 KB)

ssd1306xled.cpp (5.22 KB)

ssd1306xled.h (1.78 KB)

ssd1306xled8x16.cpp (1.61 KB)

ssd1306xled8x16.h (511 Bytes)

Tiny_ssd1306.ino (1.25 KB)