User:Boohyabuddha/ENES100/Project1

Project 1
Composting Monitoring System

Problem Statement
Composting is a great way to reduce unnecessary organic waste addition to landfills. This waste degrades inside of oxygen-deprived plastic bags, resulting in anaerobic digestion, which, in turn, results in the release of methane, nitrous oxides, carbon dioxide, and hydrogen sulfides--all greenhouse gases. However, without careful monitoring, compost done at home can also create these anaerobic byproducts. Not only are these gases inhibiting the recovery of our atmosphere, they also make the composting an unpleasant experience. This project will address these issues by taking the guess work out of composting; by developing a sensor array that will detect GHG, internal and surface temperatures, relative humidity, and soil moisture, the user will be able to more accurately determine when to aerate their compost, adjust to nitrogen saturation (which can lead to anaerobic digestion), and more, the compost can be made in a more efficient and reliable manner.

Project Plan
This project will also specifically address compost tumblers used in an urban, apartment-setting for a few reasons: 1) Aerating via tumbler action is the simplest way to aerate without exposing the user to odors, 2) Tumbling doesn't rely on ground contact to allow drainage of leachates, 3) Tumblers tend to be smaller and allow for waste to be collected in a bin before turning into compost without risking the waste biodegrading into an unpleasant state, 4) Sensors built into the top of the tumbler could gather gases released during aeration, assuming the aeration mechanism involves keeping the bin stationary, without exposing the sensors to soil contact and excess moisture.

The tumbler will have the above-mentioned sensors, and will cost <$50 to produce assuming 100+ unit production. The intended means to read the sensors is an Arduino Uno for prototyping, and possibly an Ardiuno Nano for a final product; the sensor readings will be displayed in one of three ways: 1) LCD display, 2) Bluetooth integration, 3) WiFi/Python website. The power supplied to the system should be either achievable through solar, long-lasting rechargeable battery, or a low wattage power supply.

Week1 Narrative
During the first week, I acquired the materials needed to build the base for the compost bin and fit the bin into the frame while keeping in mind the crank and other peripherals we would be adding.

My initial design was going to make the base able to be folded and portable, however, after reevaluating the design, materials, and overall function of the compost tumbler, I decided to nix this idea because of the following reasons:

1) Making the upright portions able to be folded for transportation would possibly cause a lack of stability while turing the compost. Assuming about 5gal of compost material, this would mean that the crank would be pushing and churning about 18kg of compost, and if the upright portions weren't stable, this could lead to wobbling and weaknesses in the frame.

2) Even after considering making the base foldable with options such as brackets that would lock it into 90 degree angles such as bolt locks and pneumatic hinges, this added drastically to the complexity and cost of the base before we even installed the shaft and electronic components.

3) Concerning portability, at least in this stage, it became a low priority since our focus is more on making sure the gas siphoning mechanisms work properly. This is the crux of our design and its function--not the base.

The initial design works as follows:

1) The bin is horizontal with a lid on top to insert and remove waste/compost.

2) There is a series of PVC blades with holes cut into them that are spun on a shaft inside the bin to aerate the compost, stir it, and collect gases that are released.

2a) Also in the bin are two 3in stainless steel bolts connects to the Arduino to collect compost moisture, and a thermisotr as well to take internal temperature.

3) The shaft is turned by a crank and series of 3" and 9" gears connected outside the bin by a rope/strap.

4) As the blades aerate the gas, there is a siphon mechanism inside the shaft that decreases the internal pressure of the shaft, causing the gases and air in the bin to be pulled through the holes and into the hollow shaft.

5) The shaft is connected to a tube that feeds into a gas chamber and exhaust.

6) Inside the gas chamber, the MQ4 methane sensor and hydrogen sulfide sensor analyzes the gases pulled in from the compost for anaerobic byproducts, lighting an LED and producing a serial print for the user to analyze.

7) The air and gases are then released through an exhaust with a carbon filter or other means to negate potential composting smells.

Also for consideration is a way to allow leachates to be collected for use as compost tea while also ensuring the compost doesn't become waterlogged.

For this week, I designed and built the frame for the bin and fitted it to ensure stability and compactness.

See the photos on the right for the steps for building the frame:



Week2 Narrative
For the second week of this project, I am developing the hardware and code for a means to monitor the internal temperature and moisture of the compost.

My initial design is to use 3in stainless steel bolts, separated by about 3-4", and sticking up through the bottom of the bin. These bolts will be soldered to wire and connected to the analog pin and 5v pin of the Arduino. The Arduino will send a charge, and the Arduino will measure the resistance that the compost carries in order to determine an approximate moisture percentage. (Ideally, within +/-5% accuracy.) To take the internal temperature of the compost, I will take the thermistor from the Disaster Toilet project, moisture-proof it with shrink tubing, recalibrate using 0-100C temperatures, and alter the same Arduino code from the aforementioned project.

Considerations:

- The bolts will need to allow clearance of the rotating PVC pipes.

- The bottom of the bin may accumulate liquids which can create false low resistance measurements; this needs to be addressed by either coating the bottoms of the bolts or covering them.

- Will any capacitive energy left from the bolts' discharge during moisture reading affect the thermistor's accuracy?

- Can the above capacitive energy be solved by delaying readings alone?

- Will Triboelectric energy generated by the airflow through the PVC shaft, or the PVC pipes near the plastic, affect electrical readings? or will it be negligible?

Shopping:

The only materials I needed, outside of more solder for my soldering iron, was the following that I got at Radioshack and Harbor Freight - 22-gauge insulated wire - Marine-application heat shrink

Design:

The circuit design for the soil moisture reader is as follows:

Digital Pin 1---10kresistor--Stainless Steel Bolt] (space for compost/soil to be measured) [Stainless Steel bolt--Analog Pin 1 (analog pin 0 is reserved for the thermistor)Ground

The bolts are 3in long, and will be secured into a waterproof container which will ensure the bolts: 1) Are the same distance apart 2) Moisture doesn't collect or get absorbed by its mounting material, ensuring the moisture reading is strictly based on the compost and not any pooled water.

The container will be located on the bottom of the bin, in the middle of the bin if considering it from the width and length perspective. The wiring will run out from the bottom of the bin to the Arduino located outside the bin and attached to the frame. For now, the data will print to the serial monitor on the computer, but the next step will be programing it to print to an LCD monitor, or to indicate moisture ratings with LEDs.

The code:

The code will be a basic voltage divider code, taking the low value of 0 (open air reading) and the highest reading (submerged in water). Then, the Arduino will be coded to run a simple percentage formula and print an int value for the soil moisture reading.

Example: Open air reading: 0000; water reading: 900. The coding will take the A1 input on the 1024 bit scale, and divide that result by 900. If the resistance measured is 600, the code will run: 600/900=66.66666.... as a float value, then will prin the int value of 67% moisture.

Issues?: Once trials begin, I will have to take multiple readings to make sure that the resistance varies in a linear way, and not in a logistic or logarithmic way. In other words, if the resistance does not change in a 99% accuracy ratio to the actual moisture content, the linear model of dividing by the highest known value will not provide an accurate reading; this would then require taking multiple readings (4-8) and creating a linear or quadratic regression model and using those coefficients in tandem with the voltage divider readings to get a more accurate reading. This, however, will eat up a lot of bit-length in the process, considering it will require long float values for the coefficients in order to make the regression model accurate. This is all also before the thermistor and sensors are integrated as well, both of which involve high float values (the thermistor involves three high-count float values for the Steinhart-Hart equation, while the sensors will depend on their calibration and out-of-the-box accuracy working on a relative measurement scale.

Thermistor:

For the thermistor, all that needs to be done is three simple things: 1) Coat the wire and thermistor in marine application heat shrink 2) Calibrate with known temperature values (0C-100C) 3) Alter code if necessary

Results:

Here are the values and final design of the soil moisture reader and thermistor:

Low Value=0

High Value=880

Code:
 * 1) include math.h
 * 2) define moisture_input 0
 * 3) define divider_top 2
 * 4) define divider_bottom 3

int moisture; // analogical value obtained from the experiment

int SoilMoisture{ int reading; // set driver pins to outputs pinMode(divider_top,OUTPUT); pinMode(divider_bottom,OUTPUT);

// drive a current through the divider in one direction digitalWrite(divider_top,LOW); digitalWrite(divider_bottom,HIGH);

// wait a moment for capacitance effects to settle delay(1000);

// take a reading reading=analogRead(moisture_input);

// reverse the current digitalWrite(divider_top,HIGH); digitalWrite(divider_bottom,LOW);

// give as much time in 'reverse' as in 'forward' delay(1000);

// stop the current digitalWrite(divider_bottom,LOW); reading==reading/880;

return reading; }

void setup { Serial.begin(9600);

}

void loop (void) { moisture=SoilMoisture; // assign the result of SoilMoisture to the global variable 'moisture' Serial.print("Soil moisture: "); Serial.print(moisture); // print the analogical measurement of the experiment Serial.println; delay(1000); }

Problems:

The soil moisture reader array doesn't like the screws I used; when the bare wires were touching, I was getting about 880ish, but when placing both screws in water, the highest I get is 28, and when they're touching, about 461. I'm wondering if it is better to use stainless steel nails that don't have the uneven surface?

Week3 Narrative
Goals for Week 3 and beyond:

- Develop a way to store the temperature, moisture, and gas sensor readings onto a SD card or other means via the Arduino

- Program and calibrate the gas sensors; integrate them into the gas chamber

- Test the siphoning functionality and adjust for issues

- Implement a stable, permanent power source.

- House all of the electronics into a waterproof and protected case for long operation

- Test using real compost to ensure proper aeration and mechanical functionality.

- Create a mobile app/means to access the temperature, gas, and moisture readings. (Ex: Android app, website, program that analyzes SD data.)

- Test, test, test, test all systems for total functionality.

Week 3 Accomplishments:

Breadboarded the soil moisture reader with a 10k Ohm resistor. Breadboarded the DHT11 external temperature and relative humidity with a 27k Ohm. Breadboarded the internal temperature monitor. -Unfortunately, while breadboarding the AnalogInput wire, the thermistor separated from the soldered wire in the heatshrink tubing. I will have to redo the thermistor.

Code for DH11:

// Example testing sketch for various DHT humidity/temperature sensors // Written by ladyada, public domain


 * 1) include "DHT.h"


 * 1) define DHTPIN 4    // what pin we're connected to

// Uncomment whatever type you're using! //#define DHTTYPE DHT11  // DHT 11 //#define DHTTYPE DHT21  // DHT 21 (AM2301)
 * 1) define DHTTYPE DHT22  // DHT 22  (AM2302)

// Connect pin 1 (on the left) of the sensor to +5V // NOTE: If using a board with 3.3V logic like an Arduino Due connect pin 1 // to 3.3V instead of 5V! // Connect pin 2 of the sensor to whatever your DHTPIN is // Connect pin 4 (on the right) of the sensor to GROUND // Connect a 10K resistor from pin 2 (data) to pin 1 (power) of the sensor

// Initialize DHT sensor for normal 16mhz Arduino DHT dht(DHTPIN, DHTTYPE); // NOTE: For working with a faster chip, like an Arduino Due or Teensy, you // might need to increase the threshold for cycle counts considered a 1 or 0. // You can do this by passing a 3rd parameter for this threshold. It's a bit // of fiddling to find the right value, but in general the faster the CPU the // higher the value. The default for a 16mhz AVR is a value of 6. For an // Arduino Due that runs at 84mhz a value of 30 works. // Example to initialize DHT sensor for Arduino Due: //DHT dht(DHTPIN, DHTTYPE, 30);

void setup { Serial.begin(9600); Serial.println("DHTxx test!"); dht.begin; }

void loop { // Wait a few seconds between measurements. delay(2000);

// Reading temperature or humidity takes about 250 milliseconds! // Sensor readings may also be up to 2 seconds 'old' (its a very slow sensor) float h = dht.readHumidity; // Read temperature as Celsius float t = dht.readTemperature; // Read temperature as Fahrenheit float f = dht.readTemperature(true); // Check if any reads failed and exit early (to try again). if (isnan(h) || isnan(t) || isnan(f)) { Serial.println("Failed to read from DHT sensor!"); return; }

// Compute heat index // Must send in temp in Fahrenheit! float hi = dht.computeHeatIndex(f, h);

Serial.print("Humidity: "); Serial.print(h); Serial.print(" %\t"); Serial.print("Temperature: "); Serial.print(t); Serial.print(" *C "); Serial.print(f); Serial.print(" *F\t"); Serial.print("Heat index: "); Serial.print(hi); Serial.println(" *F"); }

With the external temperature and relative humidity sensor workng, now I can move onto the next and most difficult stage: the gas sensors.

Next phase: The next phase will involve taking the gas sensors, ensuring a constant supply of 5v to preheat the coils, and then, using transistors, engage the preheated sensors when the gas-level needs to be taken. This will be difficult since it's already confusing and difficult to compile the different codes I have already for moisture, internal temperature, and external temperature and relative humidity.

Problems: Unfortunately, I'm having trouble installing the DHT11 library onto my Arduino. Everytime I try to move the folder to the libraries, it says that there's no permission to do so. Even after changing the permission, it still isn't letting me upload it.

SOLVED: I managed to recreate the libraries folder and import the DHT11 library into it, and can also upload the sketch directly onto the Arduino.

Problem #2: When I attempted to assemble the code for the soil moisture and RH/Ex. temperature, the compiling creates multiple errors that I have yet to resolve, some of which might also be from the soil moisture code more than the DHT11 since I compiled the soil moisture code moreso than the DHT11.

SOLVED: By adjusting the "#include" and "Pin" values, I finally got the code as a whole to work, though the soil moisture reading is still incorrect.

Pictures:

Week4 Narrative
Final Status: End of Project 1

All together, the following has been accomplished:

-The internal thermistor has been coded and tested: though it broke during testing and will have to be redone.

-The soil moisture reader has been coded and tested: the code is incorrect for the soil moisture reader; it's still putting out incorrect readings.

-DHT11 RH/Et sensor coded and tested: works perfectly!

-Frame for the bin: designed, built, and sized; bin handles cut to fit into frame.