Arduino (C ++) send variable to page in PHP [closed]

-1

I have the following code in C ++ in Arduino

int variavelemc;
variavelemc = 10;

And I have the following code in PHP

$variavelemphp = $_POST['variavelemc'];

How do I pass variavelemc to $variavelemphp ?

Additional Information

The Arduino is connected to the Internet.

The PHP code is hosted on the internet.

    
asked by anonymous 08.10.2018 / 14:37

1 answer

2

Using the Ethernet library

Initializing

byte mac[] = { 0x00, 0xAA, 0xBB, 0xCC, 0xDE, 0x01 }; // RESERVED MAC ADDRESS
EthernetClient client;

No begin ()

Serial.begin(115200);
if (Ethernet.begin(mac) == 0) {
    Serial.println("Failed to configure Ethernet using DHCP"); 
}

in loop ()

    if (client.connect("www.*****.*************.com",80)) {
        client.println("POST /add.php HTTP/1.1"); 
        client.println("Host: *****.*************.com");
        client.println("Content-Type: application/x-www-form-urlencoded"); 
        client.print("Content-Length: "); 
        client.println(data.length()); 
        client.println(); 
        client.print(data); 
    } 

    if (client.connected()) { 
        client.stop();  
    }
    
16.10.2018 / 14:56