Hello people.
Please, I have an arduino uno and a Chinese ethernet (enc28j60) sending the temperature to a database (php).
If it sends every 15 seconds everything is ok.
But if I post to send every 5 minutes or longer it does not send.
As if the board did not work, but if I dribble the address, it responds.
I saw that this module has some problems, but I could not solve this in any way.
I’m using IDE 1.8.1 and ethercard (https://www.tweaking4all.nl/download/arduino/ethercard.zip)
The code follows below.
Thanks
// Demo using DHCP and DNS to perform a web client request.
// 2011-06-08 <jc@wippler.nl> http://opensource.org/licenses/mit-license.php
#include <EtherCard.h>
// ethernet interface mac address, must be unique on the LAN
static byte mymac[] = { 0x74,0x69,0x69,0x2D,0x30,0x31 };
byte Ethernet::buffer[700];
static uint32_t timer;
const char website[] PROGMEM = "sergiolinux.sytes.net";
// called when the client request is complete
static void my_callback (byte status, word off, word len) {
Serial.println(">>>");
Ethernet::buffer[off+300] = 0;
Serial.print((const char*) Ethernet::buffer + off);
Serial.println("...");
}
void setup () {
Serial.begin(57600);
Serial.println(F("\n[webClient]"));
if (ether.begin(sizeof Ethernet::buffer, mymac, 10) == 0)
Serial.println(F("Failed to access Ethernet controller"));
if (!ether.dhcpSetup())
Serial.println(F("DHCP failed"));
ether.printIp("IP: ", ether.myip);
ether.printIp("GW: ", ether.gwip);
ether.printIp("DNS: ", ether.dnsip);
ether.hisport = 8080;
#if 1
// use DNS to resolve the website's IP address
if (!ether.dnsLookup(website))
Serial.println("DNS failed");
#elif 2
// if website is a string containing an IP address instead of a domain name,
// then use it directly. Note: the string can not be in PROGMEM.
char websiteIP[] = "192.168.1.1";
ether.parseIp(ether.hisip, websiteIP);
#else
// or provide a numeric IP address instead of a string
byte hisip[] = { 192,168,1,1 };
ether.copyIp(ether.hisip, hisip);
#endif
ether.printIp("SRV: ", ether.hisip);
}
void loop () {
ether.packetLoop(ether.packetReceive());
if (millis() > timer) {
timer = millis() + 1800000;// 30 minutos
Serial.println();
Serial.print("<<< REQ ");
ether.browseUrl(PSTR("/arduino/salvardados.php?"), "temp1=0&umi1=0&temp2=22.00&umi2=39.40&temp3=22.00&umi3=39.40", website, my_callback);
}
}
webClient_00.ino (1.87 KB)