Project tutorial

$5 Nokia Serial Terminal Display

Nokia 5110 and Arduino mini make a great serial monitor that can easily be battery powered at 3 Volts.

  • 9,983 views
  • 2 comments
  • 12 respects

Components and supplies

About this project

Overview of project

I have found myself on several occasions away from a PC but needing a small serial Terminal / monitor to view the start-up diagnostics of one of my projects; the traditional boot-up health check.  It is routine for me, after the main project is constructed and working, to add a little diagnostic code which uses the on board serial interface of Atmel chips such as the Atmega328P found in Uno, Mini, Mini Pro.  Also, this is applicable to the Nano, Teensy, and 32u4 products from Adafruit and Sparkfun.  If your project can afford the overhead of the extra code and the light demands of the serial output on the internal UART, then there is little concern for using the serial output.

I constructed this project from Chinese parts which totaled:
Mini Pro 328: ... $2.88 ea     (delivered in Qty 5)
Nokia 5110:   ....$2.61 ea     (delivered in Qty 5)
Total cost for 5 units including shipping: $27.41Price each:  ...   $5.48

I will give equivalent links to U.S. power houses that stock similar items and stand-by-them with support and replacement guarantees:
Adafruit: $10.00Nokia 5110: http://www.adafruit.com/products/338 Sparkfun: $9.95Pro Mini 328 3.3V: https://www.sparkfun.com/products/11114

To test my portable 3V self-contained serial 9600 BAUD terminal, I connected 2 AAA batteries and a 3.3V GPS with 9600 BAUD output.  The success is seen in the lead-in picture and the YouTube video to the right.

The code is simple and you can extend it.  It only manages newlines and carriage returns at the moment along with numerals and upper/lower case.  But it is a hack... and happily, it is totally open source and hack-able by you.

Text-based electrical connections are listed in the Defines.h file of the ZIP, but the connections are identical to the Nokia display in my project: http://www.hackster.io/rayburne/magic-morse-on-arduino  so you can use the Fritzing diagrams there if you prefer.

Have fun!

Ray

Source code for main program routine

NokiaTest1.ino
Source code for main program routine

Warning: Embedding code files within the project story has been deprecated. To edit this file or add more files, go to the "Software" tab. To remove this file from the story, click on it to trigger the context menu, then click the trash can button (this won't delete it from the "Software" tab).

/*

  This implementation specific to Arduino Mini-Pro 328 running at 3.3V

  and used with a NOKIA 5110 Craphic LCD.



  Built under Arduino 1.0.5

*/



#include <EEPROM.h>

#include <Streaming.h>

#include "Defines.h"                // Nokia 5110 LCD pin usage as controlled by "ScrnFuncts.ino"



// constants

const int  BAUD            = 9600;  // any standard serial value: 300 - 115200

const int  EEaddr          = 0;     // EEPROM address for storing WPM

const int  EEaddr1         = 2;     // EEPROM address for LCD address

// Arduino 328P pins (not physical)



const byte ContrastPin     = 8;     // D8 low activates the Contrast adjustment



// global prog variables



byte nRow;                          // line count      (0-5 for NOKIA LCD)

byte nColumn;                       // character count (0-11 for NOKIA LCD)

byte NOKIAcontrast;                 // LCD initialization contrast values B0 thru BF



char temp;



// Character array pointers

char* PROGMEM msg0[]       = {"TerminalTest(C)2014 by  M. Burnette                         Ver 0.000000"}; // 72 characters == full screen

char* PROGMEM msg1[]       = {"The quick   Brown Fox   Jumps over  The Lazy DogBack        Press ENTER "};

char* PROGMEM BlankLine[]  = {"            "};  // Nokia 12 x 6 (84 * 48)





void setup(void)

  { 



    pinMode(ContrastPin, INPUT);

    digitalWrite(ContrastPin, HIGH); // activate internal pullup resistor





    Serial.begin(BAUD);

    Serial << (F("(c) 2013 - 2014 by M. R. Burnette")) << endl;

    Serial << (F("Free RAM available: ")) ;

    Serial << freeRam() << endl;

    Serial << (F("Version 0.20140126")) << endl;

    ReStart:  // Come back here if LCD contract is changed

    // Read the EEPROM to determine if display is using a custom contrast value

    NOKIAcontrast = EEPROM.read(EEaddr1);

    // Set the Nokia LCD Contrast to default or reset if EEPROM is corrupt or set to new value

    if (NOKIAcontrast  < 0xB0 || NOKIAcontrast > 0xBF) NOKIAcontrast = 0xB2;

    // LCD

    LcdInitialise();

    LcdClear();

    LcdString(*msg0);

    delay(2000);

    if (!digitalRead(ContrastPin)) {

        NOKIAcontrast++;

        if (NOKIAcontrast > 0xBF) NOKIAcontrast = 0xB0;

        EEPROM.write(EEaddr1, NOKIAcontrast);

        goto ReStart;

    }

    // Set WPM default and write to EEPROM IF Morse Key is closed at this point...



    LcdClear(); delay(500); nRow = 1;

    LcdString(*msg1);

    nRow = 0; nColumn = 0;

    gotoXY(nColumn, nRow);

    do {} while (Serial.available() == 0) ;

    LcdClear();  // nRow = 0; nColumn = 0 done by function LcdClear()

}





void loop(void)

{

    if (Serial.available() > 0)

    {

      char temp = Serial.read();

      Serial << temp;  // for diagnostic and Arduino term echo

      switch (temp)

        {

          case '\n' :

            ++nRow; nColumn = 0;

            if (nRow == 6) nRow = 0;

            LcdString(BlankLine[0]);  // clear line



          case '\r' :

            ++nRow; nColumn = 0;

            if (nRow == 6) nRow = 0;

            LcdString(BlankLine[0]);  // clear line



          default :

            gotoXY(nColumn, nRow);

            if (temp > 31 && temp < 128) SendCharLCD(temp);

            if (nColumn == 0 ) LcdString(BlankLine[0]);  // clear new line

        }

    }

}

Source ZIP (see Defines.h for electrical connections)

A note about 3.3V input to the Arduino

A 3 Volt Arduino allows for direct connection to 3 Volt devices such as the GPS I used as an example and it makes driving the 3V Nokia display a breeze.

But, if your serial line is 5 Volts, you will need to down convert the logic level to use on your 3V mini-terminal. There are many considerations and the topic is too convoluted (too many opinions) for me to explain everything here.  So, educate yourself and select something appropriate for what you intend on doing:
https://www.google.com/#q=5V+to+3V+serial+input+step+down

Arduino mini 328 and Nokia 5110

Terminal View 2

Littl' terminal in action displaying 9600 BAUD from GPS

A note about contrast...

One of the biggest PITA about the Nokia 5110 is that every one seems to have a different contrast requirements.  This essentially is just a line in the code that sets a register in the Nokia controller... but, unless you set this correctly, you may have no display to full dark display and it is ambient temperature sensitive.

So, I hacked a simple routine to allow you cycle through all of the possibilities and then when things look the best to you, pull the jumper and the value is written to EEPROM and used afterwards.  If you plan on taking this out and about where temperatures will vary this becomes a requirement.

To calibrate your display, power the unit off, connect a jumper from Gnd to Arduino Pin D8 and power on the unit.  Allow it to cycle once or twice for you to get an idea of what the best display value will provide.  Then as the display cycles around again, just pull the wire on Pin D8 when the display looks the best.  The value is written to EEPROM and the program restarts and uses that value.

You may wish to consider using this routine in all of your Nokia 5110 projects!  You may also wish to connect a small push button switch (like Reset) so that you can use a small stylus and set this anytime you desire.

Ray

When installed correctly, you see multiple TABS


Code

NokiaTest1.inoPlain text
NokiaTest1.ino
/*

  This implementation specific to Arduino Mini-Pro 328 running at 3.3V

  and used with a NOKIA 5110 Craphic LCD.



  Built under Arduino 1.0.5

*/



#include <EEPROM.h>

#include <Streaming.h>

#include "Defines.h"                // Nokia 5110 LCD pin usage as controlled by "ScrnFuncts.ino"



// constants

const int  BAUD            = 9600;  // any standard serial value: 300 - 115200

const int  EEaddr          = 0;     // EEPROM address for storing WPM

const int  EEaddr1         = 2;     // EEPROM address for LCD address

// Arduino 328P pins (not physical)



const byte ContrastPin     = 8;     // D8 low activates the Contrast adjustment



// global prog variables



byte nRow;                          // line count      (0-5 for NOKIA LCD)

byte nColumn;                       // character count (0-11 for NOKIA LCD)

byte NOKIAcontrast;                 // LCD initialization contrast values B0 thru BF



char temp;



// Character array pointers

char* PROGMEM msg0[]       = {"TerminalTest(C)2014 by  M. Burnette                         Ver 0.000000"}; // 72 characters == full screen

char* PROGMEM msg1[]       = {"The quick   Brown Fox   Jumps over  The Lazy DogBack        Press ENTER "};

char* PROGMEM BlankLine[]  = {"            "};  // Nokia 12 x 6 (84 * 48)





void setup(void)

  { 



    pinMode(ContrastPin, INPUT);

    digitalWrite(ContrastPin, HIGH); // activate internal pullup resistor





    Serial.begin(BAUD);

    Serial << (F("(c) 2013 - 2014 by M. R. Burnette")) << endl;

    Serial << (F("Free RAM available: ")) ;

    Serial << freeRam() << endl;

    Serial << (F("Version 0.20140126")) << endl;

    ReStart:  // Come back here if LCD contract is changed

    // Read the EEPROM to determine if display is using a custom contrast value

    NOKIAcontrast = EEPROM.read(EEaddr1);

    // Set the Nokia LCD Contrast to default or reset if EEPROM is corrupt or set to new value

    if (NOKIAcontrast  < 0xB0 || NOKIAcontrast > 0xBF) NOKIAcontrast = 0xB2;

    // LCD

    LcdInitialise();

    LcdClear();

    LcdString(*msg0);

    delay(2000);

    if (!digitalRead(ContrastPin)) {

        NOKIAcontrast++;

        if (NOKIAcontrast > 0xBF) NOKIAcontrast = 0xB0;

        EEPROM.write(EEaddr1, NOKIAcontrast);

        goto ReStart;

    }

    // Set WPM default and write to EEPROM IF Morse Key is closed at this point...



    LcdClear(); delay(500); nRow = 1;

    LcdString(*msg1);

    nRow = 0; nColumn = 0;

    gotoXY(nColumn, nRow);

    do {} while (Serial.available() == 0) ;

    LcdClear();  // nRow = 0; nColumn = 0 done by function LcdClear()

}





void loop(void)

{

    if (Serial.available() > 0)

    {

      char temp = Serial.read();

      Serial << temp;  // for diagnostic and Arduino term echo

      switch (temp)

        {

          case '\n' :

            ++nRow; nColumn = 0;

            if (nRow == 6) nRow = 0;

            LcdString(BlankLine[0]);  // clear line



          case '\r' :

            ++nRow; nColumn = 0;

            if (nRow == 6) nRow = 0;

            LcdString(BlankLine[0]);  // clear line



          default :

            gotoXY(nColumn, nRow);

            if (temp > 31 && temp < 128) SendCharLCD(temp);

            if (nColumn == 0 ) LcdString(BlankLine[0]);  // clear new line

        }

    }

}

Comments

Similar projects you might like

Picture The Weather

Project tutorial by Windows IoT

  • 31,031 views
  • 23 comments
  • 89 respects

WiFi Weather Station

Project in progress by Dan Fein

  • 17,239 views
  • 15 comments
  • 44 respects

Toothbrush machine

Project tutorial by Simone

  • 7,543 views
  • 8 comments
  • 67 respects

Arduino and Android Based Bluetooth Password Lock

Project tutorial by Md. Khairul Alam

  • 10,772 views
  • 7 comments
  • 26 respects

LED Drawing with Virtual Shields

Project tutorial by Windows IoT Maker

  • 5,022 views
  • 4 comments
  • 25 respects

MatrixClock

Project showcase by Mark Wilson

  • 3,266 views
  • 8 comments
  • 8 respects
Add projectSign up / Login