SainSmart LCD Shield question

Hey guys! I'm somewhat new to the Arduino. I have the Uno. I'm working on making a thermostat. I have a digital humidity and temp sensor (DHT11) hooked up on my breadboard. I can read humidity and temp just fine plugged up to D2 pin on the Uno. But now I'm using the sainsmart LCD keypad shield 1602 and can't get a read from the DHT11. I think I'm reading the shield pinouts correctly. I'll post the pinout. If I could get confirmation that I'm using the correct pin on the LCD shield I'd appreciate it! I'm using pin 5 on J5.

Also, in my program I just need to define the input pin on the uno not on the shield, correct? As I understand it the shield just pulls the pins up from the Uno.

Thank you for you time!

But now I'm using the sainsmart LCD keypad shield 1602 and can't get a read from the DHT11.

I hope you are not using the LCD4Bit library recommended by Sainsmart. If you are then try switching to the LiquidCrystal library supplied with the IDE. You will need to invoke it with:

//LiquidCrystal lcd(RS, E, D4, D5, D6, D7);
LiquidCrystal lcd(8, 9, 4, 5, 6, 7);      // use these values with the Sainsmart Keypad Shield

As I understand it the shield just pulls the pins up from the Uno.

Correct. But you can't use any of the pins that are used by the devices on the shield. These are called out under 'Pin Allocation' in the readme.txt file and include pin 10 and Analog pin 0 in addition to the six pins mentioned above.

Don

floresta:
I hope you are not using the LCD4Bit library recommended by Sainsmart. If you are then try switching to the LiquidCrystal library supplied with the IDE. You will need to invoke it with:

//LiquidCrystal lcd(RS, E, D4, D5, D6, D7);

LiquidCrystal lcd(8, 9, 4, 5, 6, 7);      // use these values with the Sainsmart Keypad Shield

I am using the LiquidCrystal library. and I've invoked it with the correct pins. But I'm not even trying to write to the LCD yet. I just want to get the DHT to display its data in the serial monitor while I'm plugged up to the LCD shield. For now, I'm just trying to verify that data is getting to the shield and that I'm on the correct pin.

floresta:
Correct. But you can't use any of the pins that are used by the devices on the shield. These are called out under 'Pin Allocation' in the readme.txt file and include pin 10 and Analog pin 0 in addition to the six pins mentioned above.

Don

Ok I've verified that the D2 pin is not used by the LCD. Thank you for your reply, Don!

Why don't you give us some more information. You haven't mentioned a pull-up resistor for your sensor and you haven't told us what sketch you are using.

How did you read the temperature and the humidity before you tried using the LCD?

What does display on the LCD?
(a) Blank
(b) A row of boxes
(c) Incorrect data
(d) Hieroglyphics

Don

floresta:
Why don't you give us some more information. You haven't mentioned a pull-up resistor for your sensor and you haven't told us what sketch you are using.[/quote]

Sorry about that. I have a resistor connecting between the power pin and the data pin on the DHT11. I'm just using the sketch that came with the DHT11. I have added the liquidCrystal library and invoked the correct pins for the LCD.

floresta:
How did you read the temperature and the humidity before you tried using the LCD?[/quote]

I have the DHT11 on my breadboard. power and ground on the arduino running to the power and ground rails on my breadboard. Then, ran the data pin to D2 pin on the arduino. And just did a Serial.println() of my variables. And checked I was getting accurate data in the serial monitor. So I just assumed that all I had to do is run power, ground and data to the corresponding pins on the shield and I should still see data coming through the Serial monitor.

floresta:
What does display on the LCD?
(a) Blank
(b) A row of boxes
(c) Incorrect data
(d) Hieroglyphics

Don

Just a row of boxes show on the LCD. But I'm not trying to write the data to the LCD yet. I am trying to figure out why I'm not getting data pulled up to the shield. Just as a test I did an lcd.print() of my variable and the LCD is displaying the same result as when I used Serial.println(). The sensor is just returning the value 0.00.

Again, I keep everything the same, remove the LCD shield and plug directly into the arduino and I get correct data.

Thank you! --Aaron

I just read the spec sheet. BTW, you should post this link, not one of us:

http://www.thesunrain.com/Amazon/LCDKeypad%20Shield/LCD1602.rar

The LCD is using 8,9,4,5,6,7. It is not using pin 2, which is what you use. You need to post some pictures. So the LCD is working, right?

I'm just using the sketch that came with the DHT11.

The contents of that sketch seem to have slipped my mind, could you perhaps let us know more about it?

Just a row of boxes show on the LCD.

That's not good.

But I'm not trying to write the data to the LCD yet.

That's good, because you won't succeed until you deal with the boxes.

I am trying to figure out why I'm not getting data pulled up to the shield. Just as a test I did an lcd.print() of my variable and the LCD is displaying the same result as when I used Serial.println(). The sensor is just returning the value 0.00.

I don't understand this. You claim that you are not trying to write data to the LCD yet you mention using lcd.print.

How about making sure that your sketch is still running when the shield is attached. Insert some code to blink an LED each time it makes a measurement and see if the LED still blinks with the shield attached.

Don

liudr:
I just read the spec sheet. BTW, you should post this link, not one of us:

http://www.thesunrain.com/Amazon/LCDKeypad%20Shield/LCD1602.rar

The LCD is using 8,9,4,5,6,7. It is not using pin 2, which is what you use. You need to post some pictures. So the LCD is working, right?

Sorry about that. I wasn't sure what all info to post. Correct the LCD does use those pins but the shield pulls the unused pins up to a header on the shield. That's why I was using pin 2 because it wasn't being used by the LCD.

Here are some pics. If you need more just let me know.

Not sure if you can tell in the pics but, the red wires are power from the shield to the breadboard rail and power from the rail to the power pin of the sensor. Black is ground from the shield to the rail and green is ground from the sensor to the rail. Yellow is the data pin to what I assume is pin 2 pulled up from the arduino.

And yes the LCD does work. As a test, just to see if I was getting the same data from Serial.println(), I did an lcd.print() and the LCD does display the same 0.00 I'm getting with the Serial monitor.

floresta:
The contents of that sketch seem to have slipped my mind, could you perhaps let us know more about it?

It was just a basic:

int sensePin = 2;
#define DHTTYPE DHT11

DHT dht(sensePin, DHTTYPE);

float h = dht.readHumidity();
float t = dht.readTemperature();

Serial.print(h);
Serial.print(t);

That's all I'm using.

floresta:
I am trying to figure out why I'm not getting data pulled up to the shield. Just as a test I did an lcd.print() of my variable and the LCD is displaying the same result as when I used Serial.println(). The sensor is just returning the value 0.00.[/quote]
I don't understand this. You claim that you are not trying to write data to the LCD yet you mention using lcd.print.

How about making sure that your sketch is still running when the shield is attached. Insert some code to blink an LED each time it makes a measurement and see if the LED still blinks with the shield attached.

Don
[/quote]

I was only printing to the LCD just to verify that I was getting the same data. I wasn't sure if I could even do a Serial.print() with the LCD shield attached.

The led thing is a good idea. I'll give that a shot. Thank you!

That's all I'm using.

No it's not - there's data on the LCD screen.

For each thing you try we need to see the entire sketch and a photograph of the resulting display.

Don

floresta:

That's all I'm using.

No it's not - there's data on the LCD screen.

For each thing you try we need to see the entire sketch and a photograph of the resulting display.

Don

That is all I'm using. I said I wrote to the LCD just as a quick test. Then I rem'd the lines out because my most basic problem is that I'm not getting data to the shield. But here is the entire sketch:

// Example testing sketch for various DHT humidity/temperature sensors
// Written by ladyada, public domain
//#include <LiquidCrystal.h>

int sensePin = 2;
#include "DHT.h"

//LiquidCrystal lcd(8, 9, 4, 5, 6, 7);

// Uncomment whatever type you're using!
#define DHTTYPE DHT11 // DHT 11
//#define DHTTYPE DHT22 // DHT 22 (AM2302)
//#define DHTTYPE DHT21 // DHT 21 (AM2301)

// Connect pin 1 (on the left) of the sensor to +5V
// Connect pin 2 of the sensor to whatever your DHTPIN is
// Connect pin 4 (on the right) of the sensor to GROUND
// Connect a 10K resistor from pin 2 (data) to pin 1 (power) of the sensor

DHT dht(sensePin, DHTTYPE);

void setup() {

Serial.begin(9600);
Serial.println("DHTxx test!");

dht.begin();
}

void loop() {
// Reading temperature or humidity takes about 250 milliseconds!
// Sensor readings may also be up to 2 seconds 'old' (its a very slow sensor)
float h = dht.readHumidity();
float t = dht.readTemperature();

//float temp = t * 9/5 + 32; //Convert *C to *F.

Serial.print("Humidity: ");
Serial.print(h);
Serial.print(" %\t");
Serial.print("Temperature: ");
Serial.print(t);
Serial.println(" *C");
}

Here are my results plugged up directly to the arduino:

Using the same sketch with the shield on here are the results:

So I think I've read the pinout on the shield wrong or something. I can't figure out what pin will pull data to the shield.

I haven't seen any documentation that shows which pin is which on the Sainsmart shield. What makes you think that you have your yellow wire in the correct place. If I were designing the shield I would have the pins on the shield directly above the corresponding pins on the underlying Arduino.

Don

floresta:
I haven't seen any documentation that shows which pin is which on the Sainsmart shield. What makes you think that you have your yellow wire in the correct place. If I were designing the shield I would have the pins on the shield directly above the corresponding pins on the underlying Arduino.

Don

Correct, I'm not sure if I'm on the correct pin or not. I asked if someone could help me to identify the correct pin and posted the pinout in my first post. Here is the complete pinout. I figured pin 5 (on J5) on the shield was the correct pin.

Any help is much appreciated! Thank you,

I asked if someone could help me to identify the correct pin ...

There is a difference between identifying the correct pin on a diagram and then finding it on the corresponding PC board. I have a feeling that you have not found it and this sad excuse for a schematic/wiring diagram is no help.

I figured pin 5 (on J5) on the shield was the correct pin.

I agree. What makes you think that you have your yellow wire in the correct place.

Don

floresta:
There is a difference between identifying the correct pin on a diagram and then finding it on the corresponding PC board. I have a feeling that you have not found it and this sad excuse for a schematic/wiring diagram is no help.

Ah ok. That was my problem. I was relying on the schematics. I don't know why I didn't just grab the multimeter and check continuity on the pin in the first place. I guess I just had a one-track mind. I'm now on the correct pin. Thank you! And sorry for the hassle! :slight_smile:

So which one turned out to be the correct pin?