Skip to content

Instantly share code, notes, and snippets.

Created October 26, 2016 16:56
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
# A propagator node in an MQTT System
# It listens on messages/chirps via 433MHz radio and translates them to
# MQTT packages that are published over TCP/IP to a broker
from measurementtype import MeasurementType
from MQTTpublisher import MQTTpublisher
from radiolistener import RadioListener
import time
class PropagatorApplication:
wiringPiPinForReceiver = 2
brokerIP = ""
brokerPort = 1883
def __init__(self,wiringPiPinForReceiver,brokerIP,brokerPort):
self.wiringPiPinForReceiver = wiringPiPinForReceiver
self.brokerIP = brokerIP
self.brokerPort = brokerPort
def run(self):
# Defines the radio listener that uses pi-switch to listen to messages
# over 433 MHz radio
validMeasurementTypes = [
radioListener = RadioListener(self.wiringPiPinForReceiver,validMeasurementTypes)
# Defines the publisher that publishes MQTT messages to a broker
publisher = MQTTpublisher(self.brokerIP,self.brokerPort)
while True:
if radioListener.newMessageAvailable():
message = radioListener.getLatestMessage()
if message is not None:
# Take the radio message and publish the data as an MQTT message
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment