Hi everyone! I am using this code to post data to MySql database every 10 seconds by executing insert_mysql.php, this one works perfectly. But what I want now is to use the library etherShield.h and ETHER_28j60.h. Is there any equivalent code for this that works with those 2 libraries? I want to change the library that I am using because I am having problems when I use the UIPEhthernet library. For example: when i used the UIP library to control an LED using a browser, there is a delay when I pressed the ON or OFF button and sometimes the browser is just loading and unable to control the LED but when I used the etherShield and ETHER_28j60 library, controlling the LED using a browser works perfectly without delay.
Is it possible to combine a web server (controlling LED using web browser) and web client (POST data to MySQL)??? If yes, do you have any example using the library etherShield.h and ETHER_28j60.h THANKS ![]()
#include <UIPEthernet.h>
long previousMillis = 0;
long interval = 10000;
EthernetClient client;
char server[] = "192.168.10.4";
IPAddress ip(192, 168, 10, 5);
String yourdatacolumn = "yourdata=";
String yourdata;
void setup() // run once, when the sketch starts
{
uint8_t mac[6] = {
0x00,0x01,0x02,0x03,0x04,0x05 };
Ethernet.begin(mac);
}
void loop() // run over and over again
{
unsigned long currentMillis = millis();
if(currentMillis - previousMillis > interval) {
previousMillis = currentMillis;
yourdata = yourdatacolumn ;
client.connect(server, 80);
Serial.println("Connecting to server database...");
client.println("POST /arduino/insert_mysql.php HTTP/1.1");
client.println("Host:192.168.10.4 ");
client.println("User-Agent: Arduino/1.0");
client.println("Connection: close");
client.println("Content-Type: application/x-www-form-urlencoded;");
client.print("Content-Length: ");
client.println(yourdata.length());
client.println();
client.println(yourdata);
Serial.println("Connection Successful!");
client.stop();
}
}