skip to Main Content

I’m using rtl_433 (a command line tool) on a Raspberry Pi to receive data from a home temperature sensor. I get it to output JSON in the Terminal using this command:

rtl_433 -F json

An example of the output in the Terminal is:

{"time" : "2023-04-12 17:55:57", "model" : "Inkbird-ITH20R", "id" : 9537, "battery" : 90, "sensor_num" : 3, "mic" : "CRC", "temperature_C" : 17.700, "temperature_2_C" : 130.000, "humidity" : 130.000}

I need to POST that JSON to my server so I can process it. For debugging of my server app, it’s running on a different computer on port 5124 on the same network (123.123.123.123 is an obfuscated IP):

rtl_433 -F json | curl -H "Content-Type: application/json" -X POST -d @- 123.123.123.123:5124

Nothing is ever received by my server.

However if I do a quick test to make sure my server is receiving with this:

echo "{}" | curl -H "Content-Type: application/json" -X POST -d @- 123.123.123.123:5124

It works.

I think I must be piping the output from rtl_433 wrong but I’m not sure where.

2

Answers


  1. Try like a subcommand. Idk where your output from rtl_433 will be used, but adjust:

    curl -H "Content-Type: application/json" -X POST -d @- 123.123.123.123:5124 $(rtl_433 -F json)

    Login or Signup to reply.
  2. Not sure how exactly rtl_433 is supposed to function, but -w - writes its output to STDOUT, so this works for me:

    $ rtl_433  -w - | curl -d @- 127.0.0.1:8888
    

    (netcat listening on port 8888 – netcat -l -p 8888)

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search