简体   繁体   中英

rtl_433 on raspberry pi: Send data to api via http post

I'm receiving the weather data from my weather station with a dongle on my raspberry pi, that has internet connection via wifi. Now I want to send this data to a rails api/app to save it there in a database. The rails app runs on another server, so I want to post the data via http. How can I do this. I can't add the curl dependency to the rtl_433 project ( https://github.com/merbanan/rtl_433 ) to send the data directly to my backend. Am I able to run the rtl_433 for example with a python script like:
rlt_433 -F json and take that output to send it to my backend or how can I realize that?

You should be able to execute rtl_433 as a subprocess using the subprocess module. Normally you would just use subprocess.run , but since rtl_433 produces output until it is killed, you will need to use subprocess.Popen and parse the output.

Another option is to pipe the output of rtl_433 to your program and using input() or sys.stdin.readline() to read lines. Like rtl_433 -flags | python3 script.py rtl_433 -flags | python3 script.py .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM