Van Roof Rack

I’ve been working on a roof rack for the van. Today I finished up all the crossbars.  After painting them and mounting I was about to test them with my weight.  I used 5 1/2 Surco gutter mounts and 1″ steel tubing.  The tubing is 6′ long and cost $22 each.  The Surco gutter mounts are $70 new for two crossbars.  I pick up all the cutter mounts at a discount by ordering them off Amazon and buying the returned versions over the new.  The price of the ruturned sets ranged between $45-60. I saved a few dollars and they looked new.  No complaints about buying the warehouse returned versions.

Next up is covering the crossbars with wood decking.   The crossbars are strong enough to carry our gear on vacations and setting up some lawn chairs to relax and taking in the sights.   I just need to get a ladder now.

I used 1″ plastic end caps to keep water out of the tubbing and avoid any rusting later.

A sample pled piece of cedar to test the decking,

Supportx my weight!

Pai ting all the parts flat black.

This is 5 of the 7 installed.

I’m short a few end caps.

 

More re to come as I get the decking installed.

Starting HAP-NodeJS on Boot

I have been following QuickPi’s tutorials on getting a USB Camera working with HomeKit. One thing that recently came up was getting HAP-NodeJS to load on boot. CameraCore.js is required and getting it to load on boot was key. Here are the steps and a mention of what was throwing me off.

This method uses rc.local and forever. You can learn more about forever here.

Make sure you have your Raspberry set to wait for the network on boot.  You can do the in rapsi-config under the boot options.  Ocne you do this then  follow along with the rest of this tutorial.

Make sure you are in the home directory. Then install forever with the global.  This can take 5 minutes to install so be patient.

cd ~
sudo npm install forever -g
sudo nano /etc/rc.local

Now, using nano to edit  rc.local we want to add a line of code before the “exit 0” line at the bottom of the file.   We want forever to start up the CameraCore.js file.

sudo forever start /home/pi/HAP-NodeJS/CameraCore.js

NOTE: You can do the same thing with BridgedCore.js or Core.js if you are using them for any reason.

Save (Ctrl+O) and exit(Ctrl+W) the rc.local file once you are done.  Don’t forget to reboot.

sudo reboot

That is pretty much the extent of getting HAP-NodeJS to load on boot.

Unfortunately for me, even after this I could’t get CameraCore.js to load on boot.  Or that is what I thought.  My mistake was not checking if it was running as sudo.

You can  use ‘forever list’ to tell you what processes are running.  But as you see below nothing is running even after a reboot.

pi@TheaterCam:~ $ forever list
info:    No forever processes running

After pulling my hair out I figured out that since the rc.local command was run as sudo I had to use ‘forever list’ also as sudo.

pi@TheaterCam:~ $ sudo forever list 

info: Forever processes running data: uid command script forever pid id logfile uptime data: [0] j-_g /usr/local/bin/node /home/pi/HAP-NodeJS/CameraCore.js 1041 1138 /root/.forever/j-_g.log 0:0:13:3.917

As sudo I can see that in fact the CameraCore process is running.

One more bit of code that might help those of you to test and debug is running the rc.local from the terminal. If it is not working from the rc.local this is a nice option. You can do this by entering the following.

sudo sh /etc/rc.local

This was actually how I found out that the CameraCore process was already running. I got errors and the Raspberry Pi CPU resource meter was pinged out at 100%.

A final note, you can kill all forever process with the following.

sudo forever stopall

Installing HAP-NodeJS on a Raspberry Pi

I recently starting trying to get USB webcams working with HomeKit.  As I looked for information on the web it looked a bit daunting to implement since Homekit doesn’t officially support web cam just yet.  Some very smart people have done the hard work to get webcams working in HomeKit so it was much easier than I initially thought.

Below is a script to get HAPNodeJS installed and functioning. This is the first step before getting into creating new accessory for live video feeds displaying in HomeKit.

I have used this on RPI 1, 2, and 3 without issues. Works overtime for me but it is key you do this first before anything else. You need to execute this as pi and NOT root. It tells you when you when its necessary to use sudo for each steps.

$ cd /home/pi
$ sudo apt-get update
$ sudo apt-get install git-core libnss-mdns libavahi-compat-libdnssd-dev -y
$ sudo wget http://node-arm.herokuapp.com/node_latest_armhf.deb
$ sudo dpkg -i node_latest_armhf.deb
$ sudo rm -rf node_latest_arm*
$ sudo npm install -g node-gyp
$ git clone https://github.com/KhaosT/HAP-NodeJS.git
$ cd HAP-NodeJS
$ sudo npm install

Special thanks to Alex Skalozub, who reverse engineered the server side HAP.  You can find his research at here. (Sadly, on Nov 4, 2016, Apple sent the DMCA request to Github to remove the research.)

More information is on GitHub: https://github.com/KhaosT/HAP-NodeJS

SunFounder DS18B20 Temperature Module for Raspberry Pi – Part 2

Here is some python code from the SunFounder site that is part of their sensor kit install.

Let’s get back to our Raspberry home directory if you are not already. You can technically out the python script anyplace you like but I prefer the pi user home directory. Type the following if needed in Terminal.

cd /home/pi/

Now let’s create a python script. Copy the following code below then type the following again in Terminal.

sudo nano getTemp.py

Past the text below into the file.  This will get the temp from the sensors that start with “28”

#!/usr/bin/env python
import os
import time

#---------------------------------------------------
#	Note:
#		ds18b20's data pin must be connected to pin7.
#---------------------------------------------------

# Reads temperature from sensor and prints to stdout
# id is the id of the sensor
def readSensor(id):
	tfile = open("/sys/bus/w1/devices/"+id+"/w1_slave")
	text = tfile.read()
	tfile.close()
	secondline = text.split("\n")[1]
	temperaturedata = secondline.split(" ")[9]
	temperature = float(temperaturedata[2:])
	temperature = temperature / 1000
	print "Sensor: " + id  + " - Current temperature : %0.3f C" % temperature


# Reads temperature from all sensors found in /sys/bus/w1/devices/
# starting with "28-...
def readSensors():
	count = 0
	sensor = ""
	for file in os.listdir("/sys/bus/w1/devices/"):
		if (file.startswith("28-")):
			readSensor(file)
			count+=1
	if (count == 0):
		print "No sensor found! Check connection"

# read temperature every second for all connected sensors
def loop():
	while True:
		readSensors()
		time.sleep(1)

# Nothing to cleanup
def destroy():
	pass

# Main starts here
if __name__ == "__main__":
	try:
		loop()
	except KeyboardInterrupt:
		destroy()

 

ds18b20 = '28-051684d013ff'

Now we can save and exit the nano editor.  Ctrl+o to save the file and Ctrl+x to exit.

Now we can run the python script to see the results.

python getTemp.py 

You should see something like the following start to display.

Sensor: 28-051684d013ff - Current temperature : 21.437 C
Sensor: 28-051684d013ff - Current temperature : 21.500 C
Sensor: 28-051684d013ff - Current temperature : 21.500 C
Sensor: 28-051684d013ff - Current temperature : 21.500 C
Sensor: 28-051684d013ff - Current temperature : 21.500 C
Sensor: 28-051684d013ff - Current temperature : 21.500 C

You can stop the script from running with a Ctrl+z.

In part 3 of this tutorial I will show you how to get the temp sensor results showing up in Homebridge for your home automation.

SunFounder DS18B20 Temperature Module for Raspberry Pi – Part 1

I have been using the SunFounder DS18b20 attached to various Raspberry Pi GPIO in my home automation setup.  They are really easy to add to your board and start pulling temperature data in a matter of minutes.  Each room that has a Raspberry has one attached and then using Homebridge the current temperature can be display as a sensor.

You can buy the SunFounder DS18B20 Temperature Sensor Module for Arduino and Raspberry Pi off Amazon for about $8 USD. I am sure you can find them cheaper but I am a sucker for 2 day shipping.

SunFounder DS18b20
SunFounder DS18b20

Here is my routine for setting these up on a Raspberry Pi. Note, I connect them direction to the GPOIO pins and don’t use a breadboard of any kind. I need to tuck my Raspberry Pis away in various areas of the house and they generally just hang off the Raspberry.

You will be connection a ground, signal and power using a female to female jumper wire.

Connect your jumper wires to the module then to the Raspberry Pi GPIO pins. I’ll assume what show what pin is which on your RPi.

GPIO7 to Sig
5V to ACC
GRD to GRD

Upgrade your kernel

sudo apt-get update
sudo apt-get upgrade

Edit that the following config file with nano or your preferred editor.

sudo nano /boot/config.txt

Then scroll to the bottom of the final and add the following. This might already exist but commented out. Uncomment that line by removing the # in front of it if that is the case.

dtoverlay=w1-gpio

Then reboot.

sudo reboot

Mount the device drivers and confirm whether the device is effective or not.

sudo modprobe w1-gpio
sudo modprobe w1-therm
cd /sys/bus/w1/devices/
ls

The result should be something similar to this.

root@rasberrypi:/sys/bus/w1/devices# ls
28-051684d013ff w1_bus_master1

28-051684d013ff is an external temperature sensor device, but it may vary with every client. This is the serial number of your ds18b20.

Check the current temperature

cd 28-051684d013ff
ls

The result should be similar to the following.

root@rasberrypi:/sys/bus/w1/devices/28-051684d013ff# ls
driver id name power subsystem uevent w1_slave

Now enter the following to get the temperature.

cat w1_slave

The result is as follows.
root@raspberrypi:/sys/bus/w1_slave/28-051684d013ff# cat w1_slave
53 01 4b 46 7f ff 0c 10 2d : crc=2d YES
53 01 4b 46 7f ff 0c 10 2d t=21187

The second line t=21187 is current temperature value. If you want to convert it to degree Celsius, you can divide by 1000, that is, the current temperature is 21187/1000=21.187.

If you want to convert that to Fahrenheit remember that 0 °C = 32 °F. This is probably a bit more helpful. multiply by 9, then divide by 5, then add 32.

21.187 * 9 = 190.683
190.683 / 5 = 38.1366
38.1366 + 32 = 70.1366

21.187 C or 70.1366 F

In Part 2 of this tutorial let’s look at using Python to display the temperature on the screen.

How to determine the Raspberry PI board version

I have 5 Raspberry’s in my house running various home automation devices/systems.  I often forget what board is what version since they are all headless and tucked away in the house.   I found this useful in determining what version board I have.

Open Terminal and type the following.

cat /proc/cpuinfo

This should produce something similar to this based on your Raspberry Pi board.

processor : 0
model name : ARMv6-compatible processor rev 7 (v6l)
BogoMIPS : 897.37
Features : half thumb fastmult vfp edsp java tls
CPU implementer : 0x41
CPU architecture: 7
CPU variant : 0x0
CPU part : 0xb76
CPU revision : 7

Hardware : BCM2708
Revision : 000e
Serial : 0000000006475d8a

Look at the Revision result and compare it to the following table to get your board version.

The variants currently available are :

Model and PCB Revision RAM Hardware Revision Code from cpuinfo
Model B Rev 1 256MB 0002
Model B Rev 1
ECN0001 (no fuses, D14 removed)
256MB 0003
Model B Rev 2 256MB 0004
0005
0006
Model A 256MB 0007
0008
0009
Model B Rev 2 512MB 000d
000e
000f
Model B+ 512MB 0010
Model B+ 512MB 0013
Compute Module 512MB 0011
Compute Module 512MB 0014 (Embest, China)
Model A+ 256MB 0012
Model A+ 256MB 0015 (Embest, China)
Model A+ 512MB 0015 (Embest, China)
Pi 2 Model B v1.1 1GB a01041 (Sony, UK)
Pi 2 Model B v1.1 1GB a21041 (Embest, China)
Pi 2 Model B v1.2 1GB a22042
PiZero v1.2 512MB 900092
PiZero v1.3 512MB 900093
Pi 3 Model B 1GB a02082 (Sony, UK)
Pi 3 Model B 1GB a22082 (Embest, China)

 

Google Glass Explorer Program

I was invited to join the Google Glass Explorer Program yesterday. I have been following Glass since the beginning but have never had the chance to play with it. I’m on the fence about the opportunity but I can’t wait very long to make a decision.

20140403-095812.jpg

I’m most interested in the photo and video opportunities since you can shoot and capture both hands free. Biking with Glass is something I’d love to try. Photo, video, and navigation all without using my hands or fumbling for my iPhone. Concert video would be pretty interesting. I also have a few ideas for children’s educational games and a fitness app.

I’ve never seen anyone in Des Moines with Glass so I might be the first. Or maybe just the first to be seen wearing them? But it might come down to the price tag. 1500 to get into the program. That’s a lot of cash and I’m sure I could spend the money on other gadgets. Still, I’m a big enough geek that it might be hard to pass this opportunity up.

RPi Arcade Project Update: 12/2/13

A long weekend gave me time to work on the Raspberry Pi powered arcade system. For starters I used an old marquee that I had from my last arcade. It is not a perfect fit since it is smaller by about 2 inches all the way around. I’d really like to use the full marquee area with a custom marquee. This one one I downloaded from the web and added a bit to it. I have a very talented comic book artist friend so I might commission his to create me something custom.

Temporary arcade marguee in place Side shot of the marquee

My game pads arrived. I have read decent review of these retro style version on Amazon so I decided to pick them up. These are USB so they should be plug and plan. When I add these two additional USB slots will being filled and I am starting to wonder if I am going to be using all 7 USB ports on my powered USB hub in the very near future. My goal is to use the game pads for any Nintendo emulated games. I prefer the traditional arcade joysticks and arcade buttons for NeoGeo and MAME games but would like to have these as an additional option.

Classic game pads arrived.

Below you can see the cabinet in use. The control panel still doesn’t have a protective plexiglass cover on it yet. But, the panel is metal and not wood. I kind of like it without  the plexiglass at the moments. I sprayed about 4 coats of the white so I am hoping that is enough to protect it without the normal plexiglass on top of the metal control panel.  I would also like to add some vinyl graphics to it. I will reevaluate the plexiglass when I start to work on adding the vinyl. You can also see the game pads in the photos below.  The only thing I am missing is beverage holders on the sides of the control panel. I did notice this weekend that I have put place my adult beverage on the pool table that is with in an arms stretch behind the cabinet.

System in action Donkey Kong FTW

Here is a close up of the control panel in action. Now that I have NeoGeo games working I am thinking of adding 4 more buttons to each players already 6 button layout. I currently have the traditional 4 NeoGeo button mapped to each player more like a game pad with two buttons on top and two on the bottom. So that means buttons A and B are mapped to buttons 1 and 2. Then I have buttons C and D mapped to buttons 4 and 5. If I add the extra buttons I will have to drill into the metal again and maybe put another coat of white on it. More work so I am not rushing to make this update. I also need to make sure that I have the room for the extra buttons with the track ball in place.

Lots of room for more buttons.

Speaking of trackball I don’t have this working yet for any games. I also need to power a light below the trackball so that it lights up. The trackball works on operating system GUI so I’m not sure what I need to do to enable this yet fro games. My spinner is also USB so as soon as I figure out the trackball I should have the spinner working as well. There are a handful of classic game I really like to use a track ball for like Centipede, Missile Command, and World Class Bowling. For the spinner Tempest is must. I am pretty sure that the Raspberry Pi has no chance of planing any of the Golden Tee Golf games but those also use a trackball.

I hope my next post covers the trials and tribulations of getting the front end working to the different emulators. This is where I spent most of my time this last weekend. It has been a struggle to get that part of the project working.

RPi Arcade Project Update: 11/24/13

I was back on the control panel again today. I decided to paint the panel white. Before I was able to paint I had to drill two holes and test the trackball mounting. I might have to order special carriage bolts but I’m going with what I was able to find at Home Depot. They seem to work.

I planned to use the original plexiglass cover despite having some carvings in it. After painting the panel white using the original panel was not going to work. Scratches really stand out. I am going to have to get a plexiglass cover professionally cut. Not sure what that is going to cost me.

Here is the sexy new look to the control panel.

20131124-180725.jpg

20131124-180745.jpg

20131124-180759.jpg

20131124-180811.jpg

20131124-180828.jpg

20131124-180838.jpg