Cheese cave

From Real Vegan Cheese
Jump to navigation Jump to search

The cheese cave is based around a "Haier 18-Bottle Thermal Electric Wine Tower" (though any wine chiller should work). The Wine Tower is an upright wine chiller that uses two large peltier modules with heat sinks and fans to chill the bottles. It was modified to add humidity control and humidity and temperature logging using a relay-controlled ultrasonic humidifier, an SHT15 humidity and temperature sensor, a 3.3 volt arduino pro and an OpenWRT compatible wifi router with USB.

The current developer on this project is juul. Contact him for more info.

Photos of the build

  • Some photos here.
    • Apologies for the mess of hot-glued rats-nest electronics.

Circuit diagram

Other than connecting the arduino, router and sensor as described elsewhere in this guide, the circuit to control the humidifer is as described in this sparkfun tutorial.

Code

The sources for the python web app and the arduino C code are availabel on github.

Reading temperature and humidity

The temperature and humidity are read every second using a 3.3 volt Arduino Pro and a SHT15 sensor breakout board from Sparkfun.

The arduino is powered by 3.3v coming from the wifi router and communicates with the router using TTL serial.

The sensor communicates with the Arduino using a "2-wire protocol" similar to I2C.

The arduino code uses a

Wifi and logging

A Linksys/Cisco WRT160NL router was flashed with OpenWRT version 12.09 Attitude Adjustment. OpenWRT was configured to use an external usb flash drive as its root partition (extroot). Avahi was installed and the hostname set to cheese, such that any mDNS compatible operating systems are able to access the router through the domain name cheese.local.

The router has an internal 3.3v TTL serial connector. This was connected to the arduino, providing both power and communications.

A simple logger and web server was written in python to read the temperature and humidity from the Arduino and display it on a web page such that the status of the cheese cave can be monitored by accessing http://cheese.local in a web browser.

Wine cooler hacks

The wine shelves were cut to make them flatter and a sushi mats was placed on each shelf.

Wires were run between the inside and outsider of the wine chiller by un-mounting the bottom peltier module, cutting a small amount of insulation away, running the wire through and re-mounting the peltier module. One 110 vac power cord was run for the humidifier and a communications cord was run for the temperature/humidity sensor.

Troubleshooting, bugs and ToDo

Programming arduino fails

If you get an error like this during arduino programming:

avrdude: stk500_getsync(): not in sync: resp=0x00

Then try this:

  1. Ensure that the arduino is connected with both 3.3v, ground, tx and rx.
  2. In the arduino IDE, make sure that the correct serial port is selected
  3. In the arduino IDE, select the board "Arduino Pro or Pro Mini (3.3V, 8 Mhz) w/ ATmega328" (if that's what you're using)
    1. If the menu is larger than your screen, simply use arrow keys to select the invisible items.
    2. After selecting the board, the name of the selected board will appear in the bottom status bar of the IDE.
  4. Hold down the reset button on the board
  5. Click the upload button in the IDE (or use ctrl+u)
  6. Wait until IDE displays the "Binary sketch size: ..." line and release the reset button.

Wifi router won't boot

There is a problem where the router will fail to boot because the arduino is sucking too much power from the 3.3v line. The workaround is to disconnect the arduino, connect power to router, wait for router to boot, then connect the arduino. This works but should be fixed.

Serial data from arduino is garbled

Make sure you're using an old-type non-switching 12v power supply for the router. If it's heavy (like it has a chunk of metal in it) it's the right kinda. If it's light, it's a switching power supply, and those generate a lot of noise which can interfere with comms.

Make sure you're using shielded cable for the serial connection. Make sure the shield is connected to ground and that arduino, sensor and router all have their grounds connected.

ToDo

  • Implement logging.
  • Add plotting capability to web app
  • Add photos to this documentation
  • Allow changing humidity set-point from the web app
  • Allow changing temperature set-point from the web app
  • Extra Capacitor or 3.3v power supply for arduino so router can boot with arduino attached.

OpenWRT configuration

The following assumes some knowledge of networks and *nix command line.

Go to the OpenWRT table of hardware and find the wiki page for your router. It will tell you how to flash it with OpenWRT. You should use a wifi router that has the following minimum specs:

  • Atheros chipset
  • 32 MB ram
  • 4 MB flash
  • USB
  • Supported by OpenWRT

You want to connect to the router's LAN port.

After flashing, telnet into the router using:

telnet 192.168.1.1

Set the root password:

passwd

Now exit the telnet session and log in with ssh instead:

ssh root@192.168.1.1

Wifi setup

We'll set up the router to connect to your existing wifi access point as a client (you could also connect it using wired ethernet if you prefer, which should not require any configuration, provided your router has a wan port).

Edit the "config wifi-iface" section in /etc/config/wireless (using vi) too look like this:

 config wifi-iface
     option device   radio0
     option ifname   wlan0
     option network  wifi
     option mode     sta
     option ssid     myaccesspoint
     option encryption none

Replacing myaccesspoint with your wifi access point name. If the access point is password protected you will have to specify the encryption method and password.

In the same file, remove the following line:

     option disabled 1

Now edit /etc/config/network, adding the following section to the end of the file:

 config interface 'wifi'
       option ifname 'wlan0'
       option proto 'dhcp'

You should also change the line "option ipaddr '192.168.1.1'" in the "config interface 'lan'" section to e.g:

option ipaddr '172.28.1.1'

Now reboot the router. When it finishes booting, DHCP should be running on the LAN interface and you should get an IP in the 172.28.1.x range. You can now ssh back into it and check if the internet is working:

ssh root@172.28.1.1
ping sudomesh.org

If it works then the router is successfully connecting to your wifi, but you won't know its IP address is. We'll fix this in the Avahi section below.

USB extroot

Now you can set up extroot to use a flash drive as your root partition. Take a usb flash drive, and plug it into a normal linux system (e.g. debian). It should show up as e.g. /dev/sdb (you can check using dmesg). First unmount it in case it's mounted:

sudo umount /dev/sdb1

Now change the flash disk partition type to linux:

sudo fdisk /dev/sdb 
At the fdisk menu, hit:
  t <enter>
  83 <enter>
  w <enter>
  ctrl+c

Format the flash drive as ext4:

sudo mkfs.ext4 /dev/sdb1

Now plug the usb flash drive into your router and ssh into the router. The rest of the commands in this section take place on your router.

Install the required packages for extroot:

opkg update
opkg install blkid block-mount kmod-fs-ext4 kmod-lib-crc16kmod-nls-base kmod-scsi-core kmod-usb-core kmod-usb ohci kmod-usb-storage libblkid libuuid swap-utils

Change the section "config mount" in /etc/config/fstab to look like this:

 config mount
       option target   /
       option device   /dev/sda1
       option fstype   ext4
       option options  rw,sync
       option enabled  1
       option enabled_fsck 0

Now mount the usb drive and copy the filesystem:

mkdir /tmp/mnt
mount /dev/sda1 /tmp/mnt
cd /
cp -a bin etc lib rom root sbin usr var www /tmp/mnt/
cd /tmp/mnt
mkdir dev mnt overlay proc sys tmp
sync
cd /
umount /tmp/mnt

If the following command gives any output after rebooting, then you are now using extroot:

mount | grep sda1

Avahi (mDNS)

To set up mDNS, first install avahi-daemon:

opkg update
opkg install avahi-daemon

Make it work without d-bus by adding this line to the [server] section of /etc/avahi/avahi-daemon.conf:

enable-dbus=no

Make it auto-start on boot:

/etc/init.d/avahi-daemon enable

Change your hostname to something relevant by editing the hostname option in /etc/config/system (maybe set it to cheese so you can use cheese.local to access the cheese cave).

Start avahi:

/etc/init.d/avahi-daemon start

You should now be able to disconnect the ethernet cable and ssh into your router using:

ssh root@cheese.local

If you're using Windows, you will first have to install Bonjour Print Services from apple, since Windows does not come with mDNS support (grrr).

If you at some point can't get into the router via wifi, you can always connect an ethernet cable to the LAN port and ssh to root@cheese.local

Wiring notes

Communications cables between sensor, router and arduino take place over old PS/2 cables that have been cut and soldered onto the different devices. These cables are shielded, easy to get for free, and the plugs make it easy to disconnect and reconnect components. You will probably have to open the back of the humidifier to run the wires and possible cut a bit of the insulation away to make room for them.

Router to arduino connection

The router has an internal 3.3v TTL serial port. See the wiring notes section for wiring and the troubleshooting if you run into trouble. This is how we wired ours from router to arduino:

  • RX: Brown wire to TX
  • TX: Orange wire to RX
  • 3.3v: Green wire to 3.3v
  • GND: Ground (shield) wire to GND

Arduino and SHT15 sensor connection

Program the arduino with the code from the git repository. See the troubleshooting section if you have problems. The code simply waits to receive the character 'r' (for read) and then responds with a line like e.g:

<42.20|17.13>\r\n

The first number is humidity in percent and the second number is temperature in centigrade.

If the arduino program receives the character 's' instead, it will read two numbers: The lower and upper threshold for the humidifier. If the humidity drops below the lower threshold, it will turn on the humidifier and if the humidity rises above the higher threshold it will turn off the humidifer. The lua web app takes care of all of this.

The arduino program uses serial setting 9600 8N1 to communicate over serial and only allows reading once per second.

Wiring

Wiring from Arduino to SHT15:

  • VCC: Green wire to VCC (3.3v)
  • Pin 12: Orange wire to Data
  • Pin 13: Red wire to SCK (Clock)
  • GND: Shield/ground wire to GND

Wiring from arduino to the relay controlling the humidifier:

  • Pin 8: Relay control
  • Ground to ground

From router to the relay:

  • 5v: Yellow
This is needed since the Arduino does not have 5v (only 3.3v).

Serial connection

To use the serial for talking to the arduino, you will need to disable the terminal that is present per default.

Edit the file /etc/inittab and delete the line that looks like this (probably the last line):

ttyS0::askfirst:/bin/ash --login

Then reboot the router.

To test the serial connection to the arduino first install minicom on the router:

opkg update
opkg install minicom

Start minicom with -s for initial setup and -o for no init:

minicom -s -o

In the menu, use serial port setup menu to set serial device /dev/ttyS0 and 9600 8N1, then choose "Save setup as dfl" and exit the menu. You should now get one humidity/temperature reading from the arduino every time you hit a key (e.g. enter). If this does not work, check all of your connections. Especially check that your grounds are all connected and the grounds are connected to the shields on the cabled (you _are_ using shielded cables right?).

Installing the web app

THE FOLLOWING DOES NOT YET WORK! HOPEFULLY IT WILL SOON

Now you can install the lua web app on the router.

The web app uses python, pyserial and the CherryPy framework.

First, on the router do:

/etc/init.d/uhttpd disable
/etc/init.d/uhttpd stop
opkg remove luci
mkdir -p /opt/cheese
opkg update
opkg install python pyserial

Then, on your computer do:

cd online-cheese-cave/web-app
scp * root@cheese.local:/opt/cheese/

Then on the router:

cd /opt/cheese
./install.sh
/etc/init.d/cheese enable
/etc/init.d/cheese start

You should now be able to access the web app in your browser using:

http://cheese.local

The web app should auto-start on boot.