Go Down

Topic: Sainsmart LCD 16x2 I2C alongside LCDSmartie for realtime temperature monitoring (Read 3316 times) previous topic - next topic

L15T3R

Hi, im new to the Arduino Uno R3 just received it along with a sainsmart lcd 16x2 screen.
I credit the wiring and I2C address finding to this thread.
http://forum.arduino.cc/index.php/topic,128635.0.html

This is the code used from yourduino.com.

Code: [Select]
/* YourDuino.com Example Software Sketch
16 character 2 line I2C Display
Backpack Interface labelled "YwRobot Arduino LCM1602 IIC V1"
terry@yourduino.com */

/*-----( Import needed libraries )-----*/
#include <Wire.h>  // Comes with Arduino IDE
// Get the LCD I2C Library here:
// https://bitbucket.org/fmalpartida/new-liquidcrystal/downloads
// Move any other LCD libraries to another folder or delete them
// See Library "Docs" folder for possible commands etc.
#include <LiquidCrystal_I2C.h>
#include <LiquidCrystal.h>

/*-----( Declare Constants )-----*/
/*-----( Declare objects )-----*/
// set the LCD address to 0x27 for a 20 chars 4 line display
// Set the pins on the I2C chip used for LCD connections:
//                    addr, en,rw,rs,d4,d5,d6,d7,bl,blpol
LiquidCrystal_I2C lcd(0x3F, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);  // Set the LCD I2C address

/*-----( Declare Variables )-----*/
//None

void setup()   /*----( SETUP: RUNS ONCE )----*/
{
  Serial.begin(19200);  // Used to type in characters

  lcd.begin(16,2);   // initialize the lcd for 16 chars 2 lines, turn on backlight

// ------- Quick 3 blinks of backlight  -------------
  for(int i = 0; i< 1; i++)
  {
    lcd.backlight();
    delay(250);
    lcd.noBacklight();
    delay(250);
  }
  lcd.backlight(); // finish with backlight on 

//-------- Write characters on the display ------------------
// NOTE: Cursor Position: (CHAR, LINE) start at 0 
  lcd.setCursor(2,0); //Start at character 4 on line 0
  lcd.print("Hello Chris!");
  delay(1000);
  lcd.setCursor(2,1);
  lcd.print("> PC is On <");
  delay(1000); 
 
}/*--(end setup )---*/

void loop()   /*----( LOOP: RUNS CONSTANTLY )----*/
{
  {
    // when characters arrive over the serial port...
    if (Serial.available()) {
      // wait a bit for the entire message to arrive
      delay(100);
      // clear the screen
      lcd.clear();
      // read all the available characters
      while (Serial.available() > 0) {
        // display each character to the LCD
        lcd.write(Serial.read());
      }
    }
  }

}/* --(end main loop )-- */


/* ( THE END ) */


My Project
Basically what im trying to do is create a realtime monitoring screen to see the temperatures of my cpu and gpu while im gaming at high intensity.

My Problem
I have wired the LCD to the Arduino and have used code that will output characters from the serial monitor.
LCDSmartie outputs to the serial monitor from what i gather using matrix.dll.
http://lcdsmartie.sourceforge.net

So when i get it all talking and LCDSmartie outputs i get a G and what looks like 2 blocks before anything displaying?
Here are the pictures



Can anyone help? Am i doing something wrong?

Thanks Chris

floresta

You typically get characters like that (the two characters between the 'G' and the 'CPU' when you send carriage return <CR> and/or line feed <LF> codes to the LCD. 

These codes, which are 0x0D and 0x0A, correspond to the foldback (redundant) addresses for the custom characters at 0x05 and 0x02.  If you can't avoid sending those codes then you are going to have to generate 'blank' custom characters for those two positions.

There was a relatively recent post where this was explained, I'll see if I can find it.


Don

L15T3R

Thanks for the reply!
So what your saying is that LCDSmartie is actually sending those characters to the serial and the LCD is just printing them as its put out?
So i have have to somehow modify how LCDSmartie outputs the data its sending to the Arduino?
Or am i able to rectify this with code on the arduino?

Thanks Chris

floresta

Quote
So what your saying is that LCDSmartie is actually sending those characters to the serial and the LCD is just printing them as its put out?


It certainly looks like that is what is happening.

The only reason I would question this is why.  The LCDsmartie program is designed to send information to LCDs using HD44780 type controllers.  Those controllers do not interpret the <CR> and <LF> control codes the way serial CRT do so, in my opinion, they never should be sent out by LCDsmartie.


Quote
So i have have to somehow modify how LCDSmartie outputs the data its sending to the Arduino?


That would be a possibility since the program appears to be open source.  Perhaps someone has already done this, have you checked all of the plug-ins?

Quote
Or am i able to rectify this with code on the arduino?


Yes.  I already mentioned one way, by programming two of the 'custom characters'.  I haven't been able to locate the previous thread where this was discussed.

You could also intercept the data between the Serial.read and the LCD.write and filter out the unwanted codes.


Don

cattledog

Quote
You could also intercept the data between the Serial.read and the LCD.write and filter out the unwanted codes.

Don



This would be the way to go. You can filter out all non ASCII characters from the Serial read with  "if char <32".

Now where is the "G" coming from? Its ASCII character 71.

Go Up