OLED 0.96'' 1315SSD issue with text location

I manage to get my reading display on OLED monochrome 128×64dot matrix display module but the order makes no sense…

I would expect the following order from the top: Temp, Hum, Light.

  1. How to get code in order as mention above
  2. How to set the size of text?
    any advice would be appreciated…

I did some reading and expected coordiantes 0,0 to be top left

here is my code

//#define DHTPIN 3 // By default the module connected to pin D3, it can be changed, define it before the #include of the library
#include "Arduino_SensorKit.h"
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1351.h>
#include <SPI.h>


// Color definitions
#define	BLACK           0x0000
#define	BLUE            0x001F
#define	RED             0xF800
#define	GREEN           0x07E0
#define CYAN            0x07FF
#define MAGENTA         0xF81F
#define YELLOW          0xFFE0
#define WHITE           0xFFFF

int light_sensor = A3;

void setup() {
  Serial.begin(9600);
  Environment.begin();
  //.clearDisplay();
  Oled.begin();
  Oled.setFlipMode(true); // Sets the rotation of the screen
}

void loop() {

  Serial.print("Temperature = "); //println put enter at the end of this line?! strange
  Serial.print(Environment.readTemperature()); //print temperature
  Serial.println(" C");
  Serial.print("Humidity = ");
  Serial.print(Environment.readHumidity()); //print humidity
  Serial.println(" %");
  //delay(5000);

  int raw_light = analogRead(light_sensor); // read the raw value from light_sensor pin (A3)
  Serial.print("Light level: ");
  Serial.print(raw_light); // print the light value in Serial Monitor
  Serial.println(" lux");
  Serial.println("-------------");


  Oled.setFont(u8x8_font_chroma48medium8_r);
  Oled.setCursor(0, 5);    // Set the Coordinates
  Oled.print("Temp: ");
  Oled.print(Environment.readTemperature()); // Print the Values
  Oled.println(" C");
  
  Oled.setCursor(0, 55);    // Set the Coordinates
  Oled.print("Hum: ");
  Oled.print(Environment.readHumidity()); // Print the Values
  Oled.println(" %");

  Oled.setCursor(0, 25);    // Set the Coordinates
  Oled.print("Light: ");
  Oled.print(raw_light); // Print the Values
  Oled.println(" lux");
  
  Oled.refreshDisplay();    // Update the Display
  delay(2000);
  //Oled.clearDisplay();

}

Please, no ZIP files, no images of code.

In the Arduino IDE, use Ctrl T or CMD T to format your code then copy the complete sketch.

Use the </> icon from the ‘reply menu’ to attach the copied sketch.

Ok! No one wants do download a file to look at a code. so to help everyone help you you must post the code in code tags. Step #1 go to your arduino IDE/Webpage and push CTRL+T to auto format it(so that we can read it. :wink: ) Then push CTRL+A then CTRL+C.
Then click on the button in the tool bar that looks like this: </>.

```
Then paste it in this area. When your done push Reply and it should look like this.
```

Push CTRL+V to paste it in here.

Oops LOL didn’t see that you had posted that! @LarryD Sorry!

thanks, I adjusted my post to meet your notes…

Ok try this:

//#define DHTPIN 3 // By default the module connected to pin D3, it can be changed, define it before the #include of the library
#include "Arduino_SensorKit.h"
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1351.h>
#include <SPI.h>


// Color definitions
#define	BLACK           0x0000
#define	BLUE            0x001F
#define	RED             0xF800
#define	GREEN           0x07E0
#define CYAN            0x07FF
#define MAGENTA         0xF81F
#define YELLOW          0xFFE0
#define WHITE           0xFFFF

int light_sensor = A3;

void setup() {
  Serial.begin(9600);
  Environment.begin();
  //.clearDisplay();
  Oled.begin();
  Oled.setFlipMode(true); // Sets the rotation of the screen
}

void loop() {

  Serial.print("Temperature = "); //println put enter at the end of this line?! strange
  Serial.print(Environment.readTemperature()); //print temperature
  Serial.println(" C");
  Serial.print("Humidity = ");
  Serial.print(Environment.readHumidity()); //print humidity
  Serial.println(" %");
  //delay(5000);

  int raw_light = analogRead(light_sensor); // read the raw value from light_sensor pin (A3)
  Serial.print("Light level: ");
  Serial.print(raw_light); // print the light value in Serial Monitor
  Serial.println(" lux");
  Serial.println("-------------");


  Oled.setFont(u8x8_font_chroma48medium8_r);
  Oled.setCursor(0, 5);    // Set the Coordinates
  Oled.print("Temp: ");
  Oled.print(Environment.readTemperature()); // Print the Values
  Oled.println(" C");
  
  Oled.setCursor(0, 25);    // Set the Coordinates
  Oled.print("Hum: ");
  Oled.print(Environment.readHumidity()); // Print the Values
  Oled.println(" %");

  Oled.setCursor(0, 50);    // Set the Coordinates
  Oled.print("Light: ");
  Oled.print(raw_light); // Print the Values
  Oled.println(" lux");
  
  Oled.refreshDisplay();    // Update the Display
  delay(2000);
  //Oled.clearDisplay();

}

The y axis of the display runs from 0 at the top not the bottom. Adjust the y coordinates in the setCursor() function to position the text in the order that you want

As to the text size, to change it use a different font. At a guess this

  Oled.setFont(u8x8_font_chroma48medium8_r);

uses a 48 point font. Try changing it to say 64. That font may not exist (I don’t know). If so do a search for Adafruit_SSD1351.h fonts

unfortunately, it did not work
I have now

Hum, Temp and Light

//#define DHTPIN 3 // By default the module connected to pin D3, it can be changed, define it before the #include of the library
#include "Arduino_SensorKit.h"
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1351.h>
#include <SPI.h>


// Color definitions
#define	BLACK           0x0000
#define	BLUE            0x001F
#define	RED             0xF800
#define	GREEN           0x07E0
#define CYAN            0x07FF
#define MAGENTA         0xF81F
#define YELLOW          0xFFE0
#define WHITE           0xFFFF

int light_sensor = A3;

void setup() {
  Serial.begin(9600);
  Environment.begin();
  //.clearDisplay();
  Oled.begin();
  Oled.setFlipMode(true); // Sets the rotation of the screen
}

void loop() {

  Serial.print("Temperature = "); //println put enter at the end of this line?! strange
  Serial.print(Environment.readTemperature()); //print temperature
  Serial.println(" C");
  Serial.print("Humidity = ");
  Serial.print(Environment.readHumidity()); //print humidity
  Serial.println(" %");
  //delay(5000);

  int raw_light = analogRead(light_sensor); // read the raw value from light_sensor pin (A3)
  Serial.print("Light level: ");
  Serial.print(raw_light); // print the light value in Serial Monitor
  Serial.println(" lux");
  Serial.println("-------------");


  Oled.setFont(u8x8_font_chroma48medium8_r);
  Oled.setCursor(0, 0);    // Set the Coordinates
  Oled.print("Temp: ");
  Oled.print(Environment.readTemperature()); // Print the Values
  Oled.println(" C");
  
  Oled.setCursor(0, 15);    // Set the Coordinates
  Oled.print("Hum: ");
  Oled.print(Environment.readHumidity()); // Print the Values
  Oled.println(" %");

  Oled.setCursor(0, 30);    // Set the Coordinates
  Oled.print("Light: ");
  Oled.print(raw_light); // Print the Values
  Oled.println(" lux");
  
  Oled.refreshDisplay();    // Update the Display
  delay(2000);
  //Oled.clearDisplay();

}

try that.

1 Like

thanks a lot at the end I got it working with these settings and I mange to find additioanl font

not sure why none of these fonts worked

here is my code

 //Oled.setFont(u8x8_font_chroma48medium8_r); //thin
  Oled.setFont(u8x8_font_amstrad_cpc_extended_f);   //thick

  Oled.setCursor(0, 0);    // Set the Coordinates
  Oled.print("Temp: ");
  Oled.print(Environment.readTemperature()); // Print the Values
  Oled.println(" C");

  Oled.setCursor(0, 10);    // Set the Coordinates
  Oled.print("Hum: ");
  Oled.print(Environment.readHumidity()); // Print the Values
  Oled.println(" %");

  Oled.setCursor(0, 20);    // Set the Coordinates
  Oled.print("Light: ");
  Oled.print(raw_light); // Print the Values
  Oled.println(" lux");

  Oled.refreshDisplay();    // Update the Display
  delay(2000);

I run a lots of tests and with
setFont(u8x8_font_amstrad_cpc_extended_f)
maximum is for y from 0 to 30 if value will exceed it will start from top again…
something new for me but I guess maybe standard behaviour for Arduino users,

Glad I could help you figure out what the problem was!
Good luck with future projects and If you have any more issues then feel free to post a thread on them!

1 Like

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.