Conflit LCD 12864 & SHT31

Hello,
I have a lcd LM12864MBC-1.
I'm using it with glcd and u8glib and it works fine.

include "U8glib.h"

//**************************************************
// Change this constructor to match your display!!!
U8GLIB_SH1106_128X64 u8g(4, 5, 6, 7);
//**************************************************

void setup() {
u8g.setFont(u8g_font_unifont);
u8g.setColorIndex(1); // Instructs the display to draw with a pixel on.
}

void loop() {
u8g.firstPage();
do {
draw();
} while( u8g.nextPage() );
delay(1000);
}

void draw(){
u8g.drawStr( 0, 20, "Hello World");

}

On the other side, i have temp and humidity sensor sht31, connected with I2C.
With the exemple provided by adafruit, it works fine .

#include <Arduino.h>
#include <Wire.h>
#include "Adafruit_SHT31.h"

Adafruit_SHT31 sht31 = Adafruit_SHT31();

void setup() {
Serial.begin(9600);

while (!Serial)
delay(10); // will pause Zero, Leonardo, etc until serial console opens

Serial.println("SHT31 test");
if (! sht31.begin(0x44)) { // Set to 0x45 for alternate i2c addr
Serial.println("Couldn't find SHT31");
while (1) delay(1);
}
}

void loop() {
float t = sht31.readTemperature();
float h = sht31.readHumidity();

if (! isnan(t)) { // check if 'is not a number'
Serial.print("Temp *C = "); Serial.println(t);
} else {
Serial.println("Failed to read temperature");
}

if (! isnan(h)) { // check if 'is not a number'
Serial.print("Hum. % = "); Serial.println(h);
} else {
Serial.println("Failed to read humidity");
}
Serial.println();
delay(1000);
}

I would like now to display the data from sensor on the screen. But when i merge both soft, the screen no longer works.
I found that the bug is comming from the line sht31.begin(0x44).

Is there a conflict between the 2 librairies ? Y there a way to make it works ?
I have a multiplexer TCA9548A. May it help?

Thanks for your help.
Nicolas

hi !

please send your total merged code !

Hi,

Here is the merge code :

#include "U8glib.h"

#include <stdlib.h>

#include <Wire.h>
#include "Adafruit_SHT31.h"
Adafruit_SHT31 sht31 = Adafruit_SHT31();

//**************************************************
// Change this constructor to match your display!!!
U8GLIB_KS0108_128 u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 14, 15, 17, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, cs1=14, cs2=15,di=17,rw=16
//**************************************************

void setup() {
u8g.setFont(u8g_font_unifont);
u8g.setColorIndex(1); // Instructs the display to draw with a pixel on.

// If i put this line in comment, screen is working
sht31.begin(0x44);
}

void loop() {
u8g.firstPage();
do {
draw();
} while( u8g.nextPage() );
delay(1000);
}

void draw(){
char buff[10];
float shtT1 = 50.0;

//float shtT1 = sht31.readTemperature();
dtostrf(shtT1, 4, 2, buff); //4 is mininum width, 6 is precision

u8g.drawStr( 0, 20, "Hello world");
u8g.drawStr( 0, 50, buff);

}

I forget to tell i'm on arduino uno.

thanks,

okay!

=======edit this part:==============

#include "U8glib.h"
#include <stdlib.h>
#include <Wire.h>
#include "Adafruit_SHT31.h"

Adafruit_SHT31 sht31;

=============================

put delay(100); after or before :

sht31.begin(0x44);

(for init. module)

and send me the result !

Thanks for your reply.

Unfortunately, doesn't work.

i put a delay before and after, but no effect (even try longer delays).

Without : sht31.begin(0x44); , screen is updated.
With, no update, and somme strange characters. (no update means that even if i change the displayed text in arduino, the screen keeps its old message.).

what is this "hex" argument says? 0x44 ?
sht31.begin(0x44);

====

try it empty:
sht31.begin();

====

i have uno but havnt SHT sensor for testing !
check your wiring/connection to ensure its okay !

send a total sketch+librarys+.c/.h files in a ZIP file here

Thanks again for your time.

the hex value (0x44 or 0x45) are the default value for the i2c. I found it on exemple and it was working, so i keep it. I tried none as suggested, but not working.

I join my files.

Independently, lcd and sht31 are working perfectly. So i assume my connections are fine.

Thanks, Nicolas

Arduino.zip (1.08 MB)