I am trying to get two 128x64 Ic2 OLEDs to work with a nano. I get errors and can't seem to find where they are. I have read several tutorials and still can't find it. I only need both OLEDs to display the same data, which will be changed as the rest of the sketch is done.
thanks
```cpp
#include "U8glib.h"
#include "DHT.h"
#define DHTPIN 2
#define DHTTYPE DHT22
#define mando_width 46
#define mando_height 64
#define I2C_SLA (0x3C)
#define I2C_SLA (0x3D)
int leds[4] = {3,4,5,6};
DHT dht(DHTPIN, DHTTYPE);
U8GLIB_SSD1306_128X64 u8g1(U8G_I2C_OPT_NO_ACK);
U8GLIB_SSD1306_128X64 u8g2(U8G_I2C_OPT_NO_ACK);
static unsigned char mando_bits[] U8G_PROGMEM = {
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, 0x08, 0x00, 0x00,
0x00, 0x00, 0xfb, 0x1f, 0x00, 0x00, 0x00, 0x80, 0xfb, 0x1f, 0x00, 0x00,
0x00, 0xc0, 0xf9, 0x1f, 0x00, 0x00, 0x00, 0xc0, 0xf3, 0x1f, 0x00, 0x00,
0x00, 0xc0, 0xf7, 0x0f, 0x00, 0x00, 0x00, 0x80, 0xf7, 0x2f, 0x00, 0x00,
0x00, 0x00, 0xff, 0x27, 0x00, 0x00, 0x00, 0x60, 0xfe, 0x31, 0x00, 0x00,
0x00, 0x60, 0xfc, 0x30, 0x00, 0x00, 0x00, 0x60, 0x78, 0x70, 0x00, 0x00,
0x00, 0x30, 0x38, 0x78, 0x00, 0x00, 0x00, 0x70, 0x38, 0x3c, 0x00, 0x00,
0x00, 0xf0, 0x38, 0x3e, 0x00, 0x00, 0x00, 0xe0, 0xb9, 0x9f, 0x01, 0x00,
0x00, 0xe0, 0xb3, 0xcf, 0x03, 0x00, 0x00, 0xe0, 0xbf, 0xcf, 0x03, 0x00,
0x00, 0xd8, 0xff, 0xef, 0x07, 0x00, 0x00, 0x9e, 0xff, 0xe7, 0x0f, 0x00,
0x00, 0x7f, 0xfe, 0xe3, 0x1f, 0x00, 0x00, 0xff, 0xfe, 0xc3, 0x1f, 0x00,
0x80, 0xff, 0xfe, 0x83, 0x3f, 0x00, 0xc0, 0x3f, 0xfe, 0x03, 0x3f, 0x00,
0xc0, 0x1f, 0x7e, 0x03, 0x7e, 0x00, 0xc0, 0x0f, 0x64, 0x03, 0x7e, 0x00,
0xe0, 0x07, 0x24, 0x03, 0x7c, 0x00, 0xe0, 0x07, 0x2c, 0x01, 0xf8, 0x00,
0xe0, 0x03, 0x2c, 0x01, 0xf8, 0x00, 0xf0, 0x01, 0xac, 0x01, 0xf0, 0x00,
0xf0, 0x00, 0xfc, 0x01, 0xf0, 0x00, 0xf0, 0x00, 0x9c, 0x01, 0xf0, 0x00,
0xf0, 0x00, 0x9c, 0x01, 0xf0, 0x00, 0xf0, 0x00, 0xdc, 0x01, 0xf0, 0x00,
0xf0, 0x00, 0x9c, 0x01, 0x78, 0x00, 0xe0, 0x00, 0x90, 0x01, 0x7c, 0x00,
0xe0, 0x01, 0xa4, 0x82, 0x3f, 0x00, 0xc0, 0x03, 0xac, 0x02, 0x07, 0x00,
0x80, 0x7f, 0xac, 0x02, 0x00, 0x00, 0x00, 0x3f, 0xac, 0x02, 0x00, 0x00,
0x00, 0x00, 0xac, 0x06, 0x00, 0x00, 0x00, 0x00, 0xa8, 0x06, 0x00, 0x00,
0x00, 0x00, 0xa8, 0x06, 0x00, 0x00, 0x00, 0x00, 0xb8, 0x02, 0x00, 0x00,
0x00, 0x00, 0xb8, 0x02, 0x00, 0x00, 0x00, 0x00, 0x90, 0x02, 0x00, 0x00,
0x00, 0x00, 0xb0, 0x02, 0x00, 0x00, 0x00, 0x00, 0xb0, 0x04, 0x00, 0x00,
0x00, 0x00, 0xb0, 0x02, 0x00, 0x00, 0x00, 0x00, 0xb0, 0x02, 0x00, 0x00,
0x00, 0x00, 0x90, 0x01, 0x00, 0x00, 0x00, 0x00, 0x90, 0x01, 0x00, 0x00,
0x00, 0x00, 0x90, 0x01, 0x00, 0x00, 0x00, 0x00, 0xc0, 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 };
void draw(void) {
// graphic commands to redraw the complete screen should be placed here
u8g1.drawXBMP( 35, 0, mando_width, mando_height, mando_bits);
}
void setup() {
dht.begin();
u8g1.begin();
u8g1.firstPage();
do {
draw();
} while( u8g1.nextPage() );
delay(5000);
//delay(7500);
u8g2.begin();
u8g2.firstPage();
do {
draw();
} while( u8g2.nextPage() );
delay(5000);
//delay(7500);
}
void blinker(){
for (int jj; jj<sizeof(leds)/sizeof(int);jj++){
pinMode(leds[jj],OUTPUT);
//delay(10);
}
}
void loop() {
float hum = dht.readHumidity();
float temp = dht.readTemperature(true);
float fah = dht.readTemperature(true);
if (isnan(hum) || isnan(temp) || isnan(fah)) {
Serial.println("Failed to read from DHT sensor!");
return;
}
float heat_index = dht.computeHeatIndex(fah, hum);
float heat_indexC = dht.convertFtoC(heat_index); //Calculating the heat index in Celsius
digitalWrite(leds[random(0,sizeof(leds)/sizeof(int))],HIGH);
//delay(random(20,200));
digitalWrite(leds[random(0,sizeof(leds)/sizeof(int))],LOW);
u8g1.firstPage();
do {
u8g1.setFont(u8g_font_helvR12);
u8g1.drawStr(1, 15, "Temp:");
u8g1.setPrintPos(75, 15);
u8g1.print(temp, 0);
u8g1.print((char)176);
u8g1.print(" F");
u8g1.drawStr(4, 35, "Humi:");
u8g1.setPrintPos(75, 35);
u8g1.print(hum, 0);
u8g1.print(" %");
u8g1.drawStr(4, 55, "Hi:");
u8g1.setPrintPos(75, 55);
u8g1.print(heat_index, 0);
u8g1.print((char)176);
u8g1.print(" F");
} while( u8g1.nextPage() );
//delay(2500);
//delay(5000);
//delay(63);
delay(50);
//delay(38); // change to chang led blink speed
}
u8g2.firstPage();
do {
u8g2.setFont(u8g_font_helvR12);
u8g2.drawStr(1, 15, "Temp:");
u8g2.setPrintPos(75, 15);
u8g2.print(temp, 0);
u8g2.print((char)176);
u8g2.print(" F");
u8g2.drawStr(4, 35, "Humi:");
u8g2.setPrintPos(75, 35);
u8g2.print(hum, 0);
u8g2.print(" %");
u8g2.drawStr(4, 55, "Hi:");
u8g2.setPrintPos(75, 55);
u8g2.print(heat_index, 0);
u8g2.print((char)176);
u8g2.print(" F");
} while( u8g2.nextPage() );
//delay(2500);
//delay(5000);
//delay(63);
delay(50);
//delay(38); // change to chang led blink speed
}