Codesnippet: php / Raspberry Pi => Fritzbox => Telefonanruf

Jaaaa, ich hab‘ endlich auch einen Raspberry Pi und bin total begeistert – obwohl ich nach wie vor keine Ahnung habe was ich damit jetzt konkret anstellen soll🙂
Beim rumspielen ist jetzt ein Snippet entstanden, das sich per telnet an der Fritzbox anmeldet und per AT-Befehl kurz eine Nummer anruft.


$fritzIP  = '';
$pass     = 'xxxxxxxxxx';
$number   = '0173xxxxxx';
$sleep    = 10;

if ($fp = fsockopen($fritzIP, 23)) {
  $buffer = '';
  while (!feof($fp) && !preg_match('/password/', $buffer)) {
    $buffer .= fread($fp, 1);
  fputs($fp, $pass . "rn");
  fputs($fp, 'echo "ATDT' . $number . '" | nc 1011' . "rn");
  fputs($fp, 'echo "ATH" | nc 1011' . "rn");
} else {
  echo 'Telnet connection failed ' . $fritzIP;

Samsung Smart Remote Control + Arduino

Props to pjnewman who has reverse engineered the Samsung remote control tcp protocol. I’ve written a Arduino function based on the perl/php scripts and it works fine with my STB-E7500. Guess it should also work with any other Samsung Smart TV or receiver.

This sketch reads a command from serial and sends it to your TV/receiver. You can try KEY_CHUP or KEY_CHDOWN for example, more commands are documented here.

 * Based on:
 * You need the arduino base64 library:

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

char inbuf[100];
int inbufC = 0;

byte mac[] = {  0x0E, 0x0C, 0x29, 0x3E, 0xB1, 0x4F };
IPAddress server(192,168,178,22);
EthernetClient client;

void setup() {
  if (Ethernet.begin(mac) == 0) {
    Serial.println("Failed to configure Ethernet using DHCP");
    while (true) {}

void loop() {
  if (Serial.available() > 0) {
    int inByte =;
    if (inByte == 13) {
      inbuf[inbufC] = inByte;
      inbuf[inbufC+1] = '\0';
      inbufC = 0;
    } else if (inbufC > 100) {
      inbufC = 0;
    } else {
      inbuf[inbufC++] = inByte;

void sendCmd(char* cmd) {
  if (client.connect(server, 55000)) {
    uint8_t part1[] = {0,1,0,102,56,0,100,0,12,0,77,84,73,51,76,106,65,117,77,67,52,120,24,0,77,71,85,116,77,71,77,116,77,106,107,116,77,50,85,116,89,106,69,116,78,71,89,61,12,0,81,88,74,107,100,87,49,118,100,71,85,61,0,1,0,102,2,0,200,0,0,1,0,102,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
    char text[100];
    part1[74+0] = 5+strlen(text);
    part1[74+5] = strlen(text);
    for (int i = 0; i<strlen(text); i++) {
      part1[74+7+i] = text[i];

Calunium: Atmega1284 Arduino clone

A lot of us know this issue. The Atmega328 as used by Arduino Uno has too less SRAM, the Atmega2560 as used by Aruino Mega is not availabe as a DIP package and thus not really handy for do it yourself soldering. This is where the Atmega1284 comes into play. It is available as a DIP-40 package has twice as much RAM as the 2560 and costs only about 7 EUR.

Steve Marple has developed the Arduino compatible Calunium board and shared the PCB layout as open source. Cool stuff, thank you Steve🙂

I’ve ordered a couple of these boards manufactured by iteadstudio three weeks ago and they arrived yesterday. As I don’t need all of them you can have one for 5 EUR (including shipping), just drop me a message.
mailto: s{at}sui{dot}li

Introducing CRON, SUNRISE and SUNSET

This new feature allows you to trigger events at certain times. The syntax for crons is
[CRON:year,month,day,hour,minute,dayofweek:trigger], you can use an asterisk as wildcard and for example if you want to trigger an event every day at 13:15 you need to write [CRON:*,*,*,13,15,*:trigger] into the IF section of that event.

With SUNRISE and SUNSET you can trigger events at… well… sunrise and sunset🙂
As sunrise and sunset times are depending on your location you need to pass your geo coordinates. For example Hamburg is located at 53.55N, 9.99E and the sunrise/sunset triggers are like [SUNRISE:53.55,9.99:trigger] and [SUNSET:53.55,9.99:trigger]

Ardumote progress

It’s been over half a year since making the first announcement of ardumote. Now I’m actually using it myself at home to open doors and switching lights🙂

Here you can see my arduino which is mounted to the wall next to the door in the corridor. As you can see there are two servomotors stucked to the door opener with double-faced adhesive tape. They mechanically push the buttons. I know I could have connect them directly with optocouplers but since I live in a rented flat and didn’t want to mess things up this seemed to be the best solution.

Now let’s have a look in detail. There is also a 433MHz transmitter and receiver connected, which allows me to use a simple remote as input device and operate low cost RC power sockets. I use a arduino mega cause the RCSwitch didn’t run together with the ardumote arduino library due to memory limitations and unfortunately I don’t have much hope by now to get it working on a arduino uno ever. Nevertheless there is a example sketch without RCSwitch for uno/duemilanove provided in the lib. I’ve also connected a LM35 temperature sensor cause I had one to spare.

All the input, output and communication devices are straightforward added in the sketch:

    Copyright (c) 2012 Suat Özgür

    Ardumote example sketch for Mega boards

    Pin   Device
    2     433Mhz AM Receiver
    4     Servo Motor
    5     Servo Motor
    42    Status LED (Recieve)
    44    Status LED (Transmit)
    46    Status LED (IRC Connection)
    A1    433Mhz AM Transmitter
    A10   Analog temperature sensor
// ==== Basic configuration =====================================

#define ARDUMOTE_SHARED_SECRET "01234567890abcdef01234567890abcd"

#define STATUS_LED_RX  42
#define STATUS_LED_TX  44
#define STATUS_LED_IRC 46

byte mac[]     = {  0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };

// ==== General Includes ========================================
[Snipped... a lot of includes. Find them in the lib examples]
// ==============================================================

void setup() {

  // Init ethernet

  // Init ardumote itself
  ArdumoteMD5 myArdumote;

  // Init maintenance modules (Do not remove)
  SensorMaintenance s0;
  myArdumote.addSensorModule( &s0 );

  ActorMaintenance  a0;
  myArdumote.addActorModule( &a0 );

  // Init ComModules
  ComEthernetIRC c2;

  // Init sensors
  SensorRCSwitch s1;
  s1.setup("433Mhz RX", 0); // 433Mhz AM Receiver at Pin 2
  myArdumote.addSensorModule( &s1 );

  SensorAnalog s2;
  s2.setup("Temperature", A10, 60); // LM35 Sensor Pin A10
  myArdumote.addSensorModule( &s2 );

  // Init actors
  ActorRCSwitch a1;
  a1.setup("433Mhz TX", A1); // 433Mhz AM Transmitter at Pin A1
  myArdumote.addActorModule( &a1 );

  ActorServo a2;
  a2.setup("Servo 1", 5); // Servo motor at Pin 5
  myArdumote.addActorModule( &a2 );

  ActorServo a3;
  a3.setup("Servo 2", 4); // Servo motor at Pin 4
  myArdumote.addActorModule( &a3 );

  // run
  while (true) {


void loop() {

There is no business logic implemented in the arduino. It’s just about receiving and sending data to a webservice (aka „the cloud™“). There is a very simple ardumote protocol on top of IRC. I’ve chosen IRC because it’s also very simple, scalable and there are lots of ready to run stable IRC daemons around to use. XMPP would have been a cooler choice but as it deals with comparatively complex XML data, the atmega chips don’t have much resources at all and dealing with string operations in C++ is really pain in the a**… maybe somewhen in future🙂

Of course good old HTTP would also be an alternative but as it’s stateless you need to deal with DynDNS and router configuration stuff to allow the webservice to connect back to the arduino. With IRC the arduino connects to the webservice and keeps being connected and beside that in this way the latency is shorter and the data volume without tons of headers is much smaller.

Let’s come to the ardumote webservice.

Beside your arduino with all that sensors and actors you can also add other controller types with input and output devices. For now that is a „virtual remote panel“ with „virtual button“ input devices to use as a browser or smartphone interface. There is already a android app to use these virtual remote panels in a convenient way.

A „webservices controller“ controls onlineservices like Twitter, E-Mail or else and I’m already planing a android phone type controller so it would be possible to use the smartphone inputs (accelerometer, GPS, compass) and outputs (action bar notification, vibration), too. Ninjablocks might also be interesting in future.

Based on your input devices you can define events and actions with your output devices to be executed when the event occurs.
In this example I have my arduino controller in the corridor, a virtual remote panel with a „Haustür“ (thats german for „front door“) button and a webservices controller with my Twitter account linked to it. Whenever I push the button on my phone, the front door opens, the light in the corridor is switched on and a tweet is sent to my Twitter account.

That’s all folks… well, for now. Next steps will be some bugfixing, pimping up the virtual remote panels and enhancing the android app.

Feel free to sign up, download and play around with ardumote and share your thoughts in the forum. But keep in mind it’s still alpha and not stable yet.