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:https://github.com/markszabo/IRremoteESP8266/blob/master/README.md

Using the TSOP4838 wired to 5V of Wemos board, GND and D2 (aka GPIO 4) and the example from the libary (https://github.com/markszabo/IRremoteESP8266/blob/master/examples/IRrecvDumpV2/IRrecvDumpV2.ino) 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: https://github.com/markszabo/IRremoteESP8266/blob/master/examples/IRServer/IRServer.ino

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: https://kaistech.wordpress.com/2016/10/11/calling-a-http-url-from-fhem-to-trigger-action/


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)



Code: https://www.dropbox.com/s/qjve588kcf6n0zk/FritzboxBell.zip?dl=0

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: https://kaistech.wordpress.com/2016/05/22/http-request-e-g-to-thingspeak-using-arduino-and-sim900-gsm-module/

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

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

git clone git://git.osmocom.org/rtl-sdr.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: https://www.raspberrypi.org/documentation/configuration/wireless/wireless-cli.md

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

DVB-T Live TV on Fire TV with Kodi using Raspi Raspbian Jessie, tvheadend, RTL2832U

Today I made my first steps playing around with the PVR (Live TV) capability of Kodi. My personal target is, to eliminate the additional sat receiver I have connected to my TV and add a recording feature.

To set up and test the general funcionality, I deceided to use a RTL-SDR (RTL2832U) I already own. The setup works as follows:

TV-Tuner usb stick (DVB-T, DVB-S etc) -> Raspi2 with tvheadend server -> network -> Kodi (on FireTV)

Lets start…

Update system

In general its not a bad idea to get the latest updates:
sudo apt-get update && sudo apt-get upgrade

Setup of tvheadend on Raspi2 with Raspbian Jessie:

Add keys of additional Repo to your system
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 379CE192D401AB61

Modify apt sources list
sudo nano /etc/apt/sources.list

Add line at end of file
deb http://dl.bintray.com/tvheadend/deb/ jessie release

Update apt sources
sudo apt-get update

Install tvheadend
sudo apt-get install tvheadend

Check if DVB-T tuner was detected (no driver install required):

[1430354.151936] usb 1-1.4: new high-speed USB device number 4 using dwc_otg
[1430354.263931] usb 1-1.4: New USB device found, idVendor=0bda, idProduct=2838
[1430354.263960] usb 1-1.4: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[1430354.263977] usb 1-1.4: Product: RTL2838UHIDIR
[1430354.263992] usb 1-1.4: Manufacturer: Realtek
[1430354.264007] usb 1-1.4: SerialNumber: 00000001

Sources used:

Configure tvheadend via webinterface

Open webinterface in webbrowser: http://:9981

Go to Configuration – DVB Inputs – Networks
Press “Add”, Select type “DVB-T Network”, give a name on your choice and select your region from Pre-defined muxes.
Press Create

Go to Configuration – DVB Inputs – TV adapters
Find your DVB-T device there, check “enabled” and select the network created on the step before under “Networks”

Go back to Configuration – DVB Inputs – Networks
Select you network and press “Force scan”
Wait a few minutes

Go to Configuration – DVB Inputs – Services and find detected channels there.
Mark all channels and press map all (this will create Channels out of the services, which you can find under Configuration – Channel/EPG – Channels

Go to Configuration – Access entries and create a user for streaming client devices. Check all services you want your devices to access.

Configure Kodi

Start Kodi and go to Options – Settings – Addons.
Find in category PVR the plugin “Tvheadend HTSP Client”
Configure the IP adress (of your raspi and the former createt user/password)

Done! You will find TV in your Kodi home.

Remark: I tried using tvheadend on a rasi where I had dump1090 for ADB-S installed before. Even after commenting the blacklist in /etc/modprobe.d and disabling the dump1090 service the channel scan and receiving a signal didnt work. Using a fresh raspbian minimal did the job…