I am a beginner at Arduino and electronics generally. Web development however I am well practised at.
I have a very small Arduino project and I am attempting to upload updates from my Ethernet Shield mounted Arduino to a website. Since the updates will be saved to a database, I decided to send GET requests so I can write code to retrieve the data on the website and save to the database.
The following is my Arduino code where I am attempting to perform the GET request:
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
byte my_ip[] = { 172, 198, 0, 6 };
byte server[] = { 158, 81, 108, 34 };
Ethernet.begin(mac, my_ip);
Serial.begin(9600);
delay(1000);
Serial.println("connecting...");
if (client.connect(server, 80)) {
Serial.println("connected");
client.println("GET /arduinoProjects?q=arduino HTTP/1.0");
client.println();
Serial.print("CLIENT: ");
Serial.println(client);
} else {
Serial.println("connection failed");
}
My website is at http://158.81.108.34/arduinoProjects
(not the real url). As there is no arduino page, I expect the get request to register as page not found - that way I know the GET request was successfully received.
The problem is all I get from my Arduino serial port is connection failed. I have been trying to follow this example.
I don't know how to fix this. I really would appreciate any help.