Example Code for Arduino-Character Overlay

Last revision 2026/01/14

This article guides you through implementing character overlay on Arduino using FireBeetle ESP32 and OSD Character Overlay Module, detailing hardware/software setup, wiring, and code examples for custom character and string display.

Hardware Preparation

Software Preparation

Wiring Diagram

DFR0515-Wiring Diagram

Other Preparation Work

1. Operation Steps

  • Connect OSD Character Overlay Module to FireBeetle-ESP32 according to the connection diagram and turn on the OSD dial switch (D3 at here).
  • Connect camera and display to OSD Character Overlay Module according to the connection diagram.
  • Connect FireBeetle-ESP32 to PC with USD wire and open Arduino IDE.

NOTE: cs variable is chip select pin and it must be respond to dial switch. E.g. Dial switch D3 respond to IO26 of FireBeetle-ESP32. Here the CS is D3.

2. EEPROM Character Library

DFR0515-EEPROM Character Library

DFR0515-EEPROM Character Library 1

3. Matrix Software Guide

  1. Click option button.
    DFR0515-Matrix software 1
  2. Select options as follows: Padding Removal, Line wrap, Byte.
    DFR0515-Matrix software 2
  3. Input content to the left edit box, click Generate to get matrix.
    DFR0515-Matrix software 3

Sample Code

Below is the FireBeetle DFRobot_OSD sample code. Please ensure CS is respond to CS pin.

Initialize OSD module, display custom Chinese chars, chars & specified strings.

/*!
  * file DFRobot_OSD.ino
  * character superimposition.
  * @n This example Set characters on the screen.
  *
  * Copyright   [DFRobot](https://www.dfrobot.com), 2016
  * Copyright   GNU Lesser General Public License
  *
  * version  V1.0
  * date  2017-10-9
  */

#include <DFRobot_OSD.h>

/*select CS pin*/
#ifdef __AVR__
int cs = 3;
#elif defined ESP_PLATFORM
int cs = D3;
#elif defined __ets__
int cs = D3;
#else
  #error unknow board
#endif

DFRobot_OSD osd(cs);

/*Define Chinese characters*/

int buf0[36] = {0x00,0x00,0x40,0x01,0x40,0x02,0x40,0x03,0xFC,0x07,0x44,0x00,0x44,0x02,0x44,0x02,0x7C,0x02,0x94,0x02,0x94,0x01,0x92,0x01,0x12,0x01,0x9A,0x05,0x52,0x06,0x22,0x04,0x00,0x00,0x00,0x00};
int buf1[36] = {0x08,0x00,0x08,0x00,0xC8,0x07,0xBC,0x04,0xA8,0x02,0x98,0x02,0xFE,0x02,0x88,0x02,0x8C,0x02,0xB4,0x04,0xA6,0x04,0xBC,0x04,0xA4,0x04,0xA4,0x06,0xBC,0x00,0x84,0x00,0x00,0x00,0x00,0x00};
int buf2[36] = {0x00,0x00,0x04,0x02,0xC4,0x03,0x44,0x02,0x5E,0x01,0x44,0x01,0x44,0x05,0xCC,0x06,0x76,0x02,0x76,0x02,0xA6,0x02,0xA6,0x01,0x24,0x01,0x94,0x01,0x54,0x02,0x24,0x04,0x00,0x00,0x00,0x00};
int buf3[36] = {0x00,0x00,0x04,0x00,0xF4,0x01,0xAC,0x00,0xB4,0x07,0xA4,0x04,0xF4,0x05,0xAE,0x03,0xA4,0x02,0xE6,0x02,0xBA,0x06,0xE6,0x05,0xA6,0x01,0x86,0x00,0x89,0x00,0xF1,0x07,0x00,0x00,0x00,0x00};

void setup(){
  osd.init();
  osd.clear();

  /* Write the custom character to the OSD, replacing the original character*/
  /* Expand 0xe0 to 0x0e0, the high 8 bits indicate page number and the low 8 bits indicate the inpage address.*/
  osd.storeChar(0xe0,buf0);
  osd.storeChar(0xe1,buf1);
  osd.storeChar(0xe2,buf2);
  osd.storeChar(0xe3,buf3);

  /*Displays custom characters*/
  osd.displayChar(2,2,0xe0);
  osd.displayChar(2,3,0xe1);
  osd.displayChar(2,4,0xe2);
  osd.displayChar(2,5,0xe3);

  /*display character*/
  osd.displayChar(9,9,0x11d);
  osd.displayChar(9,10,0x11e);
  osd.displayChar(8,11,0x10f);

  /*display String*/
  const char* str1 = "DFRobot";
  String str2 = "2017.9.12";

  osd.displayString(14,21,str1);
  osd.displayString(2,19,str2);
  osd.displayString(4,2,"hello world!");

}

void loop(){

}

Result

OSD screen static displays custom Chinese chars, chars & multiple strings permanently.

DFR0515-Result

Was this article helpful?

TOP