Calling a HTTP url from FHEM to trigger action

I need to call HTTP urls from FHEM for several things, like firing IR signals to my TV (see my post: ).
As far as I know, FHEM currently does not have a way to do this easily (HTTPMOD seems to be a bit too complicated for that).

My solution is based on a simple PERL script which is called directly from FHEM:

Script /home/pi/

#!/usr/bin/perl -w

use warnings;
use strict;
use Time::HiRes qw/time usleep/;
use Socket qw(:all);
use POSIX ":sys_wait_h";

use LWP::Simple;

#print $ARGV[0];
#print "\n";

my $url = '';
$url .= $ARGV[0];

my $content = get($url);
die "Can't GET $url" if (! defined $content);

Then make it executable: sudo chmod +x /home/pi/

Now you can call it from FHEM e.g. from a DOIF like this:

define DOIF_Dummy_WohnzimmerTVMode DOIF ([Dummy_WohnzimmerTVMode]) ({system ("/home/pi/ 50153655 &")})

Note: Here I pass the a argument to the Perl script which is attached to the URL.

Wifi Infrared IR Remote Extension using ESP8266

In the last months we integrated a rising count of IoT devices into our FHEM based homeautomation system (Wifi switches, LED lights, door and window sensors etc.). Nevertheless, most of my entertainment devices (TV, Sounddeck) were not integrated and required their own infrared remote to be turned on, switch channel, etc. A infrared adapter needed to get in place to integrate these devices into my tablet based FHEM interface.

As I had a lot of success using ESP8266 modules for 24×7 running devices in the past, I deceided again to use a ESP8266 (Wemos D1 mini module, cheap available at Aliexpress). My aim was to let the ESP fire two IR leds which are installed directly in front of at TV and Sounddeck. A HTTP server running on the ESP receives the IR request in form of decimal IR code (which I identified before using a IR receiver on a ESP).

– ESP8266 (e.g. Wemos D1 mini or NodeMCU)
– 2x IR transmitting LED (any 950nm IR led will work), ~20Ohm 0.5W resistor, NPN transistor (any NPN like BC547, BC548 or PN2222 will work) , 330Ohm 0.125-0.25W resistor
– optional to identify IR codes using your devices IR remote: IR-receiver 38kHz (e.g. TSOP 4838)

My code is based on this nice library and its examples:

Using the TSOP4838 wired to 5V of Wemos board, GND and D2 (aka GPIO 4) and the example from the libary ( I identified the following IR codes for my device (library will print out HEX but DEC required for HTTP call lateron):







The hardware of the IR transmitting server is set up as follows. I use the 5V of Wemos board which is hardwired to the 5V rail of the USB power supply:

The IR leds are consuming about 100mA of current. I deceided to run 2 in series with a 20Ohms 0.5W resistor burning about 2Volts (3Volts burned by two led and transistor collector-emitter). The NPN transistor is driven by D2 (aka GPIO 4) via a 330Ohms resistor.

My Arduino sketch for the ESP bases on this example from the library:

A few pictures of the hardware:

Finally now I am able to put my old IR remotes away and send out IR commands via simple HTTP request to the ESP (e.g.

The examples of the library are using GPIO 2. So the PIN needs to be updated in the Arduino sketches to GPIO 4.
I configured my DSL router, to assign the same IP for the ESP all the time.

Hint: See my next post how to call the IR server from FHEM:

Door bell via SIP call with Arduino and Ethernet shield

Since mid of the 90s we had a ISDN PBX at home. This PBX had a port to connect a door bell pushbutton and perform a ring to a defined group of internal phones. Now we switched over to SIP trunk (Sipgate) and a AVM Fritzbox as internal PBX. Unfortunately the Fritzbox does not have such a door bell port, so I had to develop a solution:

– Arduino Uno
– Arduino Ethernet Shield
– Door bell pushbutton triggering Arduino digital input pin via optocoupler
– Performing SIP call to a Fritzbox callgroup (eg **701) when button is pressed
– watchdog to restart Arduino on hangup

During the first tests I found out, the Ethernet Shield tends to hang up after a few hours. Therefore, after pressing the pushbutton the Ethernet Shield will be reset before the SIP call is being performed.
To reset the Ethernet shield I connected a Arduino digital out pin to the reset port of the Ethernet Shield which goes to LOW to reset the shield. Beware, that normally the shields reset pin is connected with the reset pin of the Arduino via pin header. This would do a reset of the Arduino as well. To prevent this, I bended this one pin of the shield to prevent from connecting.
Additionally, I used a 0.5W resistor to drive some power through the pushbutton. I found out, that these kind of buttons tend to have a problem when the current is too low (e.g. because of corrosion).

In the Fritzbox the following needs to be prepared:
– create a SIP user/password for the door bell device
– create a group containing all devices which will ring on door bell press



(on the second picture you can see the reset pin of the Ethernet Shield bond by side)




The device is running for more than one year now and seems to be very reliable.

Bee Stock Hive Logger (weight, temperature, humidity, light) via 2G/3G using GSM Sim900

Inspired by the demand of a working collegue of mine, who has a few bee populations, I developed a small Arduino based device which:

– measures weight, temperatures (in bee stock, outside, in electronics box), humidity, light intensity, battery voltage
– does temperature compensation for weight result
– transfers results via 2G/3G network to a backend server
– goes into a deep sleep to save energy (because we have to use a battery, because of offsite installation on field/ in forrest)

There are a few comparable projects out there in the hackerspace, which did not fit our requirements, but were used as inspiration regarding different aspects:

A PCB was created to connect all the components in a clean way (the breadboard was horrible in the end):
– Arduino Pro Mini (I removed the power led to safe power)
– Pololu 5V, 500mA Step-Down Voltage Regulator D24V5F5 (to power the Arduino directly and efficient with 5V)
– Pololu 5V, 2.5A Step-Down Voltage Regulator D24V22F5 (to power all sensors and the Sim900 and shut them down via the POWER-EN pin of the regulator)
– Sim900 GSM module (connected via pin header)
– 2x HX711 breakout boards as we use two weight cells (via pin header)
– DS18B20 temperature sensor on pcb (for temperature directly at electronics; for temperature compensation)
– DS18B20 IP67 with cable (for temperature inside stock)
– DHT21/DHT22 with cable (for outside temperature/humidity; for temperature compensation)
– voltage divider (for battery voltage monitoring)
-Luxmeter BH1750FVI via I2C

The working procedure will be:
– wakeup from sleep, powering up devices, waiting 20sec for let them come up
– communicate sim pin to Sim900 module to let it search for cellular network and login
– performing 5 measurements with a delay of about 10 secs, calculation the median of each value
– dial into internet with Sim900, transferring data to Thingspeak via http-URL-call
– shutting down devices, bring Arduino into deep sleep for 1h

The Sim900 module needs to be prepared (correct band selection, fixed baudrate 4800) as described here:

The first version of the PCB is currently in production at OSH Park and looking like this:


I will post pictures of the assembly after building it up. When confirmed to work properly, I will publish the schematic as well the Arduino code here.

HTTP Request (e.g. to Thingspeak) using Arduino and Sim900 GSM Module

Sim900 module connected to Arduino
– Sim900 GND to Power-Supply GND
– Sim900 5V to Power-Supply 5V (not Arduino 5V, can be up to 2A!)
– Sim900 GND to Arduino GND
– Sim900 TXD to Arduino PIN 2
– Sim900 RXD to Arduino PIN 3

Using a Softserial passthrough sketch @4800baud

Initial configuration using AT commands

//Set to European Mode 900/1800
//Set to fixed Baudrate 4800

AT-Command-Set for HTTP-request

//Should reply ok if ready

//Unlocking SIM


//Should reply +CREG: 0,1 if ok

//Configure bearer 1 (change to your datat; this is for Congstar Germany by T-Mobile)

//Open bearer 1

//Check bearer 1 (should reply IP)

//Start HTTP using bearer 1



//Echo HTTP response

Raspberry as RTL SDR server

First of all blacklist DVB-T module:
sudo nano /etc/modprobe.d/rtl-sdr-blacklist.conf

Add to file:
blacklist dvb_usb_rtl28xxu
blacklist e4000
blacklist rtl2832

Then based on

Using the Raspberry Pi as an RTL-SDR dongle Server

Raspberry Pi as Remote Server for RTL2832u SDR

sudo apt-get install -y git cmake pkg-config libusb-1.0 build-essential

git clone git://
cd rtl-sdr/
mkdir build
cd build
sudo make install
sudo ldconfig

sudo reboot

rtl_test -t

rtl_tcp -a IPofRaspi

WiFi WLAN on Raspi

Just a reminder to myself how to set it up🙂

Based on:

Scan and show networks:
sudo iwlist wlan0 scan

Add network:
sudo nano /etc/wpa_supplicant/wpa_supplicant.conf

Add to file:

Then do a
sudo ifdown wlan0
sudo ifup wlan0

Check if it connected and git IP:
ifconfig wlan0