Nokia 5110 display replacement

Well, first the picture, outdoors midday sun, display using U8g2 library, 1.8” display;

This is the code for U8g2;

#include <SPI.h>
#include <U8g2lib.h>         // get library here > https://github.com/olikraus/u8g2
//view fonts here  > https://github.com/olikraus/u8g2/wiki/fntlistall

//comment in the display type below

//#define HCMODU0245         //2.4" LCD no backlight
#define HCMODU0246           //1.8" LCD with backlight   

#define DISPCS D15
#define DISPRST D14
#define DISPDC D16

#define SCK D8
#define MOSI D10
#define MISO D9

//ST7565 register names
#define BIASSELECT   0xA2
#define CONTRAST 0x81

//both these U8G2 drivers for the OpenSmart (ST7565) display work
//U8G2_ST7565_NHD_C12864_F_4W_HW_SPI u8g2(U8G2_R2, DISPCS, DISPDC, DISPRST);
U8G2_ST7565_JLX12864_F_4W_HW_SPI u8g2(U8G2_R2, DISPCS, DISPDC, DISPRST);

uint32_t StartmS, EndmS;


void loop()
{
  u8g2.setFont(u8g2_font_simple1_tf );              //7 pixel height, 8 lines of 23 characters

  StartmS = millis();
  u8g2.clearBuffer();                                //clear the internal memory
  u8g2.drawStr(0, 7, "Hello World!");
  u8g2.drawStr(0, 15, "Line1");
  u8g2.drawStr(0, 23, "Line2");
  u8g2.drawStr(0, 31, "Line3");
  u8g2.drawStr(0, 39, "Line4");
  u8g2.drawStr(0, 47, "Line5");
  u8g2.drawStr(0, 55, "Line6");
  u8g2.drawStr(0, 63, "01234567890123456789012");
  u8g2.sendBuffer();					                       //transfer internal memory to the display
  EndmS = millis();
  u8g2.setCursor(64, 35);
  u8g2.print(EndmS - StartmS);
  u8g2.print("mS");
  u8g2.sendBuffer();
  Serial.print("Screen write time ");
  Serial.print(EndmS - StartmS);
  Serial.println("mS");

  delay(2000);
  u8g2.clearDisplay();
  delay(1000);
}


void write_DisplayRegister(uint8_t reg, uint8_t regdata)
{
  //write register value to ST7565 display
  digitalWrite(DISPDC, LOW);                //set display DC low
  digitalWrite(DISPCS, LOW);                //set display CS low
  SPI.transfer(reg);                        //register address
  SPI.transfer(regdata);                    //register data
  digitalWrite(DISPCS, HIGH);               //set display CS high
}


void setup()
{
  Serial.begin(115200);
  Serial.println();
  Serial.println(__FILE__);
  Serial.println();

  SPI.begin(SCK, MISO, MOSI);

  u8g2.begin();

#ifdef HCMODU0245  //setup for 2.4"
  write_DisplayRegister(CONTRAST, 0x20);
#endif

#ifdef HCMODU0246  //setup for 1.8"
  write_DisplayRegister(CONTRAST, 0x0);
  write_DisplayRegister(BIASSELECT, 0xA3);
#endif
}

And this is for U8X8;

#include <SPI.h>

#define DISPCS D15
#define DISPRST D14
#define DISPDC D16

#define SCK D8
#define MOSI D10
#define MISO D9

//comment in the display type below

//#define HCMODU0245         //2.4" LCD no backlight
#define HCMODU0246  //1.8" LCD with backlight

#include <U8x8lib.h>  //get library here >  https://github.com/olikraus/u8g2

//ST7565 register names
#define BIASSELECT 0xA2
#define CONTRAST 0x81

//hardware SPI ST7565
U8X8_ST7565_64128N_4W_HW_SPI u8x8(DISPCS, DISPDC, DISPRST);
#define DEFAULTFONT u8x8_font_victoriabold8_r

uint16_t writecount;
uint32_t startwritemS, endwritemS, timemS;


void loop() {
  writecount++;
  Serial.print(writecount);
  Serial.print(F(" Writing to display"));
  startwritemS = millis();
  screen1();
  endwritemS = millis();
  timemS = endwritemS - startwritemS;
  u8x8.setCursor(8, 4);
  u8x8.print(timemS);
  u8x8.print(F("mS"));

  Serial.print(F(" - done "));
  Serial.print(timemS);
  Serial.println(F("mS"));
  delay(3000);
  u8x8.clear();
  delay(1000);
}


void screen1() {
  u8x8.clear();
  u8x8.setFlipMode(1);
  u8x8.setCursor(0, 0);
  u8x8.print(F("Hello World !"));
  u8x8.setCursor(0, 1);
  u8x8.print(F("Line 1"));
  u8x8.setCursor(0, 2);
  u8x8.print(F("Line 2"));
  u8x8.setCursor(0, 3);
  u8x8.print(F("Line 3"));
  u8x8.setCursor(0, 4);
  u8x8.print(F("Line 4"));
  u8x8.setCursor(0, 5);
  u8x8.print(F("Line 5"));
  u8x8.setCursor(0, 6);
  u8x8.print(F("Line 6"));
  u8x8.setCursor(0, 7);
  u8x8.print(F("0123456789012345"));  //display is 8 lines x 16
}


void write_DisplayRegister(uint8_t reg, uint8_t regdata) {
  //write register value to ST7565 display
  digitalWrite(DISPDC, LOW);   //set display DC low
  digitalWrite(DISPCS, LOW);   //set display CS low
  SPI.transfer(reg);           //register address
  SPI.transfer(regdata);       //register data
  digitalWrite(DISPCS, HIGH);  //set display CS high
}


void setup() {
  Serial.begin(115200);
  Serial.println(__FILE__);

  SPI.begin(SCK, MISO, MOSI);

  u8x8.begin();
  u8x8.setFont(DEFAULTFONT);

#ifdef HCMODU0245  //setup for 2.4"
  write_DisplayRegister(CONTRAST, 0x30);
#endif

#ifdef HCMODU0246  //setup for 1.8"
  write_DisplayRegister(CONTRAST, 0x0);
  write_DisplayRegister(BIASSELECT, 0xA3);
#endif
}

Can you share some about the hardware? I am guessing it's a LORA device. What is reason to not use the SEEED XIAO LORA daughter board.


Can you fill us in on the details of the register write?

I wanted a flexible handheld device, the module is a 868Mhz SX1262.

I have done quite a few plug in Mikrobus compatible PCBs for LoRa modules, RFM95, SX1262, SX1268, SX1280, E28 etc. The PCB can take a bare bones RFM95 or NiceRF SX1262 module too for a fixed setup, but being able to switch modules is handy.

Difficult to use the SEEED daughter board with a ESP32S3 Plus, which has the extra 9 GPIOs.

See the posted code, the registers have descriptive names.

Is that your own PCB or is it commercially available. I am interested in experimenting with LORA and that seems like a good tool for that.

Its my own PCB, just got it and going thru the testing.

The PCB is designed for the ESP32S3 Plus and NRF52840 Plus which have the extra 9 GPIOs. You can (yet to test) also fit standard XIAOs but you wont then be able to use the SD card, or the OpenSmart displays.

You can also fit a ST7789 colour TFT or 128x64 OLED.

A LoRa stuff is outdoors, so being able to hook up a outdoor visible display is good.

For some test programs, if your using the ESP32S3 you can display information on an Android phone via Bluetooth and they tend to be OK for outdoor stuff.

If the PCB is OK I will publish the Eagle files and Gerbers.

I would point out that there is now a range of ready built LoRa boards, such as those from Lilygo and Heltec, good for learning etc.

Due in part to the development of LoRa mesh applications such as Meshtastic there is also a range of 3D printed cases for these boards so you can have portable LoRa devices with batteries etc.

However these boards most often come with one of the 128x64 OLEDs fitted and these can be close to invisible in sunlight.