Go Down

Topic: sending arduino data to my database using EtherCard.h library (Read 9517 times) previous topic - next topic


Hi! I am having a problem in sending Arduino data into my database. I am currently using WAMPSERVER. I have an arduino mini w/ ATMEGA 328 and I am using ENC28J60. The problem is I have tried different libraries and examples to send data into the server but I failed. I just notice that some libraries are not compatible with my enc28J60. I have tried UIPEthernet.h, Ethernet.h, etherShield.h and EtherCard.h. The etherShield.h and EtherCard.h seemed to work just fine.  But I prefer to use EtherCard.h because I heard etherShield is the older lib. I know a little php.

I think the things that might guide me is to see a working example of using the EtherCard.h library demonstrating the sending of sensor data from arduino into my database. The network setup I am currently working on is that, the ENC28J60 is connected in my home network with an ip address of The server to which I placed the database is my laptop with an IP address of I am placing the php files in this directory C:\wamp\www. I hope I have explained it well. I'm sorry for my English.


I used EtherCard library for sending data to my server. I attached some my connection testing sketch.

Code: [Select]

// 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;

char website[] PROGMEM = "";
//char website[] PROGMEM = "google.com";

// called when the client request is complete
static void my_callback (byte status, word off, word len) {
  Ethernet::buffer[off+300] = 0;
  Serial.print((const char*) Ethernet::buffer + off);

void setup () {

  if (ether.begin(sizeof Ethernet::buffer, mymac) == 0)
    Serial.println( "Failed to access Ethernet controller");
  if (!ether.dhcpSetup())
    Serial.println("DHCP failed");

  ether.printIp("IP:  ", ether.myip);
  ether.printIp("GW:  ", ether.gwip); 
  ether.printIp("DNS: ", ether.dnsip); 

  if (!ether.dnsLookup(website))
    Serial.println("DNS failed");
  ether.printIp("SRV: ", ether.hisip);

void loop () {
  if (millis() > timer) {
    timer = millis() + 5000;
    Serial.print("<<< REQ ");
    ether.hisport = 8080;//to access  local host
    ether.browseUrl(PSTR("/HouseLogger/HouseLogger?"), "get=Hello", website, my_callback);

Some higlights:
adress of your server, in this time local computer
Code: [Select]
char website[] PROGMEM = "";

If you use other port that 80, change it here:
Code: [Select]
ether.hisport = 8080;//to access  local host

Specification of path on server and parametres for server:
Code: [Select]
ether.browseUrl(PSTR("/HouseLogger/HouseLogger?"), "get=Hello", website, my_callback);


hi, i'm trying to use it, but with my teste page it doesnt work.

on php i'm using the code bellow but nothing happens.
if(isset($_GET['get']) or isset($_POST['get'])){
mkdir('/teste', 0777, true);
chmod('/teste', 0777);
echo "Feito";
echo "Vazio";

My apache server in on on port 80, name of the test file is  callback.php and his location is

are right my changes bellow?

char website[] PROGMEM = "";

ether.hisport = 80;//to access  local host
ether.browseUrl(PSTR("/seguranca/callback?"), "get=Hello", website, my_callback);



Does anyone know how to implement a standard chat server using Ethercard?  I can't seem to find an example anywhere.  I've done it successfully using the regular Ethernet and UIPEthernet, but can't get it on Ethercard.


Go Up