Lurker News
I have Raspberry Pi and I mainly use it for VPN and piHole. I’m curious if you have one, have you found it useful? What do you do with your Raspberry Pi?

Comments (1,069) 486 threads

Earlier comments
quartz5 replies#
The coffee machine in our office is controlled by blockchain NFTs and a Raspberry Pi:

Once authenticated, an owner of the NFT can select their coffee type on their phone which then signals the Raspberry Pi to make whatever coffee type was selected by jumping the contacts that used to be pressed by the machine's buttons (which have been removed).
It's a cool gimmick, fun to show off to visitors, gives us a nice record of who is making coffee (since each NFT's owner is unique and trackable), limits users to those with the NFT without us having to build usernames/passwords, and is also how I make my coffee each afternoon.

Piskvorrr1 reply#
Is it HTCPCP-enabled? Inquiring minds want to know!
jtolly710#
Hopefully including HTTP Error 418 too!
amelius2 replies#
> gives us a nice record of who is making coffee

Is that allowed by GDPR?

coolspot#
If you don't serve cookies it is okay.
quartz#
If an EU user tries to make coffee we redirect them to a "this content is unavailable in your region" page so I think we're 100% good to go with GDPR compliance.
notdang1 reply#
What coffee machine are you using?
quartz#
It's a Nespresso Lattissima-- the old version where the buttons were physical push-to-press. We pulled the buttons off and soldered wires to the board inside via a 4-channel relay.
myhay#
Very similar to what we have in the office as well. The difference is that we are using bluetooth and NFC of the mobile as authentication method.
trimbo1 reply#
Does it record on the blockchain who took the last cup of coffee and didn't make more?

Everyone in every office would pay good money for that.

quartz#
It doesn't write individual orders to the chain. It could if we funded a wallet to pay the gas to write those records but right now it just does authentication of NFT ownership to grant access, which is conveniently free. The history logs are stored locally.
strags4 replies#
I discovered that my 17-month old son loves to mess with stereo controls. So I bought a few rotary encoders and neo-pixel rings - build a wooden enclosure with a plastic faceplate, and wrote some code to generate fancy light and audio effects when he turns/clicks the knobs. He loves it.
Sileni#
Watch out, you'll have a DJ before you know it.
1024core1 reply#
I'm thinking of doing the same for my kid. Any photos/description?
strags2 replies#
It's actually quite a bit louder than this now. Also, the lights aren't quite as infant-retina-searingly-bright as the camera would have you believe.

https://www.youtube.com/watch?v=xtE8oE9GOsM
Currently it's still running my test code, which just lets him mess with volume/pan/pitch. I need to get around to writing something a bit fancier.
Tech deets: It's just a RPi3 with most of the stuff written in Python. I tried to get a bunch of Python audio libs working, but gave up and wrote my own C++ module for sample mixing. The NeoPixel rings are driven via the SPI output, and the rotary encoders/switches are just hooked up to random GPIOs.

syspec#
He really does love it. Amazing! Hahaha
MrZongle2#
That's awesome! Great job!
msoucy1 reply#
Well now that I've seen the Furby Organ I'm not going to sleep tonight...
ryanmercer#
Watch the one where he makes some of them nekkid, it's more recent. THAT is terrifying.
cloverich#
I would love to learn more about how you did this, and what it looks like. Have you written something up about it?
scottlamb5 replies#
A security camera NVR. (Help wanted! I'm developing it here: https://github.com/scottlamb/moonfire-nvr I'm proud of the design but it's still far from a polished system that does everything a reasonable person would expect. Lots of opportunities to extend it if you're looking for a fun Rust + Javascript project.) A Raspberry Pi 2 will run a working setup; the new Raspberry Pi 4 should be a lot more pleasant in terms of being able to recompile it in a reasonable time, transfer video segments quickly, etc. I think the biggest missing piece is a real-time clock. Faster flash, builtin SATA, and a builtin NPU would also be great of course but not realistic for $35.

A home theater control system. The Pi uses HDMI-CEC, my Samsung TV's EXLINK (their protocol over RS-232), Roku's HTTP interface, etc. and an Android app is the frontend. I wanted to make this into a nice polished thing other people could use but have given up on the idea for now. The thing is that media components are super finicky, many things need special support written just for them, and you really have to extensively tweak them to see how they function as a whole. (eg does your TV turn off your stereo receiver when it turns off itself. The answer varies based on the model and settings of both components.) HDMI-CEC doesn't live up to its potential in this regard.
[edit: fixed hyperlink]

j1elo#
You got a '>' as part of the URL, which goes 404! Just removing it should do.
aloer1 reply#
Moonfire NVR looks like an amazing project that I can learn a lot from for an entirely different project with streams and stuff that I’m interested in and have zero experience with!

Also great that it’s written in rust
Is there any way to test it without rpi/camera?
If I understand the readme correctly, you store frames individually (as jpegs?) on disk and construct flexible mp4 streams on the fly. Naturally I would have assumed that this would be inefficient so I’m wondering if I got this right, not very familiar with stream/video/codec tech

scottlamb1 reply#
Thanks!

> Is there any way to test it without rpi/camera?
Without a Raspberry Pi, yes. It should run on any Unix-like OS. I've tested Linux/arm32, Linux/x86-64, and macOS/x86-64. (For the last, install ffmpeg via homebrew first.)
Without an IP camera...hmm, there are probably some public RTSP live streams somewhere. Not sure offhand.
> If I understand the readme correctly, you store frames individually (as jpegs?) on disk and construct flexible mp4 streams on the fly. Naturally I would have assumed that this would be inefficient so I’m wondering if I got this right, not very familiar with stream/video/codec tech
No, I store the video stream in the compressed form the camera gave it to me. Currently that's H.264; it wouldn't be hard to add H.265 support as well. I break it apart into roughly one-minute segments at convenient locations. The schema design doc talks about that here: https://github.com/scottlamb/moonfire-nvr/blob/master/design...
.mp4 serving will aggregate those together (maybe clipping the start and end segment) to give you a .mp4 segment for any time range of interest. It comes up with a mp4::File struct which knows what video segments to serve and maps byte locations to parts of the .mp4 container format. I don't have a good doc about how this works other than the source code right now. https://github.com/scottlamb/moonfire-nvr/blob/master/src/mp... [edit: and you probably won't be successful in understanding it without having a pdf of the ISO/IEC 14496-12 specification open next to it.] Here's some debug output for generating a five-minute video segment: https://pastebin.com/Wzfz7BF7
Storing individual frames as jpegs would be inefficient I agree in all sorts of ways: recording CPU (you have to decode the H.264 and re-encode it as JPEGs), disk space, disk seeks, playback bandwidth, browser CPU, etc. My understanding is this is how Zoneminder currently works. I imagine it worked better with the cameras Zoneminder was originally designed for: low-resolution, low-qps webcams that didn't do their own H.264 encoding.

aloer#
Thanks a lot, I had only seen the guide/schema document

What I’m interested in is primarily flexible mixing of different streams so I’ll definitely have a look here

convivialdingo1 reply#
I've been looking for something like Moonfire! Do you have any recommendations for an outdoor camera, I was looking at Lorex but don't have much experience? Thanks!
colek421 reply#
I need to dig into this later, but one suggestion is to put your video chunker in a separate process, this way you can scale across multiple nodes.
scottlamb#
It doesn't do enough work today to require that, given that it's meant for home use and doesn't decode/re-encode the video. One Raspberry Pi 4 with a couple 6 TB drives in an external USB3 SATA enclosure should be sufficient for 16+ cameras in terms of CPU, USB3 bandwidth, Ethernet bandwidth, spindle time, storage capacity, etc. If for some reason you need more security cameras than that in your home, you can probably afford a single machine beefy enough to handle it.

The only thing I anticipate being a significant performance challenge is on-NVR motion detection. Most likely that will end up being separate processes that download the video and annotate it via the HTTP API. Those workers could then run on separate machines if needed. The primary machine would have sufficient bandwidth to support this.

nprateem1 reply#
I've wanted some security cam software to run on a Pi for ages because the stuff shipped on my IP cameras is awful. Do you have any plans to offer a callback system, e.g. so when some customisable event happens (change detection, perhaps between certain hours of the day/night) it could then callback to a custom script for further processing?
scottlamb#
My plan is to extend the HTTP API [1] with an event stream [2] that can be accessed via https-with-a-session-cookie or http-over-Unix-domain-socket. It could be used by browser-based Javascript, mobile clients, and automated event subscribers. One could write a subscriber that launches a subprocess or runs scripts in-process. I think there are a few advantages over doing this directly from the main process:

* it keeps the main process logic minimal. This API is needed anyway to make a good web interface.
* it's the easiest way to have nothing else run as the same Unix user as the main process. My design is similar to a DBMS in that that you should only ever be accessing Moonfire NVR's data through its interfaces (except for development or emergency maintenance purposes). Having a dedicated user helps enforce that.
* your script can run on a separate machine if desired
Also a couple disadvantages:
* two services to set up (main process + subscriber) instead of one.
* there's the possibility that an event happens while the main process is running but your subscriber is disconnected, so the event gets committed to the database but you never see it. The easiest thing to do is to accept skipping these (as would happen anyway if the main process is down). Or the main process could buffer events for a while. Or the watcher could have logic to "catch up" (which unfortunately means not only more complex logic but also keeping state somehow).
If you'd prefer another approach or want it sooner than I'm likely to implement it, please contribute! I have my priorities & design ideas, but if you chip in, you get a say in both. And I go pretty slowly on my own anyway, so if you're able, it's worth chipping in even if you agree with me about everything.
[1] https://github.com/scottlamb/moonfire-nvr/blob/master/design... [2] https://github.com/scottlamb/moonfire-nvr/issues/40

sequoia4 replies#
I run a plex media server on my 3b+. The server is on the wall below my router (attached via ethernet), a 2TB HDD sits next to the server. I put movies & TV for my kids on the server, then they can watch on one of two TVs in the house via Roku. It's good for getting them off trashy Netflix movies & making classics (or what I consider classics at least) available to them.

I chose this configuration rather than running plex in the cloud because a) don't want to pay monthly forever for something I use a few times a week; b) less wasting power and c) this at least theoretically can work during an internet outage (though plex authentication may make this difficult). I configured the HDD to spin down after 20 seconds of no r/w, so the whole thing draws very little power while idling (or so I assume).
The major limitation of this setup is that the pi cannot handle video transcoding. As long as I transcode to something the Roku supports natively this isn't an issue: transcode once (on my laptop), put it on the Pi, play whenever. I have yet to script this process but that's my next step in the project.
It will probably be a year before I realize any cost savings (a friend pays CAD20/mo for a hosted setup which also handles on-the-fly transcoding), but, well, it's a simple server and I just wanted to do it myself, gosh darn it!

cylentwolf1 reply#
How does the HDD connect to the pi? just via usb in an separate enclosure?
sequoia#
Yes.
treelovinhippie1 reply#
What Plex install guide did you use? Few months ago I tried to install Plex to a pi already running Pihole but couldn't get it to work.
ric2b#
You can run plex via docker, if that's ok with you. But it needs network mode "host"
trollsund1 reply#
Have you thought about trying this with a RPI 4B? Thinking about replacing my 3b+ providing two SMB shares with such a setup, once 4b has matured a little.
sequoia#
Well I don't have any reason to replace the 3b+ now (I just set it up earlier this year), besides faster file transfer on the 4, and I'm disinclined to upgrade something I just built.

Unless the 4 can handle video transcoding I don't see what the benefit of it would be. If it has increased energy use it might even be a worse choice!

acolumb#
How'd you make the HD spin down automatically?

Load more comments