##Description A webpage controlled smoker temperature controller written in Node.js and intended to be hosted on the Raspberry Pi
##Purpose An exercise to learn more Node.js and Beginner's Circuitry
##Shopping List
- Raspberry Pi 2 Model B Project Board
- MCP3008 ADC
- (Recommended if your going to solder to a board) 16pin DIP IC Socket
- MicroSD Card (for Raspberry Pi)
- Raspberry Pi 2 GPIO Cobbler Plus
- 2.5mm Female Audio Mono Jack
- 47K Ohm Resistors x 3
- Large Breadboard
- (Alternatively if want it permanent) Solderable BreadBoard
- Maverick ET732 Probe
- 5v Relay Module for Arduino
- DC Blower Fan
- Power for Blower Fan
##Setup and Install Instructions Install Raspbian
Once you follow all the raspberry pi setup, Enable SPI.
Install git
sudo apt-get install git
Allow GPIO to be accessed without root permissions
git clone git://github.com/quick2wire/quick2wire-gpio-admin.git
cd quick2wire-gpio-admin
make
sudo make install
sudo adduser $USER gpio
This will allow current user logged in to have access to GPIO. Logout and log back in for changes to take place.
Install node and npm
sudo apt-get install node npm
Install code
git clone git://github.com/jjohnson338/GrillKeeper.git
cd GrillKeeper
npm install
Run program
node index.js
At this point, navigate to the pi IP address on port 3000 to view the site (Ex. 192.168.1.12:3000)
###Optional
To have the program accessible on port 80, add this line to your /etc/rc.local
iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 80 -j REDIRECT --to-port 3000
To have to the program launch on bootup, create a bash file (wherever you'd like, I put mine in /usr/local/bin
and named it grillkeeper.sh
) with the following contents. (Replace USER with the user you'd like the program to run under)
#!/bin/bash
cd /home/path/to/grillkeeper
su USER -c 'node index.js'
Chmod that script so that it can execute
sudo chmod +x /usr/local/bin/grillkeeper.sh
Add this line to your /etc/rc.local
file
/usr/local/bin/grillkeeper.sh
##Helpful Links
##Lessons Learned
###Hardware
- Don't solder the MCP3008 chip directly to a breadboard. Solder a socket, then plug the chip into the socket. (I lost one chip by soldering directly to it and that was a hard problem to debug)
- Make sure you have a precise tip for your soldering iron. (Had to start over on a new board after I consistently arced solder over to a different lane)
- A multimeter is a must when doing any kind of electrical work. Consider it a debug tool for physical electronics.
###Software
- Exclude the node_modules folder from your git repo. When I had it setup like this early in development, it caused two problems:
- Greatly increased my repo size (not a huge deal really)
- When I pushed my code to my pi as a remote repo (and ran my post-recieve script to get everything in place and running), it would strangely error out and not work when it worked fine on my computer...Issue was that one of the npm modules have actual compiled code in C (the spi package) and it copied over my x86 compiled code and tried to run it on an ARM processor.
- Use const and let instead of var in JavaScript variable declaration for more predictable scoping.
- Modularize, modularize, modularize!!! It's what node is good at, keeps your code cleaner, and easier to debug. Less moving parts together in the same space.
##Contributors
- Jared Johnson
- Shawn Dellysse
- Jacob Shelton