Arduino Ethernet : no character received
hello all
here code, supposed run on ethernet arduino board core of distant control receiver.
as ip changing, supposed ask regularely joomla! server, giving present ip.
then, web server part (not in question, works well) able reached.
the problem card code not able reach joomla! server.
here code
/*
web client
this sketch connects local joomla! v3 website (//192.168.1.36/xyz)
using arduino ethernet board.
created 15 dec 2014
based on webclient.ino example
*/
#include <spi.h>
#include <ethernet.h>
// enter mac address controller below.
// newer ethernet shields have mac address printed on sticker on shield
byte mac[] = { 0x90, 0xa2, 0xda, 0x0f, 0x54, 0x54 };
// if don't want use dns (and reduce sketch size)
// use numeric ip instead of name server:
char server[] = "//192.168.1.36/xyz/index.php"; //
// set static ip address use if dhcp fails assign
ipaddress ip(192,168,1,100);
// initialize ethernet client library
// ip address , port of server
// want connect (port 80 default http):
ethernetclient client;
void setup() {
// open serial communications , wait port open:
serial.begin(9600);
while (!serial) {
; // wait serial port connect. needed leonardo only
}
// disable sd card switching pin 4 high
// not using sd card in program, if sd card left in socket,
// may cause problem accessing ethernet chip, unless disabled
pinmode(4, output);
digitalwrite(4, high);
// start ethernet connection:
if (ethernet.begin(mac) == 0) {
serial.println("failed configure ethernet using dhcp");
// no point in carrying on, nothing forevermore:
// try congifure using ip address instead of dhcp:
ethernet.begin(mac, ip);
}
// give ethernet shield second initialize:
delay(1000);
serial.println("connecting...");
// if connection, report via serial:
if (client.connect(server, 80)) {
serial.println("connected");
// make http request:
client.println("get /index.php?psw=titi http/1.1");
client.println("host: //192.168.1.36/xyz");
client.println("connection: close");
client.println();
}
else {
// kf didn't connection server:
serial.println("connection failed");
}
}
void loop()
{
// if there incoming bytes available
// server, read them , print them:
if (client.available()) {
char c = client.read();
serial.print(c);
}
// if server's disconnected, stop client:
if (!client.connected()) {
serial.println();
serial.println("disconnecting.");
client.stop();
// nothing forevermore:
while(true);
}
}
the answer, on arduino terminal, :
connecting...
connected
disconnecting.
even if suppress the
client.println("connection: close");
line, replacing by
client.println("connection: keep-alive"); // same with keep-open
i tried many combinations with: content of variable server, argument of get, argument of host:
i never character back
i tried replace line
client.println("get /index.php?psw=titi http/1.1");
by
client.println("get /logs/state1.txt http/1.1"); // file exists!
without success.
but, adding line
if (client.connected()) { serial.println("-connected-"); }
at beginning of loop(), discovered client never connected ...
what's wrong?
the code disabling sd card not change anything.
i must specify that, using chrome or ie, if use url
//192.168.1.36/xyz/index.php?psw=titi
everything functionning, including log of call in database joomla! placed in code.
192.168.1.36 , 192.168.1.100 static address under livebox lan
if fact check software on local network reason why doesn't work, how suggest me debug it?
however, replacing site url "google.fr", nothing appears either.
for of you, merry christmas
here code, supposed run on ethernet arduino board core of distant control receiver.
as ip changing, supposed ask regularely joomla! server, giving present ip.
then, web server part (not in question, works well) able reached.
the problem card code not able reach joomla! server.
here code
/*
web client
this sketch connects local joomla! v3 website (//192.168.1.36/xyz)
using arduino ethernet board.
created 15 dec 2014
based on webclient.ino example
*/
#include <spi.h>
#include <ethernet.h>
// enter mac address controller below.
// newer ethernet shields have mac address printed on sticker on shield
byte mac[] = { 0x90, 0xa2, 0xda, 0x0f, 0x54, 0x54 };
// if don't want use dns (and reduce sketch size)
// use numeric ip instead of name server:
char server[] = "//192.168.1.36/xyz/index.php"; //
// set static ip address use if dhcp fails assign
ipaddress ip(192,168,1,100);
// initialize ethernet client library
// ip address , port of server
// want connect (port 80 default http):
ethernetclient client;
void setup() {
// open serial communications , wait port open:
serial.begin(9600);
while (!serial) {
; // wait serial port connect. needed leonardo only
}
// disable sd card switching pin 4 high
// not using sd card in program, if sd card left in socket,
// may cause problem accessing ethernet chip, unless disabled
pinmode(4, output);
digitalwrite(4, high);
// start ethernet connection:
if (ethernet.begin(mac) == 0) {
serial.println("failed configure ethernet using dhcp");
// no point in carrying on, nothing forevermore:
// try congifure using ip address instead of dhcp:
ethernet.begin(mac, ip);
}
// give ethernet shield second initialize:
delay(1000);
serial.println("connecting...");
// if connection, report via serial:
if (client.connect(server, 80)) {
serial.println("connected");
// make http request:
client.println("get /index.php?psw=titi http/1.1");
client.println("host: //192.168.1.36/xyz");
client.println("connection: close");
client.println();
}
else {
// kf didn't connection server:
serial.println("connection failed");
}
}
void loop()
{
// if there incoming bytes available
// server, read them , print them:
if (client.available()) {
char c = client.read();
serial.print(c);
}
// if server's disconnected, stop client:
if (!client.connected()) {
serial.println();
serial.println("disconnecting.");
client.stop();
// nothing forevermore:
while(true);
}
}
the answer, on arduino terminal, :
connecting...
connected
disconnecting.
even if suppress the
client.println("connection: close");
line, replacing by
client.println("connection: keep-alive"); // same with keep-open
i tried many combinations with: content of variable server, argument of get, argument of host:
i never character back
i tried replace line
client.println("get /index.php?psw=titi http/1.1");
by
client.println("get /logs/state1.txt http/1.1"); // file exists!
without success.
but, adding line
if (client.connected()) { serial.println("-connected-"); }
at beginning of loop(), discovered client never connected ...
what's wrong?
the code disabling sd card not change anything.
i must specify that, using chrome or ie, if use url
//192.168.1.36/xyz/index.php?psw=titi
everything functionning, including log of call in database joomla! placed in code.
192.168.1.36 , 192.168.1.100 static address under livebox lan
if fact check software on local network reason why doesn't work, how suggest me debug it?
however, replacing site url "google.fr", nothing appears either.
for of you, merry christmas
code: [select]
char server[] = "//192.168.1.36/xyz/index.php"; //
that not server identification. "192.168.1.36" be.
Arduino Forum > Using Arduino > Programming Questions > Arduino Ethernet : no character received
arduino
Comments
Post a Comment