U8glib: Graphics Lib + OLEDs + Constant variable

Hi, I will trying to display "Pressure and temperature" with my OLED screen 168x64 and U8glib. No problem to display the GraphicsTest. But I added a Barometric Pressus & Temp Sensor from Adafruit BMP180. I didn't succeded to display temp sensor value into my OLED screen. Below a short example that I'm trying to do. Anyone, alreay did something else ?

void u8g_ascii_2() {
  //int temp = bmp.readTemperature(); 
  u8g.drawFrame(0,0,128,64); // DRAW FRAMES
  u8g.drawStr( 0, 0,"Temperature:");
  u8g.drawStr( 0, 0,Temp);
  
}

Hi cyberrat, welcome.

What do you see on the OLED screen ? Have you tried to just display text first, and a variable next ? What do these zeros do in the drawstr lines ? Are you sure they need to be zeros and not some other value ?

I juste want display the temperature on My OLED screen and thé 0 is for the position on screen (x,y) values

Use "print" instead of "drawStr":

u8g.setPrintPos(20,20);
u8g.print(temp);

Oliver

I used adafruit library for BMP085 for my sensor BMP180. Also I trying the example code that you post. I just want to find a way to get this value bmp.readTemperature(); affected to this variable : “temp” and use “u8g.print” to display the temperature value on oled screen. I really noob :slight_smile: with this kind of thing. Thank’s for you help guys !

#include <Adafruit_BMP085.h>
Adafruit_BMP085 bmp;

void u8g_display() {
  int temp = bmp.readTemperature(); 
  u8g.drawFrame(0,0,128,64); // DRAW FRAMES
  u8g.setPrintPos(20,20);
  u8g.print(temp);
}

I knew what these zeros are for, wanted you to think over that code and the mistake you probably made.
See your first code.
You’re trying to print the 2nd line over the first line there.

The message is, take things step by step.
Break your problems down to smaller, manageable steps instead of trying to solve them all in one shot.

The only think I want is just display the tempurature in the screen. Nothing more I already makes a lot of tests without sucess. I just request help or if someone already do this before.