Hi there!
I’m using ethernet shield W5100 to send data to an a virtual hosted website at 000webhost.com
First I tried logging the data to localhost and by setting new inbound rules to bypass firewall, Arduino logged the data via local IP successfully.
but Same when I tried to send the data to a URL “http://www.jsntest.000webhostapp.com/ethernet/data.php?level=205” for instance and it works.
It didn’t update the database which can be seen from “http://www.jsntest.000webhostapp.com/ethernet/display.php”
But same data when I try to send using manually from browser works.
Arduino does connect to the server (i See Connected stated in Serial Monitor) but no update is observed in database.
I searched and found exact problem here given at “https://forum.arduino.cc/index.php?topic=566466.0” but the solution it gave was to put the space before /HTTP1.1 which I already kept before in my case.
Here is the Arduino Code. The online hosted page / server is working well. I know the problem is in the Code, but I couldn’t figure out where I’d miss my eye.
#include <SPI.h>
#include <Ethernet.h>
byte mac[] = { 0x00, 0xAA, 0xBB, 0xCC, 0xDE, 0x02 };
byte ip[] = {192, 168, 0, 108 };
//byte dn[] = {192, 168, 0, 1 };
//byte gate[] = {192, 168, 0, 1 };
//byte sub[] = {255, 255, 255, 0 };
char server[] = "www.jsntest.000webhostapp.com";
EthernetClient client;
void setup() {
Serial.begin(9600);
while (Ethernet.begin(mac) == 0) {
Serial.println("Failed to configure Ethernet using DHCP"); //DHCP
//Ethernet.begin(mac, ip, dn, gate, sub); //static IP (uncommend ipaddress)
}
//else
{
//Serial.println("DHCP Success!");
}
delay(1000); // GIVE THE SENSOR SOME TIME TO START
Serial.println("connecting...");
Serial.print("IP = ");
Serial.println(Ethernet.localIP());
}
void loop() {
float l = 190;
if (client.connect(server, 80))
{
Serial.println("connected");
client.print("GET /ethernet/data.php?level="
client.print(l);
client.println(" HTTP/1.1");
client.println("Host: www.jsntest.000webhostapp.com");
client.println("Content-Type: application/x-www-form-urlencoded");
client.println("Connection: close");
client.println();
Serial.print("Level= ");
Serial.println(l);
client.stop(); //Closing the connection
}
else {
// if you didn't get a connection to the server:
Serial.println("connection failed");
}
delay(500);
}
I am hoping the problem is in Ethernet Shield or some authentication problem to access shared hosted at 000webhost.com
Thanks in advance!