Hi!
You need use ethercard?
Can be UIPEthernet for ENC28J60?
I have an example here:
//#include <SPI.h> // Uncomment to use the W5100
//#include <Ethernet.h> // Uncomment to use the W5100
#include <UIPEthernet.h> // Comment to use the W5100
#include <Base64.h>
#include <DS1307.h> // Henning's library
byte mac[] = {0xDE, 0xAD, 0xBE, 0xAF, 0xCE, 0xDD}; // whatever mac you want
byte ip[] = {192, 168, 0, 177};
DS1307 rtc(20, 21);
char *Username = "Username";
char *APIKEY = "12345678";
EthernetClient client;
char *token = ":";
char Auth[50];
char Auth1[50];
void setup()
{
Serial.begin(9600);
strcpy(Auth,Username);
strcat(Auth,token);
strcat(Auth,APIKEY);
base64_encode(Auth1, Auth, strlen(Auth));
Ethernet.begin(mac, ip);
Serial.print("Ip Server: ");
Serial.println(Ethernet.localIP());
}
void loop()
{
delay(30000);
enviar_dados();
}
void enviar_dados()
{
EthernetClient client;
Time t = rtc.getTime();
float tempC = 25.55;
float tempH = 22.55;
float tempA = 20.55;
float PHA = 8.4;
float PHR = 6.4;
int ORP = 400;
int DEN = 1025;
byte status_parametros = 255;
byte temporizador_status = 255;
byte Status = 255;
boolean nivel_status = true;
byte tpa_status = 255;
char dados[6];
Serial.println("Connecting...");
if (client.connect("www.mySite.com", 80))
{
Serial.println(">> Connected <<");
client.println("POST /MyFolder HTTP/1.1");
client.println("Host: www.mySite.com");
client.print("Authorization: Basic ");
client.println(Auth1);
client.println("Cache-Control: no-cache");
client.println("Content-Type: application/x-www-form-urlencoded");
client.println("Connection: close");
String PostData =
"{\"userName\":\""+
String(Username)+
"\",\"minute\":\""+
String(t.year)+
"-"+
String(t.mon)+
"-"+
String(t.date)+
" "+
String(t.hour)+
":"+
String(t.min)+
":"+
String(t.sec)+
"\",\"A\":"+ // Temp. da água
dtostrf(tempC,5,2,dados)+
",\"B\":"+ // Temp. dissipador
dtostrf(tempH,5,2,dados)+
",\"C\":"+ // Temp. ambiente
dtostrf(tempA,5,2,dados)+
",\"D\":"+ // PH do aquário
dtostrf(PHA,4,2,dados)+
",\"E\":"+ // PH do reator de cálcio
dtostrf(PHR,4,2,dados)+
",\"F\":"+ // Densidade
String(DEN)+
",\"G\":"+ // ORP
String(ORP)+
",\"H\":"+ // Status chiller, 0 = desligado e 1 = ligado
String(bitRead(status_parametros,0))+
",\"I\":"+ // Status aquecedor, 0 = desligado e 1 = ligado
String(bitRead(status_parametros,1))+
",\"J\":"+ // Status reator de cálcio, 0 = desligado e 1 = ligado
String(bitRead(status_parametros,5))+
",\"K\":"+ // Status ozonizador, 0 = desligado e 1 = ligado
String(bitRead(status_parametros,7))+
",\"L\":"+ // Status reposição de água doce, 0 = desligado e 1 = ligado
String(bitRead(Status,1))+
",\"M\":"+ // Status niveis, 0 = baixo e 1 = normal
String(nivel_status)+
",\"N\":"+ // Status TPA, 0 = desligado e 1 = ligado
String(bitRead(tpa_status,0))+
",\"O\":"+
String(bitRead(temporizador_status,1))+ // Status timer 1, 0 = desligado e 1 = ligado
",\"P\":"+
String(bitRead(temporizador_status,2))+ // Status timer 2, 0 = desligado e 1 = ligado
",\"Q\":"+
String(bitRead(temporizador_status,3))+ // Status timer 3, 0 = desligado e 1 = ligado
",\"R\":"+
String(bitRead(temporizador_status,4))+ // Status timer 4, 0 = desligado e 1 = ligado
",\"S\":"+
String(bitRead(temporizador_status,5))+ // Status timer 5, 0 = desligado e 1 = ligado
",\"T\":"+ // Sinaliza falha na TPA
String(bitRead(tpa_status,2))+
"}";
client.print("Content-Length: ");
client.println(PostData.length());
client.println();
client.println(PostData);
delay(5);
client.stop();
}
else
{
Serial.println("Connection failed");
}
}
I can’t help you with PHP unfortunately.
Best regards.
Fernando Garcia