The Problem
I wanted to talk about something I’ve been playing with at work (not for work..just at work). Before I start, I want to say that I’m not trying to do a full review or guide on how to set this up. It is just a little story about what was built.. 🙂
We have two entrances to our work. We have the main entrance and then a second door most of us use to go to the bathroom. No one is monitoring the main door, so if a package is delivered, it would sit there until someone happened to go to the bathroom or you go looking for it. If someone came to the office to meet with us, they never knew where to go. Most of the time the visitor would sit up there waiting for someone to greet them. A coworker mentioned that it would be nice to have a webcam to view people coming and going. This is how this little project was born.
The solution. Version 1
My nephew is always up on cool tech toys and had recently built a Raspberry PI garage monitor system. I took that idea and built one for the office. The following items were used:
- A Raspberry Pi 3 – Raspberry Pi 3
- Web Cam 1080p – I can’t remember what type this is
- Raspbian – UI for Raspberry Pi
- MotionEye – Software used to manage the camera and motion, etc.
Setup
I didn’t want to have a monitor plugged into the Pi all the time, even though I was using a GUI OS (Raspbian), so I setup all the stuff at home. MotionEye has a pretty good page that describes how to install the software, and that was pretty easy. The following script (very simple) was used to post a message to a Microsoft Teams server indicating what the IP Address of the Pi. This would allow me to make a change to the WiFi settings to connect to the WiFi when it booted up. Everything should have been taken care of after that, because I can use putty to connect to the machine.
import teams
import tools, os
import pymsteams
def teamMsg(ip):
ips = ip.split(' ')
myTeamsMessage = pymsteams.connectorcard("<secret>")
myMessageSection = pymsteams.cardsection()
# Section Title
myMessageSection.title("Pi Boot")
# Activity Elements
myip = ips[0]
myMessageSection.activityTitle("Here is my IP(s) - %s " % (ip))
myMessageSection.text("Here is a link to come watch Watch. [Watch here](http://%s:8765) - username: 'user' -- blank password " % (myip))
# Add your section to the connector card object before sending
myTeamsMessage.addSection(myMessageSection)
myTeamsMessage.summary("Camera booted. Connected to network.")
myTeamsMessage.send()
import teams
import tools, os
ipaddress = os.getenv("_IP")
print ipaddress
teams.teamMsg(ipaddress)
This code hasn’t been cleaned up.
Motion Detection
One feature of motionEye is to detect motion, so I created some scripts to post messages to Teams when motion was triggered. This was a great idea in theory, but it would never work. MotionEye wouldn’t fire these scripts for some reason, and I haven’t been able to fix it..yet
Plugging it in
I took the Pi to work and plugged it into the network and fired it up. It didn’t go so smooth, but I was able to work it out and get it going. We had fun with it. Unfortunately, it wasn’t doing what we wanted, since it wouldn’t run the scripts during a motion event. We had more fun watching the videos of coworkers going to the bathroom, coming to work, or going home.
Boredom
We eventually grew bored of this setup and thought it would be a better idea to monitor the parking lot. Specifically Nefarious Corner mentioned in The Parking Lot post. It was nice to view this area, because it was more interesting than watching the co-workers go to the bathroom. We found a few problems with this setup and the raspberry pi.
Problem 1
The Pi didn’t have enough processing power to handle the video processing. We were getting pretty low refresh rates, so the videos were very choppy and provided little value.
Problem 2
The machine would crash often, and the only thing we could figure out is that it may be overheating. I have the Pi in a Retro Nintendo case, which is super cool when you are building a gaming machine. The case comes with a fan, but it wasn’t installed…woops!
Problem 3
There wasn’t enough space on the memory card, so it would fill up fast and then freeze up. When this thing freezes up it was difficult to get in without having a monitor plugged in.
Version 2
After the incident mentioned in The Parking Lot and the camera crashing. I wanted to get MotionEye working on a new machine that can hopefully handle the image processing and have more space.
I located an old machine that we haven’t used since 2010 and repurposed it. The new machine was constructed using Ubuntu Server 19.10. It didn’t go as smooth as the Pi due to some mistakes on my part, but I got it running. Things are running and we haven’t seen much action on the camera though.
I’ve had fun setting this up, but I’m pretty sure it can do a lot more. I have several ideas on how to extend this. One would be to integrate this with the software/service by Sigthound, which is a service that can recognize cars, license plates, people, etc. Go check it out if you haven’t seen it before. I would suggest looking at the Cloud API. I’m going to apologize now, because after you go to the site, your FB wall will be riddled with ads from Sighthound. 🙂
Conclusion
I love exploring and playing with technology and this system is perfect for watching people, especially those misbehaving in your parking lot. I say bring on the summer and the crazy meth-heads.