Skip to content
Jim Rybarski edited this page Jan 22, 2016 · 38 revisions

Download OS

Get NOOBS from here.

Modify NOOBS so you can connect via Ethernet and SSH, without a screen or keyboard.

  1. Unzip the files from the download and put them on your SD card.
  2. Delete Data_Partition in the os directory.
  3. Make the contents of os/Raspbian/flavours.json be exactly:
{
    "flavours": [
        {
            "name": "Raspbian",
            "description": "A Debian wheezy port, optimised for the Raspberry Pi"
        }
    ]
}
  1. Add silentinstall to the end of the line in recovery.cmdline
  2. Make sure your Ethernet connection is shared and connect an ethernet cable between your Ubuntu-based laptop and the temperature controller. Run sudo tail -f /var/log/syslog | grep raspberry on your laptop. Put the SD card in the Raspberry Pi and power it up.
  3. Wait 20-30 minutes for the OS to install and configure itself.
  4. In the terminal where you are monitoring syslog, get the Pi's IP address.
  5. ssh pi@IP_ADDRESS with password raspberry (even if you changed it on os.json it won't make a difference)

The instructions for that came from here.

Upgrayedd

Run sudo apt-get update && sudo apt-get upgrade -y after SSHing in.

Configure Hardware

Run sudo raspi-config, choose Advanced Options select the following (choose 'Yes' to each question):

update
I2C
SPI

Install DHCP server

Reboot the Raspberry Pi. Run sudo apt-get install isc-dhcp-server

Open up /etc/dhcp/dhcpd.conf Comment out the following lines:

option domain-name "example.org";
option domain-name-servers ns1.example.org, ns2.example.org;

Uncomment the line:

#authoritative;

Add the following to the end of the file (replacing the N in 192.168.10.N with 1 or a unique number if you have several Pi Warmers):

subnet 192.168.10.0 netmask 255.255.255.0 {
 range 192.168.10.10 192.168.10.20;
 option broadcast-address 192.168.10.255;
 option routers 192.168.10.N;
 default-lease-time 600;
 max-lease-time 7200;
 option domain-name "local-network";
 option domain-name-servers 8.8.8.8, 8.8.4.4;
}

At the bottom of /etc/default/isc-dhcp-server, make the line with INTERFACES in it be:

INTERFACES="wlan0"

Edit /etc/sysctl.conf Make sure this line is in the file: net.ipv4.ip_forward=1

Set up IPTables

Run these commands:

sudo iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
sudo iptables -A FORWARD -i eth0 -o wlan0 -m state --state RELATED,ESTABLISHED -j ACCEPT
sudo iptables -A FORWARD -i wlan0 -o eth0 -j ACCEPT
sudo sh -c "iptables-save > /etc/iptables.ipv4.nat"

Install WiFi

sudo apt-get install bridge-utils hostapd
wget http://www.daveconroy.com/wp3/wp-content/uploads/2013/07/hostapd.zip
unzip hostapd.zip
sudo mv /usr/sbin/hostapd /usr/sbin/hostapd.bak
sudo mv hostapd /usr/sbin/hostapd.edimax
sudo ln -sf /usr/sbin/hostapd.edimax /usr/sbin/hostapd
sudo chown root.root /usr/sbin/hostapd
sudo chmod 755 /usr/sbin/hostapd

Make /etc/network/interfaces be as follows (again replacing the N as you did above):

auto lo
iface lo inet loopback
auto eth0
iface eth0 inet dhcp

allow-hotplug wlan0
    iface wlan0 inet static
    address 192.168.10.N
    netmask 255.255.255.0

up iptables-restore < /etc/iptables.ipv4.nat

Make /etc/hostapd/hostapd.conf be as follows (using a number instead of N since we will have many temperature controllers in the same room:

interface=wlan0
driver=rtl871xdrv
ssid=tempcontrol
channel=1
macaddr_acl=0
auth_algs=1
ignore_broadcast_ssid=0
wpa=3
wpa_passphrase=my_s3cr3t_p4ssw0rd
wpa_key_mgmt=WPA-PSK
wpa_pairwise=TKIP
rsn_pairwise=CCMP
  1. Uncomment and update the following line in /etc/default/hostapd to make the WiFi turn on automatically: DAEMON_CONF="/etc/hostapd/hostapd.conf"

Set up Networking to Start Automatically

Run these commands:

sudo update-rc.d hostapd enable 
sudo update-rc.d isc-dhcp-server enable

Reboot

  1. Shut down the Raspberry Pi and disconnect the power cable.
  2. Plug in the Wifi dongle and attach the thermocouple and heater cable.
  3. Plug the Raspberry Pi back in and restart it.
  4. You should see the tempcontrolN hotspot available after around two minutes.

Install Temperature Controller software

  1. Install packages:
apt-get update && apt-get install -y \
    git \
    python-pip \
    python-dev \
    libffi-dev \
    python-numpy \
    python-smbus \
    i2c-tools \
    nginx \
    redis-server \
    supervisor

pip install \
    Django==1.9c1 \
    django-cors-headers==1.1.0 \
    djangorestframework==3.3.1 \
    gunicorn==19.3.0 \
    RPIO==0.10.0 \
    argparse==1.2.1 \
    bottle==0.12.8 \
    cffi==0.8.6 \
    pycparser==2.10 \
    redis==2.10.3 \
    smbus-cffi==0.4.1 \
    wsgiref==0.1.2

git clone https://github.com/adafruit/Adafruit_Python_MAX31855.git
cd Adafruit_Python_MAX31855
sudo python setup.py install

  1. Now get the custom temperature controller software:
cd /opt/ && sudo git clone https://github.com/jimrybarski/raspberrypid.git && cd raspberrypid
cp api.conf /etc/supervisor/conf.d/
cp backend.conf /etc/supervisor/conf.d/
cp frontend/config/temperature.controller.conf /etc/nginx/conf.d/
cp frontend/config/nginx.conf /etc/nginx/nginx.conf
cd interface && python setup.py install
  1. Setup some config files and other various things. Some of these might not be necessary.
mkdir -p /var/log/piwarmer
mkdir -p /var/temp_control
cd /opt/raspberrypid/backend/api
python manage.py makemigrations
python manage.py migrate
echo "i2c-dev" >> /etc/modules
echo "i2c-bcm2708" >> /etc/modules
echo "snd-bcm2835" >> /etc/modules
  1. Install the website:
mkdir /srv/www
sudo ln -s /opt/raspberrypid/frontend/* /srv/www/
sudo chown -R pi:pi /srv/www

Reboot the Raspberry Pi.

sudo supervisorctl reread && sudo supervisorctl reload

The backend should be running now and should also start automatically whenever you power up the device.