Arduino pushing data via HTTP

I want to log data from the Arduino to my root server using HTTP. The Arduino Ethershield makes this really simple.

In the Makefile (see older blogpost this LIBS need to be loaded:

LIBS = Ethernet Ethernet/utility String SPI

First version of my HTTP client on Arduino:

#include <SPI.h>
#include <Ethernet.h>

byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xDD };
byte ip[] = { 192,168,1, 42 };
byte gateway[] = { 192, 168, 1, 1};
byte subnet[] = { 255, 255, 255, 0 };

byte server[] = { 192, 168, 1, 2 };

// initialize the library instance:
Client client(server, 80);

const int postingInterval = 9000;   // delay between updates
long lastConnectionTime = 0;        // last time connected to the server
boolean lastConnected = false;      // state of the connection
long counter = 1;

String txtMsg="";

void sendData() {

  if (client.connect()) {

    client.print("POST /input/ HTTP/1.1\n");

    client.print("Host: HOSTNAME\n");
    client.print("X-ApiKey: RANDOM_API_KEY\n");

    client.println("User-Agent: Arduino");
    client.println("Accept: text/html");
    client.print("Content-Length: ");
    client.println(txtMsg.length(), DEC);

    client.print("Content-Type: text/json\n");
    client.println("Connection: close\n");


    lastConnectionTime = millis();
    counter += 1;
  else {
    Serial.println("connection failed");

void setup()
  // start the Ethernet connection:
  Ethernet.begin(mac, ip);

  // delay for the ethernet to get up

void loop()
  // get the sensor data (using the sensor is the next step -- atm no real data)
  int sensorReading = 42;

  if(millis() - lastConnectionTime > postingInterval) {
    // disconnect old client


    // the JSON message
    txtMsg = "[ value=";
    txtMsg += sensorReading;
    txtMsg += ", counter=";
    txtMsg += counter;
    txtMsg += "]";


  lastConnected = client.connected();

Arduino first steps

I want to know, why I didn't tried the Arduino before? Arduino is such a simple way into building something useful with a microcontroller.

First I wanted to use my new Arduino Uno only using console and Emacs. I used this stuff to get started:

The first program I tried was really simple (blinking LED on pin 9):

Using this Makefile (the Makefile.master is in the folder above):

# Your Arduino environment.
ARD_REV = 22
ARD_HOME = /opt/arduino-0022
AVR_HOME = /usr/bin
ARD_BIN = /usr/bin
AVRDUDE = /usr/bin/avrdude
AVRDUDE_CONF = /etc/avrdude.conf

# Board settings.
BOARD = uno
PORT = /dev/ttyACM0
PROGRAMMER = arduino

# Where to find header files and libraries.
INC_DIRS = ./inc
LIB_DIRS = $(addprefix $(ARD_HOME)/libraries/, $(LIBS))

include ../Makefile.master

After this only connect the arduino via USB and add one LED with an resistor to pin 13 and GND. Compiling and flashing using: make upload.

Amazingly simple!

Dante spring conference 2011

My personal notes from Dante spring conference in Bremen.

  • improved makeindex: Xindy
  • texdoc <FONT> helps including new fonts. i.e. texdoc bera
  • one complete font (with maths) is kpfonts
  • \showfont shows font used at the moment
  • use blindtext to get "lorem ipsum". But "Blindtext" is not Latin.
  • mathastext sets all text in formulars as text. To get variables in italic add [italic] at package loading time.
  • good Font catalogue:
  • try biblatex; don't use bibtex anymore.
  • with the option --wolfgang the capacity of bibtex8 will be increased to very huge
  • universal document converter: pandoc
  • new list typ for TeX: coollist; for strings coolstr and cool for maths
  • chronology to set time scales
  • with cntdwn a counter and a clock can be embeded in PDFs (using only with pdflatex or Acroreader)