← Back to context

Comment by numpad0

17 days ago

But what do you use Pi GPIO for? Using Pi GPIO directly leaves pins unconfigured or stuck while your app is inactive. Aren't most need for GPIO better served by Arduino + PC?

I have a Pi Zero W that is a spooky-good GPS-backed NTP server. It relies on GPIO for getting tightly-accurate PPS pulses from the GPS module (which a USB-connected Arduino won't help me with -- the timing would be much sloppier).

I have also used a different Pi Zero W with an SDR dingle to decode APRS weather data, while also using GPIO to read a local DS18B20 temperature sensor and to switch a solid-state relay.

I could have done this last thing with any random Linux-ey PC plus an Arduino, but then I'd have two problems. (It would have also cost me rather substantially more money: I bought these Zero Ws very, very cheaply from Microcenter.)

  • https://github.com/DennisSc/PPS-ntp-server

    Not mine, just something I found. I had a feeling one could run a GPS backed NTP server on a microcontroller without too much difficulty.

    • Cute, but missing some things that real ntpd on *nix offers.

      And I like ntpd. I also like self-contained systems that I can tweak without using a compiler and a dev environment. I'm a fairly competent computer user, but I have zero aspirations of being a programmer when I grow up.

      (If a Pi Zero W can do the job, then: Why must it not do that job?)

      2 replies →

I don't think you understand how GPIO is used on a Raspbery Pi. You can flip GPIOs in a BASH script, or set events on them in Python. GPIOs are first-class citizens in Rpi land, which is what makes it so convenient: you get GPIOs + Linux, seamlessly.

I have a Pi4 hooked up to a motion detector, a camera, a solenoid and some SCRs for a floodlight. A python script waits for an event interrupt from the motion detector on a GPIO. Then it turns on the lights and opens a door via GPIO, and starts recording in another thread (via a pipe to gstreamer). When the motion times out, it pushes the video to an private S3 bucket (using my own handshake for a token so that it can't be spammed).

(I used to have some GPIOs connected to motorized cat toys so that I could trigger them remotely while watching an realtime stream, but that throttled the above camera which was more important.)

... It is also a BLE gateway that monitors 4 temperature sensors, and also pushes that data up to the cloud with another python script.

... and it also is an MQTT gateway for a few NXP WiFi devices scattered around the yard, and their data ... you guessed it... is pushed up to the cloud (they control sprinklers because BLE doesn't have the range). I can log into my personal website and turn sprinklers on from anywhere my phone works.

Sure I could do the WiFi and BLE with a PC, but why waste the energy and space when I can use a tiny Pi that is already doing a bunch of other things?

I just keep adding things to it because I have my own cloud system (HomeAssistant is a big fat bloated joke).

Having a good BLE sensitivity and WiFi chip on a tiny linux board that runs dozens of python processes listening to GPIOs, and running Gstreamer would be too much of a hassle with a PC and far beyond an arduino.

  • GPIOs are first-class citizens in Linux SOC land: every single ARM/RV SOC since before the Pi allows sysfs GPIO management using the exact same API.