Arduino uno + ethernet shield


I am planing to put together a arduino + ethernet setup, with BMP085 and DHT22 so i can upload to Emoncms (own server).


Got the BMP085 and DHT22 running and giving out data on seriel (usb).

Now looking for a sketch to show how to put together the payload to send to the ethernet shield.

I had a look at the 03 - Basic Web Client



with no luck, Wrong ethernet card


So if any have a sketch for the arduino+shield i would like to have a look.



Kent88's picture

Re: Arduino uno + ethernet shield

Did you ever get this to work?

ageurtse's picture

Re: Arduino uno + ethernet shield



This is how i did it with a arduino nano and en encj2860 and using the ethercard library.

I read 2 one wire thermometers and send them to my emoncms server

maybe you could use it.


// Demo using DHCP and DNS to perform a web client request.
// 2011-06-08 <>
#include <EtherCard.h>
#include <OneWire.h>
#include <DallasTemperature.h>
char payload[50];

void(* resetFunc) (void) = 0; //declare reset function @ address 0

// ethernet interface mac address, must be unique on the LAN
// and other stuff used for the network interface
static byte mymac[] = { 0x74,0x69,0x69,0x2D,0x30,0x35 };
byte Ethernet::buffer[700];

char website[] PROGMEM = "xx.xx.xx.xx";//destination website
// This is the char array that holds the reply data
char line_buf[50];

// Stuff used for one wire sensors
// Data wire is plugged into pin 7 on the Arduino
#define ONE_WIRE_BUS 7

// Setup a oneWire instance to communicate with any OneWire devices
// (not just Maxim/Dallas temperature ICs)
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);
  int temp1;
  int temp2;

// Some random stuff used in this program
static uint32_t timer;
byte wd_counter;

// called when the client request is complete
static void my_callback (byte status, word off, word len) {

  if (strcmp((const char*) line_buf,"ok"))
    Serial.println( F(" recieved ok."));
  } else
    Serial.println( F(" !!! ERROR !!!."));
    Serial.println( F(">>>"));
    Serial.print((const char*) Ethernet::buffer+off);
    Serial.println( F("<<<"));

//Setup the board
void setup () {

  //Start serial port
  Serial.println( F("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"));
  Serial.println( F("\nNANO EMONCMS Temperatuur sender\n\n\n"));
  //Start ethernet port
  if (ether.begin(sizeof Ethernet::buffer, mymac,10) == 0)
    Serial.println(  F("Failed to access Ethernet controller"));
  //Get own ip adress
  if (!ether.dhcpSetup())
    Serial.println( F("DHCP failed"));
  ether.printIp("IP:  ", ether.myip);
  ether.printIp("GW:  ", ether.gwip); 
  ether.printIp("DNS: ", ether.dnsip); 
  //Look ip destination website
  if (!ether.dnsLookup(website))
    Serial.println( F("DNS failed"));
  ether.printIp("SRV: ", ether.hisip);

  // Startup one wire sensors

// Main program
void loop () {

  if (wd_counter>=10) {
    Serial.println( F("Resetting device"));

  if (millis() > timer) {
    timer = millis() + 25000;
    Serial.println(" ");
    Serial.print( F("Attempt number "));
    Serial.print( F(" of 10, data send to emoncms: "));
    //temp1 = round(sensors.getTempCByIndex(0)*10);
    //temp2 = round(sensors.getTempCByIndex(1)*10);     
    temp1 = sensors.getTempCByIndex(0)*10;
    temp2 = sensors.getTempCByIndex(1)*10;     
    ether.browseUrl(PSTR("/emoncms/input/post.json?apikey=********06d069745bfe8dac70040261&json="), payload, website, my_callback);


int get_reply_data(word off)
  if (off != 0)
    uint16_t pos = off;
    int line_num = 0;
    int line_pos = 0;
    // Skip over header until data part is found
    while (Ethernet::buffer[pos]) {
      if (Ethernet::buffer[pos-1]=='\n' && Ethernet::buffer[pos]=='\r') break;
    while (Ethernet::buffer[pos])
      if (line_pos<49) {line_buf[line_pos] = Ethernet::buffer[pos]; line_pos++;} else break;
    line_buf[line_pos] = '\0';
    return line_pos;
  return 0;

[Edit: APIkey obfuscated - RW]

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.