Raspberry Pi Manager for BioMONSTAAAR Algae Bioreactor
by benbongalon in Workshop > Science
9876 Views, 59 Favorites, 0 Comments
Raspberry Pi Manager for BioMONSTAAAR Algae Bioreactor
In this Instructable, I will show you how to build a Raspberry Pi module for controlling the Biomonstaaar algae bioreactor. First, a little overview of the entire system.
The Biomonstaaar algae bioreactor is an open source, automated photobioreactor (PBR) array with future applications for genetic engineering, bioremediation, and space research. It consists of an upright cylinder column with mounted sensors for monitoring key aspects of the culture's health such as pH, temperature and dissolved O2. The sensors are integrated with a Raspberry Pi - Arduino microcontroller system which provides a Graphical User Interface (GUI) for users to view the sensor data and operate the bioreactor from a Web browser.
When you complete this project, you will be able to access the Ras Pi from your computer or from any mobile device with a Web browser. Just connect your device to the same WiFi network as the Pi's, then point the browser to
You will be able to view simulated measurement data (the Pi collects new sensor readings every 5 minutes) and you can also activate the control buttons. Of course if you want actual data, you'll have to build the entire Biomonstaaar bioreactor. :-)
Here are the Instructables for the other components:
- Arduino interface for the bioreactor sensors
- Heating and Cooling System
- Control board for the Heating / Cooling System
- Flourescent Lights
Skill Level: Intermediate
To build this project, you should ideally have some familiarity with using microcontrollers (eg, Arduino, PIC, Raspberry Pi) and running command commands on a terminal console.
Now let's get started!
Materials Needed
Required Parts to get a functional Ras Pi
- Raspberry Pi, Model B
- Raspberry Pi case (optional)
- mini-USB power adapter: regulated 5VDC, 1000mA output (Note 1)
- SD card, Class 10, 4GB or more (Note 2)
- Edimax USB WiFi dongle (Note 3)
Suggested Parts
While you can get by with the above kit, you'll need to connect the Ras Pi to a laptop/desktop computer via a serial cable to set it up. An easier way, and what I would recommend, is to attach a monitor, keyboard and mouse to the Pi. To do so, get the following items:
- HDMI cable
- computer monitor with HDMI video input
- USB keyboard
- USB mouse
- USB hub with power adapter (eg, DLink)
Notes
1. More than likely, you can use a USB phone charger for this. In my case, I used a Motorola charger.
2. I bought a micro SD card and used an adapter.
3. Any USB WiFi dongle that is compatible with the Raspberry Pi would do.
Create a Bootable OS Image
In order for the Raspberry Pi to run, it needs an Operating System. There are several OSes available and I chose Raspbian, mainly because I’ve used Debian in the past and like it.
Now, let’s create the bootable OS image. You will need a computer with an SDcard adapter as well as a blank SD card. The instructions below requires typing commands on a Unix terminal console. If you want a more user-friendly tool, head over to eLinux's RPi Easy SDcard Setup guide and pick the one that’s works best for you. Otherwise, here are the steps:
1. Download the Raspbian Wheezy raw image and unzip.
2. Insert the blank SD card into your computer's media slot.
3. Open a terminal console and run these commands:
Identify the disk (not partition) of your SD card and unmount it.
$ diskutil list
$ diskutil unmountDisk /dev/disk2
Write the image to the card. This will take several minutes and it may look like the command is hung. Be patient and wait for the command to finish. NOTE: I wrote the image to raw disk (rdisk2) for faster copying. Also, use the actual name of the image file.
$ sudo dd bs=1m if="2013-07-26-wheezy-raspbian.img" of=/dev/rdisk2
When done you should see something like this:
1850+0 records in 1850+0 records out 1939865600 bytes transferred in 371.561630 secs (5220845 bytes/sec)
Assemble and Turn on the Raspberry Pi
The Ras Pi is a well designed microcomputer so setting up the hardware is pretty easy.
- Put the Rasberry Pi inside the case (if you have one).
- Connect the Pi to the computer monitor using the HDMI cable.
- Plug the Edimax WiFi dongle into one of the Pi's USB ports.
- Plug the D-Link USB hub into the other USB port of the Pi. Then connect the keyboard and mouse to the USB hub and apply power.
- Insert the SD card with the loaded Rasbian OS.
- Finally, plug the 5V power supply into the Ras Pi's (flat) USB port and apply power.
You should see the red LED light up on the Pi and the OS booting up on the computer monitor.
Configure the OS
- If needed, change keyboard layout. I changed mine to US Keyboard layout as follows.
$ cd /etc/default
$ sudo vi keyboard
Change the value of XKBLAYOUT to "us" then close the file.
2. Change your Pi's hostname. We'll call it rasman but feel free to choose another name.
$ sudo vi /etc/hosts
Look for the line with the entry 127.0.1.1 and hostname raspberrypi. Change "raspberrypi" to "rasman" then close the file. This is the only line you edit.
$ sudo vi /etc/hostname
Change the name from "raspberrypi" to "rasman" then close the file.
3. Reboot the Pi so all your changes take effect.
$ sudo reboot
Make the Pi Visible on the WiFi Network
- Make your Raspberry Pi accessible from the local network by its hostname. You need this feature so that you can always connect to Rasman even though its IP address change (which happens when you power off/on the Pi and the router assigns it a new IP). We use Avahi for this purpose.
$ sudo apt-get update
$ sudo apt-get install avahi-daemon $ sudo insserv avahi-daemon
2. Create a new file multiple.service.
$ sudo vi /etc/avahi/services/multiple.service
3. Set the content to the following, courtesy of aXon:
<?xml version="1.0" standalone='no'?> <!DOCTYPE service-group SYSTEM "avahi-service.dtd"> <service-group> <name replace-wildcards="yes">%h</name> <service> <type>_device-info._tcp</type> <port>0</port> <txt-record>model=RackMac</txt-record> </service> <type>_ssh._tcp</type> <port>22</port>
</service> </service-group>
4. Save and close the file. Then apply the new configuration with:
$ sudo /etc/init.d/avahi-daemon restart
5. If all went well, you should be able to remotely log into the box with:
$ ssh pi@rasman.local
Login with the password 'raspberry'.
6. Disable the low-power mode of your Pi's USB WiFi. This prevents the WiFi from sleeping when idle for a long time and become inaccessible from the network. For the Edimax EW-7811Un:
Create a new 8192cu.conf file at the following location
$ sudo vi /etc/modprobe.d/8192cu.conf
Type in the following line inside the file and save it.
8192cu rtw_power_mgnt=0 rtw_enusbss=0
If you are using a different USB WiFi dongle, search for the appropriate instructions for your device.
Install Rasman on the Raspberry Pi
Rasman (Raspberry Pi Manager) is an open-source software we developed for the Raspberry Pi that allows you to control the Biomonstaaar algae bioreactor via a friendly Web User Interface.
1. From your laptop or desktop computer, remotely login to the Raspberry Pi.
MyLaptop> ssh pi@rasman.local
Use the default password 'raspberry'.
2. Once logged into the Raspberry Pi, open a terminal console. You will then run the following commands:
3. Install PIP (Package Installer for Python).
$ sudo apt-get update
$ sudo apt-get install python-setuptools
$ sudo easy_install pip
4. Using PIP, install some packages required by Rasman.
$ sudo pip install Flask
$ sudo pip install requests
IMPORTANT: The next steps must be done on your computer, not on the Pi!
5. Download the Rasman source code as follows:
From your computer's browser, go to: https://github.com/BioMONSTAAAR/reactor
Click the "Download ZIP" button. Then expand the Zip file.
6. Open a console terminal and run the following commands to install Rasman on your Raspberry Pi.
$ cd <folder-where-Zip-was-expanded>/reactor/src/rasman
$ fab zip
$ fab deploy
When prompted for the password, enter 'raspberry'.
7. Remotely log into the Ras Pi and do these steps:
$ cd /home/pi/rasman/scripts
$ sudo cp -p rasmand /etc/init.d/rasmand
$ cd /etc/init.d
$ sudo chmod 755 rasmand
$ sudo chown root:root rasmand
$ ls -l rasmand
The last command should show something like this (date and time will be different):
rwxr-xr-x 1 root root 436 Nov 10 22:34 rasmand
7. Register the script to be run at start-up:
$ sudo update-rc.d rasmand defaults
8. Finally, set up the Rasman to read the sensors every 5 minutes.
$ crontab -e
Insert the following line into the text.
*/5 * * * * curl "http://localhost/api/addmeas/"
Save the file by hitting Control-X then type 'Y'.
8. Restart the Raspberry Pi.
$ sudo shutdown -r now
9. You should now be able to access Rasman. From your laptop or desktop computer, point the browser to:
http://rasman.local:3000
Running the Raspberry Pi Module in "headless" Mode
After you have the Rasman software running on the Raspberry Pi, you no longer need to have the mouse, keyboard or computer monitor connected to it since you can access Rasman from a browser. This is known as running in headless mode.
So free your lab space of clutter and unplug the following:
- computer monitor and HDMI cable
- mouse, keyboard and USB hub
And don't worry if for some reason you accidentally unplug or lose power to the Raspberry Pi. As soon as you reapply power, it will automatically boot and run Rasman.
Enjoy!