Question in the code using W5100

Hello forum developers
My name is William, I live in Brazil, I am academic systems and I think the Arduino really amazing,
I’m doing my internship and would like a help her if possible light.
I need to send the Arduino parameters for a coded Web application in Ruby on Rails. I’m using ethernet shield W5100, did some testing with examples of Web server standards and it worked perfectly, but I can not use the shield as WebClient, not of error, but did not get success in sending information.
The sending code was as follows:

// Willian Ribeiro Ludvig - 01/10/2015

#include <SPI.h>
#include <Ethernet.h>
#include <Bridge.h>
#include <HttpClient.h>

#define sensor 1

valor_sensor int = 0;

String address = “”;

mac byte = {
0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED

IPAddress ip (10, 0, 0, 190);

IPAddress MyDNS (8, 8, 8, 8);

EthernetClient client;
HttpClient client;

server char = “”;

unsigned long lastConnectionTime = 0;
const unsigned long postingInterval * = 10L 10L;
String response = “”;
String r = “”;

void setup () {
pinMode (sensor INPUT_PULLUP);
Serial.begin (9600);
while (! Serial) {

delay (1000);
Ethernet.begin (mac, ip, MyDNS);
Serial.print (“My IP address”);
Serial.println (Ethernet.localIP ());

void loop () {
valor_sensor = 0;
valor_sensor = analogRead (sensor);

char c, s;

while (client.available ()) { c = ();
response = “”;
response = + response c;
Serial.write (c);

if (millis () - lastConnectionTime> postingInterval) {
httpRequest ();

httpRequest void () {

client.stop ();

if (client.connect (server, 80)) {
Serial.println (“connecting …”);
Serial.println (valor_sensor);
Serial.println (server);

if (valor_sensor> 300) {

Endereco_temp1 string = string (address + valor_sensor);
client.print (“GET” + endereco_temp1);

Serial.println (endereco_temp1);

Millis lastConnectionTime = ();
else {
Serial.println (“connection failed”);

The code mounts the URL, but does not send to the application, let me know what might be happening?

I tried using the communication standard example, which makes communication with Google, but it still fails, the failure.
The Web application is at:

Attached the .ino code

  • I’m using Google Translate, so forgive me if some words become meaningless.

sketch_nov18a.ino (1.58 KB)

Welcome to the Forum. Please read the two posts

How to use this forum - please read.
Read this before posting a programming question …

at the top of this Forum by Nick Gammon on guidelines for posting here, especially the use of code tags which make the code look

like this

when posting source code files. Also, before posting the code, use Ctrl-T in the IDE to reformat the code in a standard format, which makes it easier for us to read.

If you have already posted without using code tags, open your message and select “modify” from the pull down menu labelled, “More”, at the lower left corner of the message. Highlight your code by selecting it (it turns blue), and then click on the “</>” icon at the upper left hand corner. Click on the “Save” button.

shield as WebClient, not of error, but did not get success in sending information.

This is NOT a server name:

server char [] = "";

This would be a server name:

server char [] = "";

BTW: Are you using an Arduino Yun? The Bridge.h library ONLY for the Arduino Yun.

const unsigned long postingInterval * = 10L 10L;

This line is probably an error. Did you mean to have some mathematical operator between the two?

 while (client.available ()) { c = ();
    response = "";
    response = + response c;
    Serial.write (c);

There are two big errors here. First, if you blank the string with every character you receive then you will never assemble the whole message. Your string will never have more than one character because the third line here erases the String.

The fourth line is nonsense and I'm very surprised if it compiled.

Thank you for aarg tip

I will try this change Jurs , oh I give feedback

Delta_g , I am new to Arduino , I used examples I found on the internet as the standard example of what comes , which makes the search in a google page also did not compile

WillianLudvig: Delta_g , I am new to Arduino , I used examples I found on the internet as the standard example of what comes , which makes the search in a google page also did not compile

I didn't say you weren't. I was just pointing out the errors in your code so you could fix them. I was trying to help. Should I stop?

The examples that come with the Ethernet library will compile and run. I know because I did it last week.

The fourth line is nonsense and I’m very surprised if it compiled.

Perhaps he is using google translate not only for his text, but also for the code?

In that case possibly a valid code that compiles fine before translation might become invalid code after Google did the “translation”.

BTW: The Arduino IDE comes with two webclient example programs

File - Examples - Ethernet - Webclient
File - Examples - Ethernet - WebclientRepeating

Delta_g no no , excuse me looked like this, is that I am using the google translator , my English is not the best

I will be testing the quotes and give feedback as soon as possible

Basic client test code. Note that the arduino does not support secure https: connections.

//zoomkat 3-1-13
//simple client checkip test
//for use with IDE 1.0.1 or later
//with DNS, DHCP, and Host
//open serial monitor and send an e to test
//for use with W5100 based ethernet shields

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

byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED }; //physical mac address

char serverName[] = ""; // test web page server
EthernetClient client;


void setup(){

  if (Ethernet.begin(mac) == 0) {
    Serial.println("Failed to configure Ethernet using DHCP");
    // no point in carrying on, so do nothing forevermore:

  Serial.println("Better client ip test 3/1/13"); // so I can keep track of what is loaded
  Serial.println("Send an e in serial monitor to test"); // what to do to test

void loop(){
  // check for serial input
  if (Serial.available() > 0) //if something in serial buffer
    byte inChar; // sets inChar as a byte
    inChar =; //gets byte from buffer
    if(inChar == 'e') // checks to see byte is an e
      sendGET(); // call sendGET function below when byte is an e


void sendGET() //client function to send/receive GET request data.
  if (client.connect(serverName, 80)) {  //starts client connection, checks for connection
    client.println("GET / HTTP/1.1"); //download text
    client.println("Connection: close");  //close 1.1 persistent connection  
    client.println(); //end of get request
  else {
    Serial.println("connection failed"); //error message if no client connect

  while(client.connected() && !client.available()) delay(1); //waits for data
  while (client.connected() || client.available()) { //connected or data available
    char c =; //gets byte from ethernet buffer
    Serial.print(c); //prints byte to serial monitor 

  client.stop(); //stop client


Good night dear employees;

My code is working now , I used the example webClienteRepeating as quoted by Jurs friend , I’ll be finishing the code and soon will post the final result here
Thank you all for your help.



WillianLudvig: Good night dear employees;

I don't know if we're a victim of poor translation again, but to be sure we are NOT employees. We are volunteers. There is a big difference.

employee == empregado

volunteer == voluntário

exactly Delta_g Forgive me these non-conformities with writing, google sometimes help, but also hinders a little, I will dedicate myself more to English so that this does not happen again