본문 바로가기

카테고리 없음

St7920 Serial Code

(17) 128×64 graphic LCD display: temperature and humidity A 128×64 graphic LCD display with ST7920 controller for the Arduino, displaying temperature and relative humidityby Floris Wouterlood – The Netherlands – August 11, 2017SummaryGraphic 128×64 LCD displays are based on (monochrome) LCD technology, yet they offer interesting graphical capabilities because every pixel is individually addressable. These displays are more complicated to program than the ‘common’ 16×2 or 20×4 LCD displays that present two or four rows of fixed character positions.

  1. St7920 Serial Code Generator
  2. Persona Sims 3
  3. St7920 Serial Code Lookup

The payoff is presentation with considerable flexibility thanks to the existence of built-in characters and, in software for the Arduino, an extensive u8g graphics library, i.e., the same library that supports display of graphics on OLED displays. Here we discuss the wiring of a ST7920 based 128×64 graphical 12864B LCD breakout display. This display is used to present data collected with a Dallas DS18B20 temperature sensor and a DHT11 relative humidity sensor.IntroductionOne of the solutions to display data collected with sensors attached to an Arduino microcontroller board is via a graphic 128×64 LCD display (Figure 1). Because the pixels are neatly arranged in 128 columns, 64 rows where every individual pixel is addressable these displays offer graphic capabilities where even images can be displayed (of course in monochrome). In this paper we discuss a very common type of 128×64 LCD display breakout based on the ST7920 controller. In spite of the impressive 20 pins that decorate this board only three pins of an Arduino are essential to make the display work, that is: in SPI mode.

This modest ‘pin requirement’ makes the ST7920 display attractive for use in Arduino projects where other pins need to be reserved for all kinds of peripheral devices and actions. The screens are in vertical direction twice as big as 20×4 LCD displays so they offer good readability. The u8g library written by Oliver Kraus (‘Olikraus’) offers a selection of graphic functions, special characters and text fonts which makes the use of this kind of display extra attractive.Electronics and supplies1x Arduino Uno microcontroller board, breadboard, Dupont jumper wires, 128×64 ST 7920 based LCD display breakout board, 1x 10 kΩ potentiometer, 1x 220 Ω resistor. Additional: 1x DHT11 temperature/ relative humidity sensor, 1x Dallas DS18B20 temperature sensor, 1 x 10kΩ resistor, 1x 4.7 k10kΩ resistor.WiringThe LCD display breakout board has 20 pins for connectivity, labeled GND, VCC, V0, RS, R/W, E, DB0, DB1, DB2, DB3, DB4, DB5, DB6, DB7, PSB, NC, RST, VOUT, BLA and BLK.Figure 1 shows the basic connectivity via the SPI interface (SPI stands for Serial Peripheral Interface).

St7920 Serial Code Generator

GND is wired to GND of the Arduino, 5V to 5V, V0 to the wiper of a 10kΩ potentiometer (this is to adapt the contrast between characters or graphics of the LCD against the background), RS to pin 12, R/W to pin 11 and E to pin 13. The DB0 through DB7 pins of the breakout board need to be connected only if parallel mode is considered. PSB is connected to ground, while BLA needs 3.3V (background LED light of the LCD display) and BLK needs connection to GND. BLA can be connected to the 5V pin of the Arduino with a 220Ω resistor in series to reduce the voltage, or it can be connected directly to the 3.3V pin of the Arduino.Confusion in nomenclatureWhile SPI protocols work with pins marked MISO, MOSI, CLK and CS, the ST7920 breakout board has completely different pin designations while it supports the SPI protocol. MISO and MOSI are necessary for master/slave mode and do not matter in the present construction. CLK (clock) and CS (chip select) are necessary and so are the data pin (R/W) and the pin marked PSB (the latter needs to be connected to GND – pin set continuously LOW to inform the display’s controller chip that it should work in serial mode (PSB HIGH means parallel mode).Summarized: SPI’s CLK is supported by pin ‘E’ on the display breakout board, data is supported by pin ‘R/W’ and Chip Select by pin ‘CS’. PSB should be connected to GND and the wires to GND, VCC, VD, BLA and BLK supply power to the display breakout and regulate background light and contrast of pixels versus background.Flexibility of pin selectionSPI is not hardware mapped, i.e., the protocol does not require specific pins of the Arduino.

However, the pins of the Arduino used to connect CLK, data and CS need to be declared in the display constructor (see below). Use of different pins is allowed as long as they are correctly declared in the display constructor, e.g. Pins 2, 3 and 4.Sensors and their connectivityA Dallas DS18B20 is an accurate temperature sensor that has three wires: 5V, GND and DATA. The DATA wire can be connected to an Arduino pin of choice; in this example pin 6 (Figure 2).

Code

Persona Sims 3

A DHT 11 has four pins of which (seen from the front, from left to right, Fig. 2) the first pin needs to be connected with 5V, the second is DATA, in this example connected to pin 8 of the Arduino, the third pin is not connected while the fourth pin needs GND. While a DHT provides both relative humidity and temperature, the accuracy of a Dallas DS18B20 is much better.

St7920 Serial Code Lookup

Code

Apart from that this article was written to show that readings from two completely different sensors can easily be displayed on this LCD display. Note the pull up resistors that are necessary to get ‘clean’ data signals from the sensors.Figure 2: Wiring of the LCD display breakout board is the same as in Figure 1, but now sensors have been connected to the Arduino: a Dallas DS18B20 – indicated with the pink circle, and a DHT 11 temperature/relative humidity sensor. Both sensors require for data relay only one pin of the Arduino (and of course 5V and GND).

Note that all data: temperature and humidity of the DHT is transmitted via the DATA wire (colored white). Both sensors need a pull-up resistor: the DS18B20 won’t function without a 4.7 kΩ resistor while the DHT11 needs a 10 kΩ pull-up resistorSketch – notesThe sketch that provide all instructions to the Arduino makes use of the u8g library written by Oliver Kraus (nickname on the Arduino forum ‘Olikraus’).