Go Down

Topic: Issue with Sainsmart 1602 LCD Sheild and Adafruit Datalogging Sheild (Read 204 times) previous topic - next topic

wxmaking

Hello all,

I attempting to save weather data on the Adafruit Data logger shield: http://www.adafruit.com/products/1141 while displaying said data live on the Sainsmart 1602 LCD Shield, which is all currently being controlled by a Uno R3 board.

Individually between the two shields (so only one is attached to the Arduino Uno board) I can get both to work, but when I stack them together I experience a issue with the LCD shield. The LCD stays in the no data blank stat throughout the whole run of the sketch, and will flicker every time the data logger shield flashes its red LED which indicates data was written to the SD card. Here is the sketch that is loaded onto the Uno:

--------------------------------------------------------------------------------------------------
Code: [Select]
//code used to print and save weather data, combines code from SD data logger test and LCD display Test.
//Started on 12-10-14

#include <Wire.h>     //I2C comunication library
#include "RTClib.h"  //Real time clock library, downloaded
#include <SD.h>      //SD library
#include <LiquidCrystal.h>  //LCD library

int tmp102Address = 0x48;  //Temp sensor Hex address
RTC_DS1307 RTC;            //Address from the RTC library
const int chipSelect = 10;  //chip selection pin for SD car
LiquidCrystal lcd(8,9,4,5,6,7);  //pins used for controlling LCD display
//File logfile;

void setup(){
 //Start up everything
 lcd.begin(16,2);
 Wire.begin();
 Serial.begin(9600);
 RTC.begin();
 pinMode(10, OUTPUT);
 //check SD car is working properly
 if (!SD.begin(chipSelect)) {
   Serial.println("Card failed, or not present");
   // don't do anything more:
   return;
 }
 Serial.println("card initialized.");
}

void loop(){
 //Pull data and time and print to Serial communication, comment out serial communications once code is working
 DateTime now = RTC.now();
 Serial.print(now.year(), DEC);
 Serial.print('/');
 Serial.print(now.month(), DEC);
 Serial.print('/');
 Serial.print(now.day(), DEC);
 Serial.print(';');
 Serial.print(now.hour(), DEC);
 Serial.print(':');
 Serial.print(now.minute(), DEC);
 Serial.print(':');
 Serial.print(now.second(), DEC);
 Serial.print(';');

 //Pulls temp data from sensor than print to Serial communication, comment out serial communication once code is working
 float celsius = getTemperature();
 float fahrenheit = (1.8*celsius)+32;
 float kelvin = celsius + 273.15;
 Serial.print(fahrenheit);
 Serial.print('F');
 Serial.print(';');
 Serial.print(celsius);
 Serial.println('C');
 Serial.println(' ');
 
 //Print date, time, and data to SD card
 File dataFile = SD.open("temp.txt",FILE_WRITE);
 if (dataFile){
   dataFile.print(now.year(), DEC);
   dataFile.print('/');
   dataFile.print(now.month(), DEC);
   dataFile.print('/');
   dataFile.print(now.day(), DEC);
   dataFile.print(';');
   dataFile.print(now.hour(), DEC);
   dataFile.print(':');
   dataFile.print(now.minute(), DEC);
   dataFile.print(':');
   dataFile.print(now.second(), DEC);
   dataFile.print(';');

   dataFile.print(fahrenheit);
   dataFile.print(';');
   dataFile.println(celsius);
   dataFile.close();
 }
 else{
   Serial.println("error opening temp.txt");
 }
 
 //Print temp data to LCD display
 lcd.clear();
 lcd.print('Temp:');
 lcd.setCursor(0,2);
 lcd.print(celsius);
 lcd.setCursor(5,2);
 lcd.print('C');
 lcd.setCursor(9,2);
 lcd.print(fahrenheit);
 lcd.setCursor(15,2);
 lcd.print('F');
 //cycle ~10 seconds
 delay(10000);
}

 //function used to calculate temp using bineary math
 float getTemperature(){
 Wire.requestFrom(tmp102Address,2);

 byte MSB = Wire.read();
 byte LSB = Wire.read();

 int TemperatureSum = ((MSB << 8 ) | LSB) >> 4;

 float celsius = TemperatureSum*0.0625;
 return celsius;
}

--------------------------------------------------------------------------------------------------

The issue to me seems like I'm over lapping communication pins between the LCD display and the Data logger shield, but I have looked over this a dozen times and I do not see that as a issue. Also, if that was the case I would expect both shields to fail, not just one working and the other fails.

Anyone have a idea what is happening, I'm a bit lost here.

cattledog

I believe that there is a conflict on digital pin 10 which is the spi chip select for the data logger shield and the backlight control for the lcd button shield.

Quote
The LCD stays in the no data blank stat throughout the whole run of the sketch, and will flicker every time the data logger shield flashes its red LED
Can you confirm that the lcd is blank because the backlight is not on?

If this is the source of the problem, I think you are going to have to modify one or the other of the shields. I'm not sure which is the better way to go. On the lcd shield, if you don't turn the backlight on and off, you could disconnect pins 15/16 from the transistor and pin 10 backlight control and power them from jumper wires with a resistor. On the data logger shield you can cut the trace to pin 10 from the cs pad. Connect that pad to another pin, and then change the cs pin call in the sketch and maybe the library. If you Google around, you can find some documentation on that process.

But before you start hacking, let's confirm that the pin 10 conflict is the source of your problem.

floresta

Quote
... but when I stack them together I experience a issue with the LCD shield.
Obviously the LCD shield is on top.  You should verify that all of the pins needed to control the LCD are indeed carried through the Data Logger shield and that none of them are used by anything on that other shield.

You should try running a simple sketch like "Hello World" first with only the LCD shield and then with both shields stacked.

Also - please go back and edit your original post.  Highlight the part that is program code and then click on the 'code' icon (currently 7th from the right).

Don

wxmaking


Can you confirm that the lcd is blank because the backlight is not on?

The backlight is on, it only flickers off when the data logger shield light flickers to indicate data was written to the SD card. When I said blank I meant more like this: http://www.element14.com/community/servlet/JiveServlet/download/77476-113267/SAM_0294.JPG?01AD=3jdEcBP1BYGSnyExx7cCE_Q8Qq9fdgDmpSIUlBuYcuGMNYy_H0OoKtQ&01RI=02A67E301D7DB28&01NA=

Like the LCD display is ready to go, but waiting for information to display.

floresta

Quote
When I said blank I meant more like this: . . .
That is the classic display that you get when the LCD controller is not properly initialized.  This will occur if any of the six wires between the Arduino and the LCD are not connected.

In reply #2 I recommended "running a simple sketch like "Hello World" first with only the LCD shield and then with both shields stacked."  Have you done this?

Don

wxmaking

Correct I have done so. The LCD display itself will work perfectly fine with just the Arduino board, but will experience the issue when the SD shield is stacked in. This problem even occurs when there isn't any code that is executing anything on the SD shield.

floresta

In your first post you mentioned "the Sainsmart 1602 LCD Shield" but you didn't really identify the specific shield.

Theoretically the LCD shield should operate correctly since none of the pins used by the LCD controller are also used by the data logger shield.

But - and it's a big but, it seems that you may be using the Sainsmart 1602 LCD Keypad Shield which is a whole different story.

As mentioned by cattledog in reply #1 this combination does indeed have a conflict since pin 10 is used by the LCD backlight.  This shouldn't normally have an effect on the LCD controller except that this is most likely one of the shields mentioned in the highlighted sticky post right at the beginning of this forum section titled Warning to users of some vendors LCD keypad shields..

So, if you do indeed have a LCD Keypad shield you should follow the recommendations in reply #1.

Don


cattledog

Quote
This problem even occurs when there isn't any code that is executing anything on the SD shield.
You can see the interaction with the backlight due to the pin 10 conflict when the Chip Select pin is addressed when writing to the data logging shield. But, I'm not certain that it is the cause of your blank LCD.

Since you know that the lcd works when the shield is mounted alone on the Uno, I would use a multimeter to try and determine if there is continuity from the pins/pads which are along the edge of the shield to the underlying pins on the UNO when the LCD shield is plugged into the data logging shield. Power should be off when you do this.

There is a little sliver of trace coming out from the sides of the female pin headers on the UNO which you should be able to get a probe on. Pay particular attention to the pins selected in your constructor, as well as the RW pin. which should be tied to ground. There should not be more than a few ohms top to bottom. Can you verify this?

Go Up
 


Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy