Answer the question
In order to leave comments, you need to log in
How to use arduino to put data on a remote server by URL?
Task:
To put data into the database on the server, the transfer is by the get method.
But the fact is that everything works fine on the home server, accessing the server by ip,
And manually, like: 192.168.10.21/get.php?data1ard=1.00&data2ard=2.00&...
And the arduina connects normally and transfers data .
Access to the remote server is only by URL.
Manually everything works: site.com.ua/get.php?data1ard=1.00&data2ard=2.00&da...
And the arduino can't reach it in any way.
What could be the problem?
#include <Ethernet.h>
float a=1, b=2, c=3;
String msg = "GET /get.php?data1ard="+ String(a) + "&data2ard="+String(b) + "&data3ard="+String(c);
byte mac[] = { 0x00, 0xAA, 0xBB, 0xCC, 0xDE, 0x02 };
IPAddress ip(192, 168, 10, 22);
byte server[] = { 192, 168, 10, 21 };
//char server[] = "www.site.com.ua";
void setup()
{
}
void loop()
{
EthernetClient client;
Ethernet.begin(mac, ip);
delay(1000);
client.connect(server, 80);
client.println(msg);
client.println(" HTTP/1.1");
client.println("Connection: close");
client.println();
client.println();
delay (2000);
client.stop();
}
Answer the question
In order to leave comments, you need to log in
Most likely this is the case:
client.println(msg);
client.println(" HTTP/1.1");
client.println("Connection: close");
client.print("GET ");
client.print(msg);
client.println(" HTTP/1.1");
client.println("Host: 192.168.10.21");
client.println("Connection: close");
You are trying to connect to a server over a domain, but the connection cannot be established on a domain, only on an IP.
To solve this problem, there are DNS services that convert a domain name into an IP address.
You need to either find a library to work with DNS or write queries manually.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question