Oled display not printing ble serial text

/**************************************************************************
 This is an example for our Monochrome OLEDs based on SSD1306 drivers

 Pick one up today in the adafruit shop!
 ------> http://www.adafruit.com/category/63_98

 This example is for a 128x32 pixel display using I2C to communicate
 3 pins are required to interface (two I2C and one reset).

 Adafruit invests time and resources providing this open
 source code, please support Adafruit and open-source
 hardware by purchasing products from Adafruit!

 Written by Limor Fried/Ladyada for Adafruit Industries,
 with contributions from the open source community.
 BSD license, check license.txt for more information
 All text above, and the splash screen below must be
 included in any redistribution.
 **************************************************************************/
String data = ""; //declaring Variable for storing received data
#include <SPI.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#include <SoftwareSerial.h>
const unsigned int MAX_MESSAGE_LENGTH = 1000;
#define SCREEN_WIDTH 128 // OLED display width, in pixels
#define SCREEN_HEIGHT 32 // OLED display height, in pixels
SoftwareSerial Genotronex(0, 1);
// Declaration for an SSD1306 display connected to I2C (SDA, SCL pins)
// The pins for I2C are defined by the Wire-library. 
// On an arduino UNO:       A4(SDA), A5(SCL)
// On an arduino MEGA 2560: 20(SDA), 21(SCL)
// On an arduino LEONARDO:   2(SDA),  3(SCL), ...
#define OLED_RESET     -1 // Reset pin # (or -1 if sharing Arduino reset pin)
#define SCREEN_ADDRESS 0x3C ///< See datasheet for Address; 0x3D for 128x64, 0x3C for 128x32
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);

#define NUMFLAKES     10 // Number of snowflakes in the animation example

#define LOGO_HEIGHT   16
#define LOGO_WIDTH    16
static const unsigned char PROGMEM logo_bmp[] =
{ 0b00000000, 0b11000000,
  0b00000001, 0b11000000,
  0b00000001, 0b11000000,
  0b00000011, 0b11100000,
  0b11110011, 0b11100000,
  0b11111110, 0b11111000,
  0b01111110, 0b11111111,
  0b00110011, 0b10011111,
  0b00011111, 0b11111100,
  0b00001101, 0b01110000,
  0b00011011, 0b10100000,
  0b00111111, 0b11100000,
  0b00111111, 0b11110000,
  0b01111100, 0b11110000,
  0b01110000, 0b01110000,
  0b00000000, 0b00110000 };

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

  // SSD1306_SWITCHCAPVCC = generate display voltage from 3.3V internally
  if(!display.begin(SSD1306_SWITCHCAPVCC, SCREEN_ADDRESS)) {
    Serial.println(F("SSD1306 allocation failed"));
    for(;;); // Don't proceed, loop forever
  }

  // Show initial display buffer contents on the screen --
  // the library initializes this with an Adafruit splash screen.
  display.display();
  delay(2000);
  display.clearDisplay();
  Serial.begin(9600);  // baud rate for serial data transmission
    pinMode(13, OUTPUT);
}

void loop() {

  if(Genotronex.available() > 0){
    data = Genotronex.readString();
    Genotronex.println(data);
    
  }
  display.setTextSize(1);
  display.setTextColor(WHITE);
  display.setCursor(0,0);
  display.println(data);
  display.display(); 
  delay(4000);
  display.clearDisplay();
  display.display();                         
}

input on btt terminal app
hi

output on serial monitor

hi

display output

none

display works etc etc so is there code error?

@LarryD @paulpaulson @PaulRB pls help

its a school proj

1 Like

I'd suggest that you post the minimal code which demonstrates that your display works.
That is, get the display working first even if you are printing only a hard coded message.
After that, start looking at adding alternative input sources.

What type of arduino are you using? On many types, 0 and 1 are the hardware serial pins and should not be used for other purposes. On some types like Leonardo and (Pro) Micro, these pins are an available hardware serial port and it's always best to use a hardware port in preference to a software serial port.

The data variable is not initialized in your code. You should declare it as a string variable before using it.

Also, you are clearing the display after every 4 seconds which might not be what you want. If you want to display the data continuously, you should remove the delay function and clearDisplay() function from your loop() function.

I hope this helps! Let me know if you have any other questions!

Top of the listing.
String data = ""; //declaring Variable for storing received data

Admittedly, not normally where one finds it!

Oh sorry! I missed that!

Can you please check if your OLED display is properly connected and powered? Also, make sure that the I2C address of your OLED display matches the one in your code. Let me know if this helps!

Nano. Actually this is a miswired ble hence softwareserial

I successfully made the display display a string input in serial monitor...but when same is done y Bluetooth terminal app from playstore, the app does send text to serial monitor but it does not display

Guys it started working same code but it takes 2 secs to process...why is that?

Maybe these lines have something to do with that?

I don't get it. On Nano 33 BLE those pins are an available hardware serial port. Why are you using Software Serial?

its not nano 33 ble.....normal nano with hc05

it works with a generic btt app but not mine

Can you see why I thought it was a nano 33 ble?

See post #3

@Abeer_goel This is a technical forum. To get best out of it, you need to provide clear, concise technical information. That starts with, but is not limited to, a schematic, exact product identifications, and complete software listings that you update as changes are made. There is no other way to answer your questions or help you with deficiencies. You limit your chances of success when inconsistent details are sprinkled throughout your posts. Please provide a summary of the current state of affairs, addressing those needs.

Hey @6v6gt @cloudDev @PaulRB @camsysca @red_car sorry for disturbance....i made a stupid mistake in code of the, first display, then app.....this is actually a ____ ________ _______ pda for ________
......im in a inter-state comp.....thnks

Never mind. If you have any questions, please feel free to contact us again!

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