jckuester / weather-station

A Prometheus exporter for 433 MHz temperature and humidity sensors
Apache License 2.0
64 stars 6 forks source link

[Question] Arduino vs GPIO? #11

Open geekdave opened 6 years ago

geekdave commented 6 years ago

Hello,

Just stumbled upon this project after building something similar from another guide: https://timleland.com/wireless-temperature-sensor/

It seems we both used a 433mHz receiver, but you plugged yours into an Arduino, which in turn was connected to your Pi via USB.

In my case, I attached a similar receiver to the GPIO pins of my Pi 3.

I'm pretty new to all this, so I was wondering if there was any special reason to use the intermediary Arduino, instead of connecting directly to GPIO, and if the rest of your instructions could work for someone like me who used a direct GPIO approach.

Thanks! Dave

skunkr commented 6 years ago

Hi, same question from me too, it would be nice being able to use the Pi directly. Can this nice aplication do that too ? Thank you very much !

jckuester commented 6 years ago

Thanks for being interested in my project!

The main reason to use the Arduino is performance. Instead of letting the PI periodically poll for signals and compress the timings, the Arduino is doing it externally on it's own chip. This is the software flashed to the Arduino for that reason. With the PI 3, performance is probably not that critically anymore, though.

This is the what the Arduino prints to a device file (usually /dev/ttyUSB0) and what the weather-station takes as input:

RF receive 453 1992 88 9228 0 0 0 0 01020102020201020101010101010102010101010202010202020202010102010102020203

If you want to use the receiver connected directly to GPIO, you somehow need it to output signals in the same format as shown above. How do signals look like received via GPIO, are they raw?

geekdave commented 6 years ago

Thanks for the insights, @jckuester ! I'm using a Pi3, and indeed I'm observing that the program that polls and decodes the signal is consuming about 25% CPU constantly. I'm using a dedicated Pi for this purpose, so this is fine for me. Here is the code I found from the tutorial which polls and decodes the signal: https://github.com/timleland/temperaturesensor/blob/master/capture.cpp

I modified it slightly to output the temperature readings to a log file instead of to a database. I'm then capturing metrics from the log file and tracking them over time with prometheus.io. I'll write-up a blog post about this sometime soon.