Go Down

Topic: Ethernet & LCD Shield project (Read 2295 times) previous topic - next topic

#15
May 22, 2012, 10:46 pm Last Edit: May 22, 2012, 10:56 pm by Rirawen Reason: 1
Yes, and no joy.

I'll rephrase - all pins from the arduino run into the ethernet shield, all pins except Digital 4 and 10 run from the Ethernet to the LCD.
Digital pins 3 and 4 on the LCD are connected.

SurferTim

#16
May 22, 2012, 11:02 pm Last Edit: May 22, 2012, 11:08 pm by SurferTim Reason: 1
I don't understand that. If you remove the ethernet shield and connect the LCD shield directly to the Arduino with the LCD shield pins still bent and the jumper, does the LCD work?

add: If that doesn't work, remove the jumper and bend pin 4 back to connect to the Arduino. Check the LCD again. And change this back to pin 4
Code: [Select]
LiquidCrystal lcd(8, 9, 4, 5, 6, 7);

I have a blacklight, but no output on the LCD.

Trace on serial shows;
Quote
Starting ethernet...started
Connecting...
failed

..repeatedly.

SurferTim

There will be no ethernet connection because there is no ethernet shield.

Remove the jumper wire and rebend pin 4 so it inserts in the Arduino and change this back to pin 4:
Code: [Select]
LiquidCrystal lcd(8, 9, 4, 5, 6, 7);


That almost has to work, doesn't it?

Yes, that works.

..and just for reference the code; (just incase I did something stupid)
Code: [Select]
#include <SPI.h>
#include <Ethernet.h>
#include <LiquidCrystal.h>

byte mac[] = {  0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
IPAddress ip(192,168,0,50);

IPAddress server(192,168,0,90);
EthernetClient client;

void setup() {
 
  Serial.begin(9600);
  pinMode(4,OUTPUT);
  digitalWrite(4,HIGH);
 
  LiquidCrystal lcd(8, 9, 4, 5, 6, 7);

  lcd.begin(16, 2);
  lcd.setCursor(0,0);
  lcd.print("Web Client:");

  Serial.print("Starting ethernet...");
  Ethernet.begin(mac,ip);
  Serial.println("started");
  delay(2000);

  Serial.println("Connecting...");

  if (client.connect(server, 80)) {
    Serial.println("Connected");
    client.println("GET / HTTP/1.0");
    client.println();

    while(client.connected()) {
      while(client.available()) {
        Serial.write(client.read());
      }
    }
    client.stop();
    Serial.println("disconnected");
  }
  else {
    Serial.println("failed");
  }
}

void loop() {
  delay(2000);
  setup();
}


SurferTim

#20
May 22, 2012, 11:21 pm Last Edit: May 22, 2012, 11:27 pm by SurferTim Reason: 1
I would do it this way. Set up the ethernet interface once, then make the connection in the loop().
Code: [Select]
#include <SPI.h>
#include <Ethernet.h>
#include <LiquidCrystal.h>

byte mac[] = {  0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
IPAddress ip(192,168,0,50);

IPAddress server(192,168,0,90);
EthernetClient client;

void setup() {
 
 Serial.begin(9600);
 pinMode(4,OUTPUT);
 digitalWrite(4,HIGH);
 
 LiquidCrystal lcd(8, 9, 4, 5, 6, 7);

 lcd.begin(16, 2);
 lcd.setCursor(0,0);
 lcd.print("Web Client:");

 Serial.print("Starting ethernet...");
 Ethernet.begin(mac,ip);
 Serial.println("started");
 delay(2000);

}

void loop() {

  lcd.clear();
 lcd.print("Connecting");

 Serial.println("Connecting...");

 if (client.connect(server, 80)) {
   Serial.println("Connected");
   client.println("GET / HTTP/1.0");
   client.println();

   while(client.connected()) {
     while(client.available()) {
       Serial.write(client.read());
     }
   }
   client.stop();
   Serial.println("disconnected");
 }
 else {
   Serial.println("failed");
 }

  lcd.clear();
 lcd.print("Disconnected");

delay(2000);
}


Add any cursor position changes to that it may need. edit: I added a "lcd.clear()" to each print.

Does this change the LCD display as it goes through the loop? It will not make a connection yet. Leave the shield off. Best to do this one shield at a time.

#21
May 22, 2012, 11:26 pm Last Edit: May 22, 2012, 11:30 pm by Rirawen Reason: 1
Yes, I get the initial "Web Client:" then it writes the connecting / disconnected lines over and over.

add: though i notice you have a clear() in there.. the LCD does not clear, it just continues from where the cursor stopped.

SurferTim

Now bend digital 4 so it does not insert into the Arduino, and put the jumper on the shield from 4 to 3.

Change to this again:
Code: [Select]
LiquidCrystal lcd(8, 9, 3, 5, 6, 7);


Still no LCD output?

Changed, pin 4 removed from the arduino, jumper between 3 and 4 on the LCD - no joy.. code runs i can see on the serial monitor.
But no text on the LCD.

SurferTim

#24
May 22, 2012, 11:42 pm Last Edit: May 23, 2012, 12:11 am by SurferTim Reason: 1
I only have one more try left, then we are out of pins. Try digital 2 instead of digital 3. Move the jumper one pin over, connecting digital 4 to digital 2 , and change to this:
Code: [Select]
LiquidCrystal lcd(8, 9, 2, 5, 6, 7);


If that doesn't do it, I have run out of pins and ideas at the same time.  :(

edit: I lied. I have one more idea.
Bend digital 4 on the LCD shield so it does not connect to the ethernet shield.
Bend digital pin 4 on the ethernet shield so it does not connect to digital pin 4 on the Arduino.
Put the jumper from digital 4 on the LCD shield to the Arduino digital 4.
Put another jumper from the ethernet shield digital 4 to +5v.
Then back to this:
Code: [Select]
LiquidCrystal lcd(8, 9, 4, 5, 6, 7);


But that is it for my ideas. With that setup, the microSD card is not useable. You might be able to jumper that pin on the ethernet shield to digital 3.

Thanks for your help Tim,

It's late and I'm going to pack it in for tonight.

One thing I have notice.. on the LCD Shield where the digital pins are.. their neighboring counterparts are not connected.
This is an almost identical board to the LCD board im using, only visual difference is the drive the future logo, which is not present on my board.


I noticed that using pin 4 and connecting from 4 on the arduino to the outer 4 on the LCD board did not produce an output, but connecting 4 on the
arduino board to pin 4 on the factory header with no code changes - works.. :~

I will have to wait until morning before I can dig my tester out the garage and confirm this, but it looks like I'm skuppered  :(

SurferTim

I'm packing it in for tonight also.

The "outer 4" is the digital 4 in the red rectangle, and the "factory header" is in the blue rectangle? And you think they may not be connected? And if you use digital 4 in the blue, it works?

#27
May 23, 2012, 10:57 am Last Edit: May 23, 2012, 11:24 am by Rirawen Reason: 1
The "outer 4" is the digital 4 in the red rectangle, and the "factory header" is in the blue rectangle? And you think they may not be connected? And if you use digital 4 in the blue, it works?

Yes.. I had assumed from previous shields that each pin red to blue were connected, but apparently not.
I'm also getting that dimming of the LCD characters again.

Add:
OK I've had a little success :)

I have both the Ethernet and LCD shields connected, I'm getting a good response from the webserver which is feeding through in the serial monitor,
and I'm getting output (if a bit dim as described above) on the LCD..

I changed the code ever so slightly, no pin changes.. just to structure the LCD output so it didn't just keep overwriting the last string of chars.

here it is;
Code: [Select]
#include <SPI.h>
#include <Ethernet.h>
#include <LiquidCrystal.h>

byte mac[] = {  0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
IPAddress ip(192,168,0,50);

IPAddress server(192,168,0,90);
EthernetClient client;
LiquidCrystal lcd(8, 9, 4, 5, 6, 7);
 
void setup() {
 
 Serial.begin(9600);
 pinMode(4,OUTPUT);
 digitalWrite(4,HIGH);
 
 lcd.begin(16, 2);
 lcd.setCursor(0,0);
 lcd.print("Web Client:");

 Serial.print("Starting ethernet...");
 Ethernet.begin(mac,ip);
 Serial.println("started");
 delay(2000);

}

void loop() {
 
 lcd.setCursor(0,1);
 lcd.print("Connecting...   ");
 Serial.println("Connecting...");

 delay(1000);

 if (client.connect(server, 80)) {
   
   lcd.setCursor(0,1);
   lcd.print("Connected       ");
   
   Serial.println("Connected to server.");
   client.println("GET / HTTP/1.0");
   client.println();

   while(client.connected()) {
     while(client.available()) {
       Serial.write(client.read());
     }
   }
   
   delay(3000);
   
   client.stop();
   Serial.println("Disconnected from server.");
 }
 else {
   Serial.println("Connection to server Failed.");
 }
 
 
 lcd.setCursor(0,1);
 lcd.print("Disconnected    ");

delay(2000);
}


Add also: Digital Pin 4 is connected to all boards and pin 10 on the LCD board is not connected to anything.

SurferTim

#28
May 23, 2012, 12:08 pm Last Edit: May 23, 2012, 12:41 pm by SurferTim Reason: 1
Are both shields powered by the Arduino +5v? Maybe not enough power? My first check would be the voltage on the +5v pin.

edit: Personally, I do my best to keep devices available. I would try to move digital pin 4 on the LCD to digital 3 and use that pin instead. Then I could use the microSD card. Otherwise, the best storage for large amounts of data is not available.

Yes, both are stacked directly with the Arduino and powered through the USB.
Adding a 9v battery to the power socket does seem to rectify the dimming, but only a little.

My multimeter shows the +5v pin at +4.4v without the battery and +4.7v (though I think the battery is on it's way out anyway..
Will have to either knock together a mains supply or buy one if I don't have the parts, and test running only on the mains supply.

Go Up