foca
1
Hello, well I am new here, and have a question about why I can't connecto to 000webhost via ethernet shield this is my code.
#include <SPI.h>
#include <Ethernet.h>
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
byte gateway[] = { 192, 168, 1, 254 };
byte subnet[] = { 255, 255, 255, 0 };
IPAddress server( 192,168,1,65 );
int s[20];
EthernetClient client;
void setup(){
Ethernet.begin(mac, gateway, subnet);
delay(1000);
Serial.begin(9600);
}
void loop(){
for(int a=0;a<20;a++){
s[a]=random(10, 15);
}
mysql_ins();
}
void mysql_ins(){
if (client.connect(server, 80)) {
client.print("GET /arduino/read.php?s1=");
client.print(s[0]);
for(int a=1;a<20;a++){
client.print("&s");
client.print(a+1);
client.print("=");
client.print(s[a]);
}
client.println(" HTTP/1.1");
client.println("Host: localhost");
client.println();
Serial.println("ARDUINO: HTTP message sent");
delay(3000);
if(client.available()){
Serial.println("ARDUINO: HTTP message received");
Serial.println("ARDUINO: printing received headers and script response...\n");
while(client.available()){
char c = client.read();
Serial.print(c);
}
}else{
Serial.println("ARDUINO: no response received / no response received in time");
}
client.stop();
}else{
Serial.println("connection failure");
}
}
When I do it in my local computer I can acces but, I cant in 000webhost I set the server ip as it show me in the Cpanel.
system
2
What response do you get from the server?
What do the server's logs show?
foca
3
I cant see the server log... and how can I know the error?
I am trying to access by the ip 31.170.160.96/home/a9451348 but I can't. In the cpanel show me that ip to acces...
system
4
In the cpanel show me that ip to acces...
What is this cpanel (or Cpanel) that you are talking about?
I am trying to access by the ip 31.170.160.96/home/a9451348
How does 31.170.160.96 relate to 192.168.1.65? Your source code shows that the server you are trying to access is at 192.168.1.65, not 31.170.160.96.
foca
5
hello I'm back again, the cpanel it's the control paranel from my webSite and I get this data:
and my code is this:
#include <SPI.h>
#include <Ethernet.h>
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
byte gateway[] = { 192, 168, 1, 254 };
byte subnet[] = { 255, 255, 255, 0 };
IPAddress server( 31,170,160,99 );
int s[20];
EthernetClient client;
void setup(){
Ethernet.begin(mac, gateway, subnet);
delay(1000);
Serial.begin(9600);
}
void loop(){
for(int a=0;a<20;a++){
s[a]=random(10, 15);
}
mysql_ins();
}
void mysql_ins(){
if (client.connect(server, 80)) {
client.print("GET /arduino/read.php?s1=");
client.print(s[0]);
for(int a=1;a<20;a++){
client.print("&s");
client.print(a+1);
client.print("=");
client.print(s[a]);
}
client.println(" HTTP/1.1");
client.println("Host: localhost");
client.println();
Serial.println("ARDUINO: HTTP message sent");
delay(3000);
if(client.available()){
Serial.println("ARDUINO: HTTP message received");
Serial.println("ARDUINO: printing received headers and script response...\n");
while(client.available()){
char c = client.read();
Serial.print(c);
}
}else{
Serial.println("ARDUINO: no response received / no response received in time");
}
client.stop();
}else{
Serial.println("connection failure");
}
}
system
6
client.println("Host: localhost");
localhost is the computer that the code is running on (the Arduino). Have you really figured out a way to get PHP to run on your Arduino?