Go Down

Topic: Arduino + LCD + Ethernet Twitter Problem (Read 3027 times) previous topic - next topic


I've been trying to get this right for the past two days but keep getting stuck.  I'm going off of these two codes/tutorials:


I first connected the Ethernet shield to the arduino uno and then connected the lcd (same one as in the instructables demo).  I shifted down the lcd pins like it says in the instructables and ran the "hello world" example from the IDE and it worked brilliantly.

Problem now is in compiling either of the codes from the above two examples.  The first I ran into basically told me to change "Client client(server, 80);" to "EthernetClient client(server, 80);".

Now this is the error I'm getting:

Code: [Select]
Twitter2LCD2.pde:-1: error: no matching function for call to 'EthernetClient::EthernetClient(byte [4], int)'
C:\Documents and Settings\Me\My Documents\Downloads\arduino-1.0.1-windows\arduino-1.0.1\libraries\Ethernet/EthernetClient.h:12: note: candidates are: EthernetClient::EthernetClient(uint8_t)
C:\Documents and Settings\Me\My Documents\Downloads\arduino-1.0.1-windows\arduino-1.0.1\libraries\Ethernet/EthernetClient.h:11: note:                 EthernetClient::EthernetClient()
C:\Documents and Settings\Me\My Documents\Downloads\arduino-1.0.1-windows\arduino-1.0.1\libraries\Ethernet/EthernetClient.h:8: note:                 EthernetClient::EthernetClient(const EthernetClient&)
Twitter2LCD2.cpp: In function 'void loop()':
Twitter2LCD2.pde:-1: error: no matching function for call to 'EthernetClient::connect()'
C:\Documents and Settings\Me\My Documents\Downloads\arduino-1.0.1-windows\arduino-1.0.1\libraries\Ethernet/EthernetClient.h:15: note: candidates are: virtual int EthernetClient::connect(IPAddress, uint16_t)
C:\Documents and Settings\Me\My Documents\Downloads\arduino-1.0.1-windows\arduino-1.0.1\libraries\Ethernet/EthernetClient.h:16: note:                 virtual int EthernetClient::connect(const char*, uint16_t)

I've been going insane trying to find the answer everywhere but can't!  Please help.


Make sure yout LCD shield and the ethernet shield are not trying to use the same pin at the same time.
Google forum search: Use Google Search box in upper right side of this page.
Why I like my 2005 Rio Yellow Honda S2000  https://www.youtube.com/watch?v=pWjMvrkUqX0


Post YOUR code, not links to someone else's code, if you want help with YOUR code.


Hey, ive got my code working (as i can see the ouput on the serial monitor) but it won't display on the lcd
can u help me please  :) ..im using a 16x2 lcd
i have no idea on how to get the String object displayed onto the lcd

here is my code


#include <LiquidCrystal.h>
#include <SPI.h>
#include <Ethernet.h>

// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

byte server[] = { 212,1,210,253 }; //ip Address of the server you will connect to

String location = "/output.php HTTP/1.0";

byte mac[] = {0x90, 0xA2, 0xDA, 0x0D, 0x0A, 0xA0 };

EthernetClient client;

char inString[190]; // string for incoming serial data..date/time + tweet characters
int stringPos = 0; // string index counter
boolean startRead = false; // is reading?

void setup()

void loop()
  String pageValue = connectAndRead(); //connect to the server and read the output
  Serial.println(pageValue); //print out the findings.

  lcd.print(pageValue); //display onto lcd
  delay(5000); //wait 5 seconds before connecting again

String connectAndRead()
  //connect to the server


  //port 80 is typical of a www page
  if (client.connect(server, 80))
    client.print("GET ");

    //Connected - Read the page
    return readPage(); //go and read the output

    return "connection failed";


String readPage()
  //read the page, and capture & return everything between '<' and '>'
  stringPos = 0;
  memset( &inString, 0, 140 ); //clear inString memory

    if (client.available())
      char c = client.read();

      if (c == '<' )
      { //'<' is our begining character
        startRead = true; //Ready to start reading the part
      else if(startRead)

        if(c != '>')
        { //'>' is our ending character
          inString[stringPos] = c;
          stringPos ++;
          //got what we need here! We can disconnect now
          startRead = false;
          return inString;


i have no idea on how to get the String object displayed onto the lcd

Can you display anything on the LCD? Or is that you can display some stuff, but not Strings?

You should do yourself a favor and get rid of all Strings from your code. Use NULL terminated char arrays, instead.

I see that most of your processing is done using a char array, and then the global char array is converted to a String object to be returned by the function. Those functions really don't need to return anything. Just use the global char array.


thanks for your help :)
yup i test the lcd by displaying "Hello World" onto it
i just can't display strings
how do i change my Strings to NULL terminated char array?
sorry im quite new to arduino


Code: [Select]
how do i change my Strings to NULL terminated char array?
Code: [Select]
        if(c != '>')
        { //'>' is our ending character
          inString[stringPos] = c;
          stringPos ++;
          inString[stringPos] = '\0'; // <--- Add a NULL

inString is a global array. So, readPage()'s return type should be void, not String. Remove the return statement.

The return type for connectAndRead() should also be void. Remove the return keyword, but NOT the call to readPage().

In loop, just call connectAndRead(). It returns nothing, so just print(), to the serial port and LCD, inString.

Finally, change the type of location to char * instead of String.

Nick Gammon


@komalkristina - stick to a single thread please or there will be trouble.
Please post technical questions on the forum, not by personal message. Thanks!

More info:

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!

via Egeo 16
Torino, 10131