简体   繁体   English

树莓派上的 rtl_433:通过 http 帖子将数据发送到 api

[英]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.

相关问题 如何通过蓝牙一次从树莓派 4 向多个树莓派发送数据? - How to send data to multiple raspberry pi's at a time from raspberry pi 4 via Bluetooth? Raspberry Pi蓝牙-发送数据 - Raspberry pi bluetooth - send data 如何通过蓝牙在两个树莓派之间进行通信并将传感器数据从一个树莓派发送到另一个树莓派? - How to communicate between two raspberry pi via Bluetooth and send sensor data from one pi to another? 如何通过HTTP发送二进制发布数据? - How to send binary post data via HTTP? 在Raspberry Pi按键上将数据发送到Arduino - Send data to Arduino on keypress Raspberry Pi 如何将数据从树莓派发送到网页? - how to send data from raspberry pi to a webpage? 通过python`request`代码将树莓派传感器数据发送到远程elasticsearch - Send Raspberry pi sensor data to remote elasticsearch via python `request` code 使用Raspberry Pi通过命令行参数将消息发送到LCD - Send message to LCD via Command Line argument using Raspberry Pi 可能吗? Python通过USB端口(Raspberry Pi)发送十六进制代码 - Is it possible? Python send Hex code via usb port (raspberry pi) 如何通过 USB 电缆将消息从 Raspberry Pi 发送到 Arduino - How send messages from Raspberry Pi to Arduino via USB cable
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM