Pages

Wednesday, April 5, 2017

DIY microcontroller recording temperature and float switch state for mesocosm experiment

It is extremely valuable to have environmental data in environmental science, of course! Monitoring or measuring device can be easily several hundreds or even thousands dollars. However, we can measure temperature, humidity, light, etc. (basic environmental and climatic data) with a fraction of commercial products' costs.  We can also monitor a state of experiments as well which is sometimes impossible to do because of either location, cost, or your time.

We are going to set up a mesocosm experiment to test the effect of salinity on soil and marsh geochemistry, including carbon and nutrient cycles. We will use eight large baths (about 10 feet diameter) holding soil samples, and four out of eight will simulate "high tide", while other four baths will simulate "low tide". The simulation will be run by a series of eight bilge pumps that will run by time (every 6  hours) to pump water from one side of four baths to another side.

Since the mesocosm facility locates at the Rice River center which is 40-minute away from our laboratory and we will visit only weekly, it would be great if I can make a microcontroller to monitor the status of pumping and water temperature.

I use Arduino microcontroller to accomplish two major tasks: temperature measurement (soil, air, and water) and water level (high or low water).

Total cost of this project is less than $40 if you have a sodering iron and SD card.

* Things needed
- Arduino board: Any model. I use Duemilanove which is very similar to most popular model, UNO
- SD card shield integrated with real time clock (DS1307): Find on Ebay ($4)
- Temperature probe (DS18B20): Find on Ebay ($2)
- Float switch (any type of float switch will work)
- Arduino power adapter: Find on Ebay ($2)
SD shield coming with RTC time clock
Float switch and temperature probe

* Building steps
1. Connect a temperature probes to Arduino board
- Red wire to 5 voltage
- Black wire to ground
- Yellow wire to 4.7 kohm resistor to Arduino digital pin# 2

2. This temperature probe can be wired ALL TOGETHER and use ONLY 1 DIGITAL PIN on Arduino. It is possible because each probe has its own "address". But you need to find out the address first to use the probe (Follow instruction below:)
- Download Arduino libraries (https://www.hacktronics.com/Tutorials/arduino-1-wire-address-finder.html): Onewire.h, SD.h, Wire.h, SPI.h, RTClib.h
- Import the library (you may get an error message if you don't have or install all necessary libraries.)
- Run "Read_adress.ino" to find a unique "address" or identification number for each temperature probe (for example, one of mine is 0x28, 0x54, 0xAD, 0x2C, 0x06, 0x00, 0x00, 0x80)

3. Check Real time clock
- First, checking RTC  by running one of RTC examples which are listed in the example menu (find a model number matching your product). It will nicely print out current time in the following format:

2017/3/31 (Friday) 21:18:29

4. Check SD card datalog shield
- Format and insert SD card into a slot on the shield. Run a code provided by SD library (Find on the example menu). Decide a time interval for recording data (I used 10 min).

5. Float switch
- I connect float switch to Arduino digital pin# 3 with 10 kohm resistor.
- Test the switch by running any simple digital input example found on Google
I know that this picture is not really useful to learn a wiring  in this project. But it's very easy to find an instruction from any Arduino page. Just searching for each product name for Arduino.
6. Combine all codes and run Arduino
- As you can see temperature has been dropping over night in my house. I am going to add total three temperature probes.





I put the boards into a used container for some protection.

I use a wire connector and attach to the side of container. Wires coming from temperature probes and float switch will be connected to the screws.

The entire project took less than 6 hours from planning to assembling. But it will be used to monitor temperature and water level for several months or years as long as experiment is going.

Happy making!

No comments:

Post a Comment