Question

Is there any way to get a working 433MHz-Sender or -Receiver in a Python Thread?

I have tried those from Ninjablocks and those from Adafruit. But the Problem is that these are all c or c++ scripts, that are outputting to stdout and have no end of the output. I also tried piping them through a Unix-FIFO but there no data is transmitted until I close the Program (Ctrl + C) the second problem is, that the finished programs doesn't recognize my ninjablocks 433MHz Temperature Sensor, that is one of the most important parts of the system.

The 433 MHz Sender/Receiver are connected with the GPIOs of my Raspberry PI (Version B, Rev 2.0)

My Goal is to get the several 433 MHz Sensors (And some sonsors connected via i2c or spi these are already working) working with a python script, that does calculate some Rules (e.g. When Motion detected in Living Room, and between Sunset and Sunrise, turn Light on; Turn on Heating when Temperature Drops below 20°C etc.)

I have written a small program:

import RPi.GPIO as io
data = [] * 10000
while not interrupted:
  data.append(io.input(rxPin))
  io.wait_for_edge(rxPin, io.BOTH

I expected that code to output something like 1010101010101 because every Edge is recognized. My next step would have been to measure time between the edges and - based on that time - decide if it was a short 1/0 or a long 1/0 (433MHz seems to be encoded like short 1 long = = 1 long 1 short 0 = 0 or vise versa) but the output was something like:0110011001000000010110010 etc. so the python thread is missing some 1s and 0s, I think.

has anybody an idea to get that Wireless input in my Program?

Was it helpful?

Solution

If you are running python I guess you are using some kind of linux on the Raspberry Pi, am I right? Linux is not real time os, meaning your python loop does not run all the the time and can skip some GPIO data. You can solve it by either using a real time os like Chibios or use kernel module to stop all interrupts and sample the GPIO continuously as demonstrated in the Panalyzer project.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top