Tuesday, September 17, 2019

Chiefs Tomahawk Chop with Raspberry Pi

Wanted to cook up a quick and nerdy way to support the Chiefs this year. So I came up with a Raspberry Pi Tomahawk Chop Button using a servo and an arcade button I had laying around.

Code here.

Had to figure out how to slow the servo down a bit. You can see I went the low tech way. Essentially I am rolling through 3 chops to play with the music. I call the music first using another python script so I can return back to the code to run the chop will the song plays. Here is the song script.

See video below for the chop in action. Let's go CHIEFS!!!!!!

Thursday, May 16, 2019

Python NEOPIXEL Google Traffic and Weather LED Strip

Started playing around with the Neopixel library and python on the Raspberry Pi. I usually take a run over lunch break so I wanted a way to get a quick view of the current weather conditions. I have a 60 LED WS2812 strip so I divided the strip up into 15 LED sections.

  • Section 1 - Temperature. Depending on the temperature I wanted to color the 15 LEDs a specific color.
    • temp > 44 and < 80 = Green
    • temp > 79 and < 90 = Yellow
    • temp > 90 = Red
    • temp > 34 and < 45 = Yellow
    • temp < 34 = Red
  • Section 2 - Wind. 
    • wind < 5 = green
    • wind = 5 and < 16 = Yellow
    • wind > 15 = Red
  • Section 3 - Humidity
    • Humidity < 61 = Green
    • humidity > 61 and < 80 = Yellow
    • humidity > 80 = Red
  • Section 4 - Condition
    • If it is not raining - Green
    • If it is raining - Red
I am using the Open Weather Map API. You can sign up for a free account here: https://openweathermap.org/. I setup an infinite while loop that will sleep for 10 minutes between each iteration. I also set it up to only turn the LEDs on between 10AM and 2PM. The API will only be called during these times. I typically take a run around lunch time so no need to keep it on after this. 

Next steps is to add a Traffic API call. I will light the led up based upon my commute time home.

Monday, March 25, 2019

PowerShell Folder Sizes

More of just a place holder for me because I am tired of searching for this everytime I need it. The following powershell will list out all the subfolders for a given root folder with Sizes and last date modified.

The script will dump the data to CSV so you can do whatever you need from there.

Wednesday, December 26, 2018

Christmas Tree Timer and Switch

Didn't do the Christmas tree to music this year. I did however setup a simple timer and override switch so the tree would turn off and on automatically.

I setup a simple relay attached it to the Raspberry Pi and wrote the Python Script below. I wired up a light switch (hadn't done this before so that was fun) to the Pi with some wire nuts. The Light switch will override the timer. So if you want the tree to stay on longer just flip the switch to on.

Here are some pictures.

Look at the sweet duct tape job

The light switch was connected to GPIO pin 20 and ground. I had to use the internal pull_up_down resistor to make it work. Found a nice little function that takes in the current time, start time and end time. The function will determine if the current time is between the time range you set. Worked really well for this project.

Christmas tree would light up at 6:00AM and then turn off at 10:00AM. Then it would light up at 4:00PM and turn off at 10:00PM. It would check every 5 seconds to see if it needed to turn off or on. Then if you flip the switch it would not check for time of day and would just leave the relay in the on position.

Wednesday, October 3, 2018

Smart Garden v1.0 Raspberry Pi

Some fellas at the office had a crazy idea to try and grow a garden in their cube at work. After several people tried to talk them out of it, they plowed ahead and started one anyway. So why not hook up some sensors and a web cam and call it a Smart Garden?

Sensors and such

Kuman Moisture Sensor Kit 5Pc: From the reviews these have a tendency to not last very long. They are cheap and this experiment may not last long so I went for them. If they start blowing up we may invest in a nice Sensor.

DHT22: Yes I know people say these are not accurate. Calm down folks we are not reporting data for the NOAA, we are just checking the temperature and the humidity in the office. We can live with the inaccuracy.

Cheap Webcam: Whatever you have laying around. As you can see the one I found is cheap and potato quality.

Raspberry PI: if you have one laying around you are a nerd.

Readings and Data

We are taking moisture readings from two sensors, temperature and humidity readings, and a picture on the web camera every 5 minutes. I wrote two web services that are used to store the data. A python script was created to read the sensors and take a picture, the script will then call the web services to send the data over to a database, and a FTP script is called to copy the image to the web server.

I had to use FTP because I didn't take the time to figure out how to post the actual image to a web service. I may work on that eventually.

Web Site

After the data was collected a website was built to allow folks to keep tabs on stuff. I downloaded some TimeLapse software and threw together some time lapses which have turned out really cool given the cheapness of the web cam.

The Chart.js library was used to make some charts to display the recent readings. Bootstrap was used to make it mobile friendly. The Charts look squished on mobile so that may be on the do list for the future.


Wednesday, September 5, 2018

Raspberry PI Relay Control using Python and Flask

I wanted to create a party button accessible from a web site using Python and Flask. Buckle up folks.

So somehow I got flask up and running. There should be a ton of articles on how to install it. I seem to remember it being pretty easy. Just google it already.

I created a new directory called party. Inside this directly I created a static and a template directory. I then created a file called app.py

Here is the app.py script

You can park all your images and such in the static folder and reference them using flask templates. In the template folder I created the look and feel I wanted for the web pages served up by flask.

You can see I call the template in the app.py with the return render_template command. So when you start a party you are quickly returned to the index.html page. Here is the index.html page

I wanted a cool DJ Air horn so I grabbed it and I am using VLC command line to run that. You will notice that the Flask is setup to run a couple other Python Scripts. This is my party start and party stop functions. These python scripts control the relay.



Pretty straight forward on the Relay control. You'll notice on the partyStart.py I wanted to call a little DJ airhorn to really kick the party off right. I am using the VLC command line interface to do that.

Here is what end result looks like

This can be expanded to do all sorts of fun stuff. Using this basic Flask/Python example you setup several different web based controls using Raspberry Pi.

Monday, July 30, 2018

ESP8266 Post to Web Service

Purchased a DHT22 recently for a Work Desk Temperature project. Wrote a web service and created some SQL stuff to capture the temperature and humidity at my desk. Here we go.

Web Service

Just a real simple web service to call the stored procedure I wrote:

See my other blog post for more details on creating a web service: http://tech.thejoestory.com/2017/01/simple-sql-server-aspnet-web-service.html

SQL stuff

Created a Table and a couple stored procedures to support this. Here is the table.
Here are the stored procs.

ESP8266 Post

From there I just needed to figure out the ESP8266 Post. I had to search around a bit but finally landed on the script below. The script will establish a WiFi connection. Then it will loop every one minute taking a temperature/humidity reading from the DHT22. Finally it will call the web service I built to store the data in SQL server.

You will need to grab the DHT and AdaFruit Libraries using your Arduino IDE. From there I created a web site using Chart.js and a couple other stored procedures I wrote to get MAX/MIN/AVG Temp and Humidity.

Thursday, July 5, 2018

Find Text String in Text Files Powershell

Quick script to search a set of text files for a specific text string.


Wednesday, June 6, 2018

Raspberry Pi Speed Camera Python

I setup a pedestrian speed camera in the office using a great project by pageauc on github: https://github.com/pageauc/speed-camera. This thing was so dead simple to setup and run, and after some tweaks on the config I was clocking fast walkers in my office like a champion.

  1. I started with a fresh Raspberry Pi 3 Raspbian build
  2. Installed OpenCV3 using this link: https://www.pyimagesearch.com/2016/04/18/install-guide-raspberry-pi-3-raspbian-jessie-opencv-3/. This takes a while
  3. Download the speed camera project from github: https://github.com/pageauc/speed-camera
  4. Extract it and copy it over to your Raspberry Pi. I just parked it under /home/pi/speed-camera
  5. Crack open the config and start messing with stuff

I am using a web cam so I had to change this value in the config right away:

I had to tweak the capture area for my project and did so by playing around with these values

Turn on the gui window so you can see what you are doing

Here is a shot of me walking by the camera. The software will automatically save the image and add the speed calculated to the image which is gangsta.

My camera is pretty potato quality. Another setting I had to tweak often was the track_len_trig. This determines how many pixel changes are required to save an image. Since my target is down the hall I had to reduce this down to 5. If you are tracking a larger area you will want to play with this since the default is 60. I get some false readings but it captures what I need.

Here is a picture of the system in action on the Pi. 
If you have any troubles review the guide on github. It is pretty handy.

Monday, April 2, 2018

AnswerBot 3000 Version 2

Way back I made an AnswerBot using Teensy. I mean not a real one. Basically its a button that you push, it will pick a random saying and send the keystrokes using Teensy Keyboard library.

AnswerBot: keep it gucci fam

Always answerbot. Anyway, I wanted to make a better physical representation of AnswerBot so here is Version 2.0.

He of course has a short in one of the LEDs which is perfect. I need to work on my can cutting skills. Anywho AnswerBot is now online and adding fun quotes to my various instant message platforms.

AnswerBot: i failed you

No way AnswerBot you cool.