I need a Python code sample for receiving device data readings from ChirpStack V4 to my app upon uplink events. Does anyone have an example?
Also what’s the most robust method for transferring data from chirpstack to another app, which one should i use?
Hi,
not sure if i understand your question correctly… but have you seen the documentation about integrations?
Personally i use http Integration - and there is a basic example in the documentation as well.
for test cases i used the MQTT Integration - here is a basic example for MQTT:
import paho.mqtt.client as mqtt
topic = "application/APPLICATION_ID/#"
broker_address = "xxx"
broker_port = "xxx"
def on_connect(client, userdata, flags, rc):
if rc==0:
print("The Application has successfull connected to the MQTT broker %s on port %s" % (broker_address, broker_port))
client.subscribe(topic)
print("The app has subscribed to %s topic" % (topic))
print("Start the loop...")
else:
print("Bad connection Returned code=",rc)
db_disconnect()
sys.exit("no connection possible")
def on_message(client, userdata, message):
//do your stuff here
client = mqtt.Client()
client.on_connect = on_connect
client.on_message = on_message
client.connect(broker_address, port=broker_port, keepalive=30) #connect to broker
client.loop_forever() #start the loop
hope this helps for a easy start
1 Like