Tag Archives: raspberry pi

Conways Game of Life

Finished up the hardware to display the results of my coding exercise. My primary goal was to learn a little more about python and object oriented coding. I could never really wrap my head round objects, and I needed a project with real end goals to address that. The code is available and has documentation on github.

Basic construction is comprised of 16×16 pixel ws2812 panels in a 3×3 grid. The way the panels were laid out and wired made a sort of weird numbering scheme, which I had to compensate for in software. Next time i’d be more planful on which inputs go to which outputs.

I made a picture frame out of walnut to contain the insides. There are actually 2 panes of glass with the following layers:
(front)
Glass
Matte with display window cut
Glass
Papyrus type paper for led diffusion
The 3d-printed grid
the wooden panel with the led’s mounted
(back)
This stack keeps everything tight/contained and keeps the LED grid close agains the diffuser paper so the lines are crisp. I used the LED grid so i’d get colored squares instead of circles, to me it really looked a LOT better.

The somewhat ungainly back of the stack. I put air holes along the top as I wasn’t sure. how much heat the LED’s would generate, but they aren’t running at full brightness and the glass doesn’t even get warm to the touch. You’ll notice the 3 cross braces, which are bowed up by spacers in the middle. This presses the whole grid tightly against the glass, keeping the lines displayed bye the grid on front tight. Powered by a raspberry pi with a small level converter IC to talk 3.3v -> 5v.

Conways Game of Life Preview

Working on a new project, combining making something fun with learning some new skills. In this instance the primary goal was to learn a little more about python, Visual Studio Code + Github, and object oriented programming (my first class!).

Sneak peek below, but this will be a RGB 48*48 matrix framed in a shadow-box on the wall. Initially it’ll run the game of life, but could be updated later to display anything. Early pics of the physical project below, and link to gitHub repository.

Publishing IoT IP Addresses to MQTT

I have been playing around with using ESP8266’s as endpoints around the house for collecting temperature, turning the sprinkler pump on, texting me when the doorbell is pressed, etc.  One of the challenges when doing setup/testing is getting the IP address of them when they first come online.

I am running dnsmasq on a raspberry pi, which provides both local DNS and DHCP services.  This is in no way novel, as it is a pretty vanilla configuration.  What I wanted to share is a small script that monitors for updates to the dnsmasq log, watches for new client releases/renewals and then posts those to the MQTT service.  There are lots of things you can do with it from there, but I usually just subscribe to the topic via terminal or mqtttool on my iPhone.

#!/usr/bin/python
from pygtail import Pygtail
import sys
import re
import time
import paho.mqtt.client as mqtt

client = mqtt.Client()
client.username_pw_set("xxxxxx","xxxxxx")

while (1):
 for line in Pygtail("/var/log/dnsmasq.log"):
   isItACK = re.search(r'DHCPACK',line)                #see if its an ACK
   if isItACK:
     newInput = re.sub(r'^.*DHCPACK\(eth0\).', "", line) #strip everything before mac address
     newInput = newInput.rstrip()                        #strip newlines
     client.connect("xxxxxx.widgetninja.net",1883)       #connect to mqtt
     client.publish("/network/DHCP",newInput)            #publish to mqtt
     client.disconnect                                   #hang up
     #sys.stdout.write(newInput)                         #debugging
 time.sleep(10)

Hope this helps save you some time trying to find the ip address of that new device, be it something you made or otherwise just added to your network.

mqtt