Go Down

Topic: SD and 16x2 LCD do not work together. (Read 2 times) previous topic - next topic



I am trying to log and display temperatures. I have a Duemilanove on a breadboard
with this SD card module http://www.ebay.de/itm/Neu-SD-Memory-Card-Module-Slot-Socket-SPI-Reader-For-Arduino-ARM-MCU-3-3V-5V-/261073492935?pt=Wissenschaftliche_Ger%C3%A4te&hash=item3cc9315bc7
and this display http://www.ebay.de/itm/5pcs-New-5v-1602-LCD-Display-Module-Blue-for-Arduino-2560-UNO-R3-ARV-STM32-ARM-/280928964351?pt=Bauteile&hash=item4168abceff

Now, the logging works. Always. The LCD, however, stops working as soon as as SD.begin is called and holds the last text displayed. Without line 59-67, the display works fine again (but of course, the logging does not). So, the wireing seems to be ok. I don't know where to start searching the problem ...

Code can be seen at http://pastebin.com/e7e4ASdU


I click your code link and I get:
Your request has been blocked by XXX Information Security

XXX blocks Web sites which contain inappropriate content, those that contain malicious code, and those that provide services that may be unsafe to the XXX network and or its resources.

Where XXX is my company.

Post your code, or, if it is too large, make a sample that just illustrates the problem. It should not take more than 9500 characters to illustrate the problem.


Strange. I mean, it's pastebin. Pretty standard ...

Code: [Select]
// -----------------------------------------------------------------

#include <OneWire.h>
#include <DallasTemperature.h>
#include <SPI.h>
#include <SD.h>

// Data wire is plugged into pin 7 on the Arduino
#define ONE_WIRE_BUS 7

// Setup a oneWire instance to communicate with any OneWire devices
// (not just Maxim/Dallas temperature ICs)
OneWire oneWire(ONE_WIRE_BUS);

// Pass our oneWire reference to Dallas Temperature.
DallasTemperature sensors(&oneWire);
float temperature = 0.0;

// -----------------------------------------------------------------

#include <LiquidCrystal.h>

// Connections:
// rs (LCD pin 4) to Arduino pin 12
// rw (LCD pin 5) to Arduino pin 11
// enable (LCD pin 6) to Arduino pin 10
// LCD pin 15 to Arduino pin 13
// LCD pins d4, d5, d6, d7 to Arduino pins 5, 4, 3, 2
LiquidCrystal lcd(12, 11, 10, 5, 4, 3, 2);

int backLight = 13;    // pin 13 will control the backlight

// -----------------------------------------------------------------

//SD card
const int sdPin = 9;
File logFile;

// -----------------------------------------------------------------

void setup(void)
  // start serial port
  Serial.println("Dallas Temperature IC Control");
  // Start up the library
  pinMode(backLight, OUTPUT);
  digitalWrite(backLight, HIGH); // turn backlight on. Replace 'HIGH' with 'LOW' to turn it off.
  lcd.begin(16,2);              // columns, rows.  use 16,2 for a 16x2 LCD, etc.
  lcd.clear();                  // start with a blank screen
  lcd.setCursor(0,0);           // set cursor to column 0, row 0 (the first row)
  lcd.print("Dallas Temperature IC Control");    // change this text to whatever you like. keep it clean.
  lcd.setCursor(0,1);           // set cursor to column 0, row 1
  if(!SD.begin(sdPin)) {
    Serial.println("Failed to initialize SD card");
//    lcd.setCursor(0,0);
//    lcd.println("Init SD failed  ");
  } else {
    Serial.println("SD initialized.");
//    lcd.setCursor(0,0);
//    lcd.println("Init SD success ");

void loop(void)
  // call sensors.requestTemperatures() to issue a global temperature
  // request to all devices on the bus
  Serial.print(" Requesting temperatures...");
  sensors.requestTemperatures(); // Send the command to get temperatures
  temperature = sensors.getTempCByIndex(0);

  Serial.print("Temperature for Device 1 is: ");
  Serial.println(temperature); // Why "byIndex"?
    // You can have more than one IC on the same bus.
    // 0 refers to the first IC on the wire
  lcd.print("*C         ");
  lcd.print(" sec                 ");
  logFile = SD.open("cookLog.txt", FILE_WRITE);


Code: [Select]
LiquidCrystal lcd(12, 11, 10, 5, 4, 3, 2);
Pins 11, 12, and 13 are the SPI pins. Those are generally the pins that are used to connect SD card readers.

How is your SD card reader connected to the Arduino?


Oh dammit. I put the ┬ÁC and the display together some time ago and now I just assumed it also works with SPI - so I just wired everything like two SPI devices.
Obviously, it does not. So, that explains alot.


Go Up