Using rtl_433 as a receiver to generate output codes for python script

1,826 views
Skip to first unread message

Atle Samuelsen

unread,
Feb 25, 2018, 4:30:16 AM2/25/18
to rtl_433
Hi Guys,

I'm here at home, trying to build a small home-automization system. I've been testing your awsome rtl_433 app! 

But, I was thinking.. Would it be possible to make it "automagically" output the "codes" that could be used with a python script for sending events ? 

Like the link http://www.instructables.com/id/Super-Simple-Raspberry-Pi-433MHz-Home-Automation/ explains how I could do it with a raspberry pi, and a 433 receiver and sender. 
But, I think the RTL_433 would do this allot better!

So, A combination with a 433 sender, and the Rtl433 receiver, you could basically build your own household gateway application for ~ 5 bucks + the computer you would run it on (for me a raspberry pi)


So, Long text, not well formatted.. but simple question: Has anyone made a "python-gpio-out" module for rtl_433?

-a

Benjamin Larsson

unread,
Feb 25, 2018, 7:14:49 AM2/25/18
to rtl...@googlegroups.com
Hi, I've had some thoughts on how to do it. I ended up building some
hardware (Arduino mini + 433MHz sender connected to arduino gpio port)
and firmware for the arduino. The problem is that rtl_433 doesn't output
enough data for you to reconstruct the signal just based on the events.
So it is much easier to just hard code the signal you need for your use
case.

Ideally you would a feature complete signal syntax that could describe
the signal you need. And then what values you can map to that. And then
a bitstream writer for that. And then several bitstream sender modules
for different hardware. A fairly complex system for limited generic use.

Anyway if someone still want to work on it I would suggest to base it on
the CC1101 transceiver chip hooked up to a mcu. For example this:

https://www.ebay.com/itm/CC1101-STM8-testing-board-E06-TB07-with-micro-USB-interface-for-Ebyte-E07-module/192222922237?ssPageName=STRK%3AMEBIDX%3AIT&_trksid=p2057872.m2749.l2649

https://www.ebay.com/itm/E07-M1101D-TH-10dBm-wireless-transceiver-433MHz-CC1101-SPI-module-spring-antenna/191974909018?ssPageName=STRK%3AMEBIDX%3AIT&_trksid=p2057872.m2749.l2649

This hardware is quite generic in what it can transmit. But the transmit
part is easy, the hard part is extending rtl_433 and develop all the
bitstream generators and the framework for it.

MvH
Benjamin Larsson
Message has been deleted

Khalid Baheyeldin

unread,
Feb 28, 2018, 2:37:28 PM2/28/18
to rtl_433
On Sunday, February 25, 2018 at 4:30:16 AM UTC-5, Atle Samuelsen wrote:

So, Long text, not well formatted.. but simple question: Has anyone made a "python-gpio-out" module for rtl_433?


I use Home Assistant with MQTT for collecting data from sensors via rtl_433.

This shell script does the trick:

MQTT_HOST="localhost"
MQTT_TOPIC="home/something"

PREV_LINE=""

# Start the listener and enter an endless loop
rtl_433 -g 40 -F json | while read LINE
do
  # Log the raw data to file, so we can debug them if needed
  echo $LINE >> rtl.log

  # Skip duplicate lines
  if [ "$LINE" != "$PREV_LINE" ]; then
    # Extract the ID of the sensor
    ID=`echo $LINE | jq .id | tr -d '"'`

    # Send the entire JSON message to MQTT
    mosquitto_pub -h $MQTT_HOST -t $MQTT_TOPIC/$ID -m "$LINE"
  fi

  # Set the previous line
  PREV_LINE="$LINE"

done &

It uses jq to extract info from the json message that rtl_433 receives, and mqtt publishes that. But depending on your specific requirements and setup, you may not need that part.

For your question: you want to send codes, not just receive them?

If you use Home Assistant, it has this integration built in, as RF Switch:

https://home-assistant.io/components/switch.rpi_rf/

If you don't want to use Home Assistant, you can use the rpi-rf module

https://pypi.python.org/pypi/rpi-rf

In both cases, you need to get a pair of cheap transmitters/receivers and a Raspberry Pi.


Atle Samuelsen

unread,
Mar 4, 2018, 2:22:10 AM3/4/18
to rtl_433
Thank you for your support! 

will try to test this today ;)

-a

Asif Ayan Mithawala

unread,
Jan 22, 2019, 3:14:24 PM1/22/19
to rtl_433
Thank you!!!

I did like this:

PREV_LINE=""

/usr/local/bin/rtl_433 -F json -G | while read LINE
do
  # Skip duplicate lines
  if [ "$LINE" != "$PREV_LINE" ]; then

  DEVICE="$(echo $LINE | jq --raw-output '.model' | tr -s ' ' '_')" # replace ' ' with '_'
  DEVICEID="$(echo $LINE | jq --raw-output '.id' | tr -s ' ' '_')"

  MQTT_PATH=$MQTT_TOPIC

  if [ ${#DEVICE} > 0 ]; then
    MQTT_PATH=$MQTT_PATH/"$DEVICE"
  fi
  if [ ${#DEVICEID} > 0 ]; then
    MQTT_PATH=$MQTT_PATH/"$DEVICEID"
  fi

  # Create file with touch /tmp/rtl_433.log if logging is needed
  #[ -w /tmp/rtl_433.log ] && echo $line >> rtl_433.log
  echo $LINE | /usr/bin/mosquitto_pub -h $MQTT_HOST -i RTL_433 -l -t $MQTT_PATH
Reply all
Reply to author
Forward
0 new messages