[英]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.我正在使用我的树莓派上的加密狗从气象站接收天气数据,该加密狗通过 wifi 连接互联网。 Now I want to send this data to a rails api/app to save it there in a database.
现在我想将此数据发送到 rails api/app 以将其保存在数据库中。 The rails app runs on another server, so I want to post the data via http.
rails 应用程序在另一台服务器上运行,所以我想通过 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.
我无法将 curl 依赖项添加到 rtl_433 项目( https://github.com/merbanan/rtl_433 )以将数据直接发送到我的后端。 Am I able to run the rtl_433 for example with a python script like:
例如,我是否能够使用 python 脚本运行 rtl_433,例如:
rlt_433 -F json
and take that output to send it to my backend or how can I realize that? rlt_433 -F json
并将 output 发送到我的后端,或者我该如何实现?
You should be able to execute rtl_433
as a subprocess using the subprocess module.您应该能够使用subprocess模块将
rtl_433
作为子进程执行。 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.通常你只会使用
subprocess.run
,但由于rtl_433
产生 output 直到它被杀死,你将需要使用subprocess.Popen
并解析 output。
Another option is to pipe the output of rtl_433
to your program and using input()
or sys.stdin.readline()
to read lines.另一种选择是将 rtl_433 的 pipe 和
rtl_433
到您的程序并使用input()
或sys.stdin.readline()
读取行。 Like rtl_433 -flags | python3 script.py
喜欢
rtl_433 -flags | python3 script.py
rtl_433 -flags | python3 script.py
. rtl_433 -flags | python3 script.py
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.