<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>AndrewNohawk</title>
	<atom:link href="http://andrewmohawk.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://andrewmohawk.com</link>
	<description>Just another script kiddie&#039;s ramblings</description>
	<lastBuildDate>Mon, 14 Nov 2011 17:32:23 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1</generator>
		<item>
		<title>Automated Water System</title>
		<link>http://andrewmohawk.com/2011/11/14/automated-water-system/</link>
		<comments>http://andrewmohawk.com/2011/11/14/automated-water-system/#comments</comments>
		<pubDate>Mon, 14 Nov 2011 17:03:14 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Arduino]]></category>
		<category><![CDATA[Coding]]></category>
		<category><![CDATA[Social]]></category>
		<category><![CDATA[Soil Sensor]]></category>
		<category><![CDATA[Water Pump]]></category>

		<guid isPermaLink="false">http://andrewmohawk.com/?p=333</guid>
		<description><![CDATA[So this is going to be a rather strange post as at the time of writing its not actually implemented, the system is built in a waterproof container as well as the networking setup and so on. I figure that since I will only be able to get another Arduino and ethernet shield at a [...]]]></description>
			<content:encoded><![CDATA[<p>So this is going to be a rather strange post as at the time of writing its not actually implemented, the system is built in a waterproof container as well as the networking setup and so on. I figure that since I will only be able to get another Arduino and ethernet shield at a later stage I may as well write it up for now. Below are a few pictures of the system completed:</p>
<div id="attachment_335" class="wp-caption alignleft" style="width: 160px"><a href="http://andrewmohawk.com/wp-content/uploads/2011/11/CompletedTwo.jpg"><img class="size-thumbnail wp-image-335 " title="Completed System" src="http://andrewmohawk.com/wp-content/uploads/2011/11/CompletedTwo-150x150.jpg" alt="Completed System" width="150" height="150" /></a><p class="wp-caption-text">Completed System</p></div>
<div id="attachment_334" class="wp-caption alignleft" style="width: 160px"><a href="http://andrewmohawk.com/wp-content/uploads/2011/11/CompletedOne.jpg"><img class="size-thumbnail wp-image-334 " title="Completed System" src="http://andrewmohawk.com/wp-content/uploads/2011/11/CompletedOne-150x150.jpg" alt="Completed System" width="150" height="150" /></a><p class="wp-caption-text">Completed System</p></div>
<div id="attachment_337" class="wp-caption alignleft" style="width: 160px"><a href="http://andrewmohawk.com/wp-content/uploads/2011/11/CompletedThree.jpg"><img class="size-thumbnail wp-image-337 " title="Completed System" src="http://andrewmohawk.com/wp-content/uploads/2011/11/CompletedThree-150x150.jpg" alt="Completed System" width="150" height="150" /></a><p class="wp-caption-text">Completed System</p></div>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>With regards to the requirements for the system my part spec was as follows:</p>
<ul>
<li><strong>One large reservoir</strong> &#8211; I got an 80 litre orange bucket for about R100</li>
<li><strong>Arduino + Ethernet shield</strong> &#8211; pretty stock standard</li>
<li><strong>4x 10K resistors</strong> &#8211; used for the sensors</li>
<li><strong>4x &#8216;sensors&#8217; &#8211; </strong>sensors setup as before, coiled wire (soldered if you can) and taped on</li>
<li><strong>8x galvanised steel washers</strong> &#8211; used as the actual sensors</li>
<li><strong>2x transistors </strong>- used for the relay setup</li>
<li><strong>2x relays </strong>- I used LT-5GS&#8217; for this to switch the pumps on and off</li>
<li><strong>2x Diodes</strong> &#8211; used for my relay setup</li>
<li><strong>2x Water pumps </strong>- I used two (1 per pot) honestly because it was cheaper, although not as elegant as having a electrical valves and a more intricate watering system, mine were the 1.5A 12V bilge pumps (about R150 each)</li>
<li><strong>2x Water pump power supplies</strong> &#8211; Obviously used for the pumps power, I used some cheap power adapters that didn&#8217;t cost much</li>
<li><strong>1x Arduino power supply </strong>- See <a title="http://www.arduino.cc/playground/Learning/WhatAdapter" href="http://www.arduino.cc/playground/Learning/WhatAdapter" target="_blank">http://www.arduino.cc/playground/Learning/WhatAdapter</a> for more information</li>
<li><strong>Wires, Tape, Tv Series, Patience </strong>-  essential in setting this up :)</li>
</ul>
<p><span id="more-333"></span></p>
<p>After getting the above its important to setup the environment:</p>
<p><a href="http://andrewmohawk.com/wp-content/uploads/2011/11/environment1.jpg"><img class="alignleft size-thumbnail wp-image-347" title="environment1" src="http://andrewmohawk.com/wp-content/uploads/2011/11/environment1-150x150.jpg" alt="" width="150" height="150" /></a><a href="http://andrewmohawk.com/wp-content/uploads/2011/11/environment2.jpg"><img class="alignleft size-thumbnail wp-image-348" title="environment2" src="http://andrewmohawk.com/wp-content/uploads/2011/11/environment2-150x150.jpg" alt="" width="150" height="150" /></a></p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>Overall this shouldnt cost much, apart from the Arduino and Ethernet shield. The relays are about R10 each at electronics123 (thanks to schalk from H4H for picking one up for me).</p>
<p>So the system can be divded into a few easy parts:</p>
<ol>
<li>
<ol>
<li>Sensors ( to measure soil moisture levels )</li>
<li>Pump system (relays, diodes, transistors)</li>
<li>Ethernet webserver (used to pull the stats as well as turn the pumps on and off)</li>
</ol>
</li>
</ol>
<p>&nbsp;</p>
<h2><strong>Sensors:</strong></h2>
<p>As before in the previous post &#8211; <a title="http://andrewmohawk.com/2011/10/07/automated-gardening-moisture-sensor/" href="http://andrewmohawk.com/2011/10/07/automated-gardening-moisture-sensor/">http://andrewmohawk.com/2011/10/07/automated-gardening-moisture-sensor/</a> the sensors are pretty simple to setup. I went and got a ton of electrical wiring for the pumps and so on and i needed rather long leads for the pots so I just used that. Basic idea is to simply wire up the galvanized washers as below:</p>
<div id="attachment_340" class="wp-caption alignleft" style="width: 160px"><a href="http://andrewmohawk.com/wp-content/uploads/2011/11/DSC02066_1080x810.jpg"><img class="size-thumbnail wp-image-340" title="Galvanized Sensors" src="http://andrewmohawk.com/wp-content/uploads/2011/11/DSC02066_1080x810-150x150.jpg" alt="Galvanized Sensors" width="150" height="150" /></a><p class="wp-caption-text">Galvanized Sensors</p></div>
<div id="attachment_341" class="wp-caption alignleft" style="width: 160px"><a href="http://andrewmohawk.com/wp-content/uploads/2011/11/DSC02068_1080x810.jpg"><img class="size-thumbnail wp-image-341" title="Galvanized Sensors" src="http://andrewmohawk.com/wp-content/uploads/2011/11/DSC02068_1080x810-150x150.jpg" alt="Galvanized Sensors" width="150" height="150" /></a><p class="wp-caption-text">Galvanized Sensors</p></div>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>The basic idea with these sensors is to measure the resistance via a 10K resistor across two portions of the soil, I&#8217;ve stolen a very nice picture of the setup of these from the internets and is as follows:</p>
<div id="attachment_342" class="wp-caption alignleft" style="width: 160px"><a href="http://andrewmohawk.com/wp-content/uploads/2011/11/arduino-diagram-sensors.jpg"><img class="size-thumbnail wp-image-342" title="Arduino Sensor Diagram" src="http://andrewmohawk.com/wp-content/uploads/2011/11/arduino-diagram-sensors-150x150.jpg" alt="Arduino Sensor Diagram" width="150" height="150" /></a><p class="wp-caption-text">Arduino Sensor Diagram</p></div>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>(If someone has the original for this please let me know and I will link).</p>
<p>Anyway, once you have the sensors setup, I built 4- 2 per plant so i could measure the soil moisture at the top and bottom of the pots, you can simply wire them in as the above diagram. I wired mine up to analog ports 0-3.</p>
<p>&nbsp;</p>
<h2><strong>Pump system (relays, diodes, transistors)</strong></h2>
<p>So this is obviously the more exciting part for me, since I get to play with something that I can turn on and off and get a more real world experience out of my digital life :) I had a few discussions about it with the guys from house4hack.co.za and they suggested i setup the relay in a standard way which is as follows:</p>
<div id="attachment_343" class="wp-caption alignleft" style="width: 160px"><a href="http://andrewmohawk.com/wp-content/uploads/2011/11/arduino-relay.png"><img class="size-thumbnail wp-image-343" title="arduino-relay" src="http://andrewmohawk.com/wp-content/uploads/2011/11/arduino-relay-150x150.png" alt="arduino-relay" width="150" height="150" /></a><p class="wp-caption-text">arduino-relayarduino-relay</p></div>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>Basically use your data line connected to one of the Arduino digital ports and your relay as above. The transistor now allows you to use digitalWrite to turn the pumps on or off. Below is a closer picture of the one relay in place with the other removed:</p>
<div id="attachment_344" class="wp-caption alignleft" style="width: 160px"><a href="http://andrewmohawk.com/wp-content/uploads/2011/11/realy.jpg"><img class="size-thumbnail wp-image-344" title="Relay" src="http://andrewmohawk.com/wp-content/uploads/2011/11/realy-150x150.jpg" alt="Relay" width="150" height="150" /></a><p class="wp-caption-text">Relay</p></div>
<p>&nbsp;</p>
<p>You can see the sensor setup on the left of the board, relay one in the middle and the missing relay on the right. You can see the transistor and diode setup as well.</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>When connecting the power, its also important to make sure that you have the adapters the right way round, just use a multimeter to check you know which is the positive and which is the negative wire. We only bridge the positive via the relay, the ground/negative we leave as is:</p>
<p><a href="http://andrewmohawk.com/wp-content/uploads/2011/11/power-test.jpg"><img class="alignleft size-thumbnail wp-image-349" title="power-test" src="http://andrewmohawk.com/wp-content/uploads/2011/11/power-test-150x150.jpg" alt="" width="150" height="150" /></a></p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<h2><strong>Web setup:</strong></h2>
<p>So now we have a relay setup and the sensors, its really just a case of putting two and two together. We need a simple web interface that can do the following:</p>
<ol>
<li>Give us the readings for all 4 sensors</li>
<li>Be able to control both pumps (switching on and off)</li>
</ol>
<p>Ideally the system i have in mind is not completely controlled by the arduino, but also has  a PC element to manage the water by the average soil moisture over time. Id want it to be customisable in a way that i can set the time period (say 2-6 hours) where it averages the soil moisture and determines if the pumps should be turned on or off. This is the reason I really want the webserver to essentially just spit out the values and offer me the ability to turn the pumps on and off.</p>
<p>Herewith is my Arduino Code:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">//These includes are for the webduino addon for Arduino</span>
<span style="color: #666666; font-style: italic;">#include &quot;SPI.h&quot;
</span><span style="color: #666666; font-style: italic;">#include &quot;Ethernet.h&quot;
</span><span style="color: #666666; font-style: italic;">#include &quot;WebServer.h&quot;
</span>
<span style="color: #666666; font-style: italic;">//Define the MAC and IP for our interface</span>
static uint8_t mac<span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span> <span style="color: #208080;">0xDE</span><span style="color: #339933;">,</span> <span style="color: #208080;">0xAD</span><span style="color: #339933;">,</span> <span style="color: #208080;">0xBE</span><span style="color: #339933;">,</span> <span style="color: #208080;">0xEF</span><span style="color: #339933;">,</span> <span style="color: #208080;">0xFE</span><span style="color: #339933;">,</span> <span style="color: #208080;">0xED</span> <span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
static uint8_t ip<span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span> <span style="color: #cc66cc;">192</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">168</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">210</span> <span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//Prefix</span>
<span style="color: #666666; font-style: italic;">#define PREFIX &quot;/&quot;
</span>WebServer webserver<span style="color: #009900;">&#40;</span>PREFIX<span style="color: #339933;">,</span> <span style="color: #cc66cc;">80</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//Define which digital ports are used for which pump (mine are ports 3 and 4)</span>
<span style="color: #666666; font-style: italic;">#define pump1 3
</span><span style="color: #666666; font-style: italic;">#define pump2 4
</span>
<span style="color: #666666; font-style: italic;">//Variables used to indicate whether the pumps are on (1) or off (0)</span>
static int relayPump1 <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
static int relayPump2 <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//Variables used to store the moisture readings</span>
int moisture_val1 <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
int moisture_val2 <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
int moisture_val3 <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
int moisture_val4 <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//Variables used to store the analog ports used for the sensors (mine are 0-3)</span>
int moisture_sensor1 <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
int moisture_sensor2 <span style="color: #339933;">=</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span>
int moisture_sensor3 <span style="color: #339933;">=</span> <span style="color: #cc66cc;">2</span><span style="color: #339933;">;</span>
int moisture_sensor4 <span style="color: #339933;">=</span> <span style="color: #cc66cc;">3</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//Toggles the first pump</span>
void pumpOne<span style="color: #009900;">&#40;</span>WebServer <span style="color: #339933;">&amp;</span>amp<span style="color: #339933;">;</span>server<span style="color: #339933;">,</span> WebServer<span style="color: #339933;">::</span><span style="color: #004000;">ConnectionType</span> type<span style="color: #339933;">,</span> char <span style="color: #339933;">*,</span> bool<span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
  server<span style="color: #339933;">.</span>httpSuccess<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>type <span style="color: #339933;">!=</span> WebServer<span style="color: #339933;">::</span><span style="color: #004000;">HEAD</span><span style="color: #009900;">&#41;</span>
  <span style="color: #009900;">&#123;</span>
    relayPump1 <span style="color: #339933;">=</span> <span style="color: #339933;">!</span>relayPump1<span style="color: #339933;">;</span>
    switchPumps<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//Toggles the second pump</span>
void pumpTwo<span style="color: #009900;">&#40;</span>WebServer <span style="color: #339933;">&amp;</span>amp<span style="color: #339933;">;</span>server<span style="color: #339933;">,</span> WebServer<span style="color: #339933;">::</span><span style="color: #004000;">ConnectionType</span> type<span style="color: #339933;">,</span> char <span style="color: #339933;">*,</span> bool<span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
  server<span style="color: #339933;">.</span>httpSuccess<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>type <span style="color: #339933;">!=</span> WebServer<span style="color: #339933;">::</span><span style="color: #004000;">HEAD</span><span style="color: #009900;">&#41;</span>
  <span style="color: #009900;">&#123;</span>
    relayPump2 <span style="color: #339933;">=</span> <span style="color: #339933;">!</span>relayPump2<span style="color: #339933;">;</span>
    switchPumps<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//List the statistics for the webserver</span>
void getStats<span style="color: #009900;">&#40;</span>WebServer <span style="color: #339933;">&amp;</span>amp<span style="color: #339933;">;</span>server<span style="color: #339933;">,</span> WebServer<span style="color: #339933;">::</span><span style="color: #004000;">ConnectionType</span> type<span style="color: #339933;">,</span> char <span style="color: #339933;">*,</span> bool<span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
  server<span style="color: #339933;">.</span>httpSuccess<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>type <span style="color: #339933;">!=</span> WebServer<span style="color: #339933;">::</span><span style="color: #004000;">HEAD</span><span style="color: #009900;">&#41;</span>
  <span style="color: #009900;">&#123;</span>
&nbsp;
    moisture_val1 <span style="color: #339933;">=</span> analogRead<span style="color: #009900;">&#40;</span>moisture_sensor1<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    moisture_val2 <span style="color: #339933;">=</span> analogRead<span style="color: #009900;">&#40;</span>moisture_sensor2<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    moisture_val3 <span style="color: #339933;">=</span> analogRead<span style="color: #009900;">&#40;</span>moisture_sensor3<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    moisture_val4 <span style="color: #339933;">=</span> analogRead<span style="color: #009900;">&#40;</span>moisture_sensor4<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    server<span style="color: #339933;">.</span><span style="color: #b1b100;">print</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Pump one: &quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    server<span style="color: #339933;">.</span><span style="color: #b1b100;">print</span><span style="color: #009900;">&#40;</span>relayPump1<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    server<span style="color: #339933;">.</span><span style="color: #b1b100;">print</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;
Pump two: &quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    server<span style="color: #339933;">.</span><span style="color: #b1b100;">print</span><span style="color: #009900;">&#40;</span>relayPump2<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    server<span style="color: #339933;">.</span><span style="color: #b1b100;">print</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;
Sensor 1: &quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    server<span style="color: #339933;">.</span><span style="color: #b1b100;">print</span><span style="color: #009900;">&#40;</span>moisture_val1<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    server<span style="color: #339933;">.</span><span style="color: #b1b100;">print</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;
Sensor 2: &quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    server<span style="color: #339933;">.</span><span style="color: #b1b100;">print</span><span style="color: #009900;">&#40;</span>moisture_val2<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    server<span style="color: #339933;">.</span><span style="color: #b1b100;">print</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;
Sensor 3: &quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    server<span style="color: #339933;">.</span><span style="color: #b1b100;">print</span><span style="color: #009900;">&#40;</span>moisture_val3<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    server<span style="color: #339933;">.</span><span style="color: #b1b100;">print</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;
Sensor 4: &quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    server<span style="color: #339933;">.</span><span style="color: #b1b100;">print</span><span style="color: #009900;">&#40;</span>moisture_val4<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
&nbsp;
  <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//Main loop</span>
void loop<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
&nbsp;
  <span style="color: #666666; font-style: italic;">/* process incoming connections one at a time forever */</span>
  webserver<span style="color: #339933;">.</span>processConnection<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//switch the pumps</span>
int switchPumps<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
	<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span>relayPump1 <span style="color: #339933;">==</span> <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
	  digitalWrite<span style="color: #009900;">&#40;</span>pump1<span style="color: #339933;">,</span>HIGH<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	  <span style="color: #666666; font-style: italic;">//Serial.println(&quot;Pump1 Activated&quot;);</span>
	<span style="color: #009900;">&#125;</span>
	<span style="color: #b1b100;">else</span> <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span>relayPump1 <span style="color: #339933;">==</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
	  digitalWrite<span style="color: #009900;">&#40;</span>pump1<span style="color: #339933;">,</span>LOW<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	  <span style="color: #666666; font-style: italic;">//Serial.println(&quot;Pump1 De-Activated&quot;);</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span>relayPump2 <span style="color: #339933;">==</span> <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
	  digitalWrite<span style="color: #009900;">&#40;</span>pump2<span style="color: #339933;">,</span>HIGH<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	  <span style="color: #666666; font-style: italic;">//Serial.println(&quot;Pump2 Activated&quot;);</span>
	<span style="color: #009900;">&#125;</span>
	<span style="color: #b1b100;">else</span> <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span>relayPump2 <span style="color: #339933;">==</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
	  digitalWrite<span style="color: #009900;">&#40;</span>pump2<span style="color: #339933;">,</span>LOW<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	  <span style="color: #666666; font-style: italic;">//Serial.println(&quot;Pump2 De-Activated&quot;);</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #b1b100;">return</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//Setup the server - switch the pumps to OUTPUT</span>
void setup<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
  pinMode<span style="color: #009900;">&#40;</span>pump1<span style="color: #339933;">,</span>OUTPUT<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  pinMode<span style="color: #009900;">&#40;</span>pump2<span style="color: #339933;">,</span>OUTPUT<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
  Ethernet<span style="color: #339933;">.</span>begin<span style="color: #009900;">&#40;</span>mac<span style="color: #339933;">,</span> ip<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  webserver<span style="color: #339933;">.</span>setDefaultCommand<span style="color: #009900;">&#40;</span><span style="color: #339933;">&amp;</span>amp<span style="color: #339933;">;</span>getStats<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  webserver<span style="color: #339933;">.</span>addCommand<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;pumpOne&quot;</span><span style="color: #339933;">,</span> <span style="color: #339933;">&amp;</span>amp<span style="color: #339933;">;</span>pumpOne<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  webserver<span style="color: #339933;">.</span>addCommand<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;pumpTwo&quot;</span><span style="color: #339933;">,</span> <span style="color: #339933;">&amp;</span>amp<span style="color: #339933;">;</span>pumpTwo<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  webserver<span style="color: #339933;">.</span>addCommand<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;stats&quot;</span><span style="color: #339933;">,</span> <span style="color: #339933;">&amp;</span>amp<span style="color: #339933;">;</span>getStats<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
  <span style="color: #666666; font-style: italic;">/* start the webserver */</span>
  webserver<span style="color: #339933;">.</span>begin<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #009900;">&#125;</span></pre></div></div>

<h2><strong>Completion:</strong></h2>
<p>Once I&#8217;d completed the above sensors and arduino&#8217;s, I popped them into the waterproof container and was good to go with my final testing environment and container:</p>
<p><a href="http://andrewmohawk.com/wp-content/uploads/2011/11/endEnvironment.jpg"><img class="alignleft size-thumbnail wp-image-350" title="endEnvironment" src="http://andrewmohawk.com/wp-content/uploads/2011/11/endEnvironment-150x150.jpg" alt="" width="150" height="150" /></a><a href="http://andrewmohawk.com/wp-content/uploads/2011/11/endEnvironment2.jpg"><img class="alignleft size-thumbnail wp-image-351" title="endEnvironment2" src="http://andrewmohawk.com/wp-content/uploads/2011/11/endEnvironment2-150x150.jpg" alt="" width="150" height="150" /></a><a href="http://andrewmohawk.com/wp-content/uploads/2011/11/powerbox.jpg"><img class="alignleft size-thumbnail wp-image-353" title="powerbox" src="http://andrewmohawk.com/wp-content/uploads/2011/11/powerbox-150x150.jpg" alt="" width="150" height="150" /></a></p>
<p><a href="http://andrewmohawk.com/wp-content/uploads/2011/11/inbox.jpg"><img class="alignleft size-thumbnail wp-image-352" title="inbox" src="http://andrewmohawk.com/wp-content/uploads/2011/11/inbox-150x150.jpg" alt="" width="150" height="150" /></a></p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>However my ethernet shield seems to have overheated and popped itself and the arduino, so I will need to get a replacement for them (<strong>feel free to donate me yours :D). </strong>Once i have this I will definitely include the server side code to manage the watering and web interface as well<strong>. </strong></p>
<p>&nbsp;</p>
<p><strong>-AM<br />
</strong></p>
<div id="_mcePaste" class="mcePaste" style="position: absolute; left: -10000px; top: 4556px; width: 1px; height: 1px; overflow: hidden;">//These includes are for the webduino addon for Arduino<br />
#include &#8220;SPI.h&#8221;<br />
#include &#8220;Ethernet.h&#8221;<br />
#include &#8220;WebServer.h&#8221;&nbsp;</p>
<p>//Define the MAC and IP for our interface<br />
static uint8_t mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };<br />
static uint8_t ip[] = { 192, 168, 1, 210 };</p>
<p>//Prefix<br />
#define PREFIX &#8220;/&#8221;<br />
WebServer webserver(PREFIX, 80);</p>
<p>//Define which digital ports are used for which pump (mine are ports 3 and 4)<br />
#define pump1 3<br />
#define pump2 4</p>
<p>//Variables used to indicate whether the pumps are on (1) or off (0)<br />
static int relayPump1 = 0;<br />
static int relayPump2 = 0;</p>
<p>//Variables used to store the moisture readings<br />
int moisture_val1 = 0;<br />
int moisture_val2 = 0;<br />
int moisture_val3 = 0;<br />
int moisture_val4 = 0;</p>
<p>//Variables used to store the analog ports used for the sensors (mine are 0-3)<br />
int moisture_sensor1 = 0;<br />
int moisture_sensor2 = 1;<br />
int moisture_sensor3 = 2;<br />
int moisture_sensor4 = 3;</p>
<p>//Toggles the first pump<br />
void pumpOne(WebServer &amp;server, WebServer::ConnectionType type, char *, bool)<br />
{<br />
server.httpSuccess();<br />
if (type != WebServer::HEAD)<br />
{<br />
relayPump1 = !relayPump1;<br />
switchPumps();<br />
}<br />
}</p>
<p>//Toggles the second pump<br />
void pumpTwo(WebServer &amp;server, WebServer::ConnectionType type, char *, bool)<br />
{<br />
server.httpSuccess();<br />
if (type != WebServer::HEAD)<br />
{<br />
relayPump2 = !relayPump2;<br />
switchPumps();<br />
}<br />
}</p>
<p>//List the statistics for the webserver<br />
void getStats(WebServer &amp;server, WebServer::ConnectionType type, char *, bool)<br />
{<br />
server.httpSuccess();<br />
if (type != WebServer::HEAD)<br />
{</p>
<p>moisture_val1 = analogRead(moisture_sensor1);<br />
moisture_val2 = analogRead(moisture_sensor2);<br />
moisture_val3 = analogRead(moisture_sensor3);<br />
moisture_val4 = analogRead(moisture_sensor4);</p>
<p>server.print(&#8220;Pump one: &#8220;);<br />
server.print(relayPump1);<br />
server.print(&#8220;&lt;br/&gt;Pump two: &#8220;);<br />
server.print(relayPump2);<br />
server.print(&#8220;&lt;br/&gt;Sensor 1: &#8220;);<br />
server.print(moisture_val1);<br />
server.print(&#8220;&lt;br/&gt;Sensor 2: &#8220;);<br />
server.print(moisture_val2);<br />
server.print(&#8220;&lt;br/&gt;Sensor 3: &#8220;);<br />
server.print(moisture_val3);<br />
server.print(&#8220;&lt;br/&gt;Sensor 4: &#8220;);<br />
server.print(moisture_val4);</p>
<p>}<br />
}</p>
<p>//Main loop<br />
void loop()<br />
{</p>
<p>/* process incoming connections one at a time forever */<br />
webserver.processConnection();<br />
}</p>
<p>//switch the pumps<br />
int switchPumps()<br />
{<br />
if(relayPump1 == 1)<br />
{<br />
digitalWrite(pump1,HIGH);<br />
//Serial.println(&#8220;Pump1 Activated&#8221;);<br />
}<br />
else if(relayPump1 == 0)<br />
{<br />
digitalWrite(pump1,LOW);<br />
//Serial.println(&#8220;Pump1 De-Activated&#8221;);<br />
}</p>
<p>if(relayPump2 == 1)<br />
{<br />
digitalWrite(pump2,HIGH);<br />
//Serial.println(&#8220;Pump2 Activated&#8221;);<br />
}<br />
else if(relayPump2 == 0)<br />
{<br />
digitalWrite(pump2,LOW);<br />
//Serial.println(&#8220;Pump2 De-Activated&#8221;);<br />
}</p>
<p>return 0;<br />
}</p>
<p>//Setup the server &#8211; switch the pumps to OUTPUT<br />
void setup()<br />
{<br />
pinMode(pump1,OUTPUT);<br />
pinMode(pump2,OUTPUT);</p>
<p>Ethernet.begin(mac, ip);<br />
webserver.setDefaultCommand(&amp;getStats);<br />
webserver.addCommand(&#8220;pumpOne&#8221;, &amp;pumpOne);<br />
webserver.addCommand(&#8220;pumpTwo&#8221;, &amp;pumpTwo);<br />
webserver.addCommand(&#8220;stats&#8221;, &amp;getStats);</p>
<p>/* start the webserver */<br />
webserver.begin();</p>
<p>}</p>
</div>
]]></content:encoded>
			<wfw:commentRss>http://andrewmohawk.com/2011/11/14/automated-water-system/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Automated Moisture Sensor</title>
		<link>http://andrewmohawk.com/2011/10/07/automated-gardening-moisture-sensor/</link>
		<comments>http://andrewmohawk.com/2011/10/07/automated-gardening-moisture-sensor/#comments</comments>
		<pubDate>Thu, 06 Oct 2011 23:56:13 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Arduino]]></category>
		<category><![CDATA[Coding]]></category>
		<category><![CDATA[Social]]></category>
		<category><![CDATA[Soil Moisture]]></category>
		<category><![CDATA[Soil Sensor]]></category>

		<guid isPermaLink="false">http://andrewmohawk.com/?p=302</guid>
		<description><![CDATA[I&#8217;ve always been harping on about growing my own tomatoes and other veggies and earlier this year i attempted it for a while.Unfortunately with me going away for various conferences and generally being a forgetful lout i managed to kill many many plants! What i wanted was: What I got was: So recently I was [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve always been harping on about growing my own tomatoes and other veggies and earlier this year i attempted it for a while.Unfortunately with me going away for various conferences and generally being a forgetful lout i managed to kill many many plants!</p>
<p>What i wanted was:</p>
<p><img title="What i wanted!" src="http://2.bp.blogspot.com/-3PFuYhPWNrQ/TWFu6lmF69I/AAAAAAAAAGU/0g_8S8ElsPY/s1600/patio+tomato.jpg" alt="What i wanted!" width="270" height="338" /></p>
<p>What I got was:</p>
<p><img title="What I Got" src="http://www.zanekohler.com/storage/production-blog/jasmin-plant.jpg" alt="What I Got" width="270" /></p>
<p>So recently I was playing with my arduino and thinking about this, and got the idea to try and create an automated gardening system where my plants where automatically given water/light/etc without me having to worry about it. There are some fantastic resources online like http://www.instructables.com/id/Garduino-Gardening-Arduino/ and http://makeprojects.com/Project/Garduino-Geek-Gardening/62/1.</p>
<p>I began planning something i&#8217;d want, and ideally it would have to be this:</p>
<ul>
<li>Moisture control for water</li>
<li>Water pump to water them</li>
<li>Light sensors for Lights and LEDs (red and blue for optimal growth)</li>
<li>Humidity to keep my plants cosy</li>
<li>Interface via LCD/Web to see how things are doing (if more water is needed etc)</li>
<li>Solar panel to allow the system to be completely stand alone</li>
</ul>
<p><span id="more-302"></span></p>
<p>I looked at some of the things and it appears that the solar panel wont be powerful enough to power the relay for the pump as well as the LEDs, so thats out initially till i find a better plan. And I think that the LEDs can be avoided for now with me probably going to have this thing outside.</p>
<p>First things first, i decided to look at the moisture sensor, since thats what i&#8217;d initially need to make the water system work. Basically it checks the moisture levels in the soil and if the soil is too dry it will need to either turn on a water pump or change a valve or something to let the water flow. So i started looking around and you can buy moisture sensors for a few hundred bucks, but ACTUALLY they just measure resistance in soil so you can easily do this with a 2 pieces of wire, a resistor and some nuts (although these may not be required):</p>
<div id="attachment_303" class="wp-caption aligncenter" style="width: 160px"><a href="http://andrewmohawk.com/wp-content/uploads/2011/10/requirements.jpg"><img class="size-thumbnail wp-image-303" title="requirements" src="http://andrewmohawk.com/wp-content/uploads/2011/10/requirements-150x150.jpg" alt="Basic Requirements" width="150" height="150" /></a><p class="wp-caption-text">Basic Requirements</p></div>
<p>After this just strip either end of the wire and coil one side round one of the nuts (its essentially our &#8216;sensor&#8217;), you will need two pieces per sensor. Basically looks like this:</p>
<div class="mceTemp mceIEcenter" style="text-align: left;">
<dl id="attachment_304" class="wp-caption   aligncenter" style="width: 160px;">
<dt class="wp-caption-dt"><a href="http://andrewmohawk.com/wp-content/uploads/2011/10/coiled.jpg"><img class="size-thumbnail wp-image-304" title="Coiled Sensor" src="http://andrewmohawk.com/wp-content/uploads/2011/10/coiled-150x150.jpg" alt="Coiled Sensor" width="150" height="150" /></a></dt>
<dd class="wp-caption-dd">Coiled Sensor</dd>
</dl>
</div>
<p>Next you want to connect this to the Arduino. One &#8216;sensor&#8217; is connected to your 5V source. The other &#8216;sensor&#8217; is connected to one side of the resistor along with a line to an analog port. The other side of the sensor is merely connected to the ground of the Arduino.</p>
<p>You can then read the resistence by simply doing something like: <em><strong>soilMoisture = analogRead(0)</strong></em> if it was connected to analog port 0.</p>
<p>Heres a video I made of a single sensor, and you can see the value changing as I pour water into the  pot:</p>
<p><object style="height: 390px; width: 640px;"><param name="movie" value="http://www.youtube.com/v/BPgtkBPbY_4?version=3" /><param name="allowFullScreen" value="true" /><param name="allowScriptAccess" value="always" /><embed type="application/x-shockwave-flash" width="640" height="360" src="http://www.youtube.com/v/BPgtkBPbY_4?version=3" allowfullscreen="true" allowscriptaccess="always"></embed></object></p>
<p>Of course just 1 sensor is cool, but we can do better, we can place 3 sensors at different levels of the pot and monitor the changes in resistence as the water trickles down to the roots, I also have an LCD connected to mine as you saw in the previous video to watch the changes. Here is the a 3 sensor system to watch the water adding resistance at depths.</p>
<div id="attachment_305" class="wp-caption aligncenter" style="width: 160px"><a href="http://andrewmohawk.com/wp-content/uploads/2011/10/3Sensors.jpg"><img class="size-thumbnail wp-image-305" title="3 Sensor Setup" src="http://andrewmohawk.com/wp-content/uploads/2011/10/3Sensors-150x150.jpg" alt="3 Sensor Setup" width="150" height="150" /></a><p class="wp-caption-text">3 Sensor Setup</p></div>
<p>And finally a video of it working:<br />
<object style="height: 390px; width: 640px;"><param name="movie" value="http://www.youtube.com/v/8hFtv5rJRR4?version=3" /><param name="allowFullScreen" value="true" /><param name="allowScriptAccess" value="always" /><embed type="application/x-shockwave-flash" width="640" height="360" src="http://www.youtube.com/v/8hFtv5rJRR4?version=3" allowfullscreen="true" allowscriptaccess="always"></embed></object></p>
<p>Also the code for this for my Arduino:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#include &lt;LiquidCrystal.h&gt;
</span>LiquidCrystal lcd<span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">12</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">11</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">5</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">4</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">3</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">2</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
int moisture_val1 <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
int moisture_val2 <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
int moisture_val3 <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
&nbsp;
int moisture_sensor1 <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
int moisture_sensor2 <span style="color: #339933;">=</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span>
int moisture_sensor3 <span style="color: #339933;">=</span> <span style="color: #cc66cc;">2</span><span style="color: #339933;">;</span>
&nbsp;
String moistureString <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;&quot;</span><span style="color: #339933;">;</span>
&nbsp;
void setup<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  <span style="color: #666666; font-style: italic;">// set up the LCD's number of columns and rows: </span>
   lcd<span style="color: #339933;">.</span>begin<span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">16</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">2</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
void loop<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  lcd<span style="color: #339933;">.</span>clear<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  lcd<span style="color: #339933;">.</span><span style="color: #b1b100;">print</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Soil Sensor:&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  lcd<span style="color: #339933;">.</span>setCursor<span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  moisture_val1 <span style="color: #339933;">=</span> analogRead<span style="color: #009900;">&#40;</span>moisture_sensor1<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  moisture_val2 <span style="color: #339933;">=</span> analogRead<span style="color: #009900;">&#40;</span>moisture_sensor2<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  moisture_val3 <span style="color: #339933;">=</span> analogRead<span style="color: #009900;">&#40;</span>moisture_sensor3<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
  moistureString <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;&quot;</span><span style="color: #339933;">;</span>
  moistureString <span style="color: #339933;">=</span> moisture_val1<span style="color: #339933;">;</span>
  moistureString <span style="color: #339933;">=</span> moistureString <span style="color: #339933;">+</span> <span style="color: #0000ff;">&quot;/&quot;</span><span style="color: #339933;">;</span>
  moistureString <span style="color: #339933;">=</span> moistureString <span style="color: #339933;">+</span> moisture_val2<span style="color: #339933;">;</span>
  moistureString <span style="color: #339933;">=</span> moistureString <span style="color: #339933;">+</span> <span style="color: #0000ff;">&quot;/&quot;</span><span style="color: #339933;">;</span>
  moistureString <span style="color: #339933;">=</span> moistureString <span style="color: #339933;">+</span> moisture_val3<span style="color: #339933;">;</span>
  moistureString <span style="color: #339933;">=</span> moistureString<span style="color: #339933;">;</span>
&nbsp;
  lcd<span style="color: #339933;">.</span><span style="color: #b1b100;">print</span><span style="color: #009900;">&#40;</span>moistureString<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  delay<span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">1000</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>Cheers,<br />
Andrew</p>
]]></content:encoded>
			<wfw:commentRss>http://andrewmohawk.com/2011/10/07/automated-gardening-moisture-sensor/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>zacon badges</title>
		<link>http://andrewmohawk.com/2011/09/27/zacon-badges/</link>
		<comments>http://andrewmohawk.com/2011/09/27/zacon-badges/#comments</comments>
		<pubDate>Tue, 27 Sep 2011 00:09:45 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[Social]]></category>
		<category><![CDATA[Badges]]></category>
		<category><![CDATA[ZACon]]></category>

		<guid isPermaLink="false">http://andrewmohawk.com/?p=288</guid>
		<description><![CDATA[zacon &#8211; http://www.zacon.org.za/ &#8211; is just around the corner now, so badge submission went out. Wasn&#8217;t particularly inspired but i hacked together 3 diff ones, now we just wait and see. UPDATE Decided to go with the Spy badges, what do you think? &#160;]]></description>
			<content:encoded><![CDATA[<p>zacon &#8211; <a title="http://www.zacon.org.za/" href="http://www.zacon.org.za/">http://www.zacon.org.za/</a> &#8211; is just around the corner now, so badge submission went out. Wasn&#8217;t particularly inspired but i hacked together 3 diff ones, now we just wait and see.</p>

<a href='http://andrewmohawk.com/2011/09/27/zacon-badges/zacon3-spybadge-volunteer/' title='ZACon3-spybadge-volunteer'><img width="150" height="150" src="http://andrewmohawk.com/wp-content/uploads/2011/09/ZACon3-spybadge-volunteer-150x150.png" class="attachment-thumbnail" alt="ZACon3-spybadge-volunteer" title="ZACon3-spybadge-volunteer" /></a>
<a href='http://andrewmohawk.com/2011/09/27/zacon-badges/zacon3-spybadge-speaker/' title='ZACon3-spybadge-speaker'><img width="150" height="150" src="http://andrewmohawk.com/wp-content/uploads/2011/09/ZACon3-spybadge-speaker-150x150.png" class="attachment-thumbnail" alt="ZACon3-spybadge-speaker" title="ZACon3-spybadge-speaker" /></a>
<a href='http://andrewmohawk.com/2011/09/27/zacon-badges/zacon3-spybadge-conner/' title='ZACon3-spybadge-conner'><img width="150" height="150" src="http://andrewmohawk.com/wp-content/uploads/2011/09/ZACon3-spybadge-conner-150x150.png" class="attachment-thumbnail" alt="ZACon3-spybadge-conner" title="ZACon3-spybadge-conner" /></a>
<a href='http://andrewmohawk.com/2011/09/27/zacon-badges/zacon3-spybadge-organiser/' title='ZACon3-spybadge-organiser'><img width="150" height="150" src="http://andrewmohawk.com/wp-content/uploads/2011/09/ZACon3-spybadge-organiser-150x150.png" class="attachment-thumbnail" alt="ZACon3-spybadge-organiser" title="ZACon3-spybadge-organiser" /></a>
<a href='http://andrewmohawk.com/2011/09/27/zacon-badges/zacon3-spybadge/' title='ZACon3-spybadge'><img width="150" height="150" src="http://andrewmohawk.com/wp-content/uploads/2011/09/ZACon3-spybadge-150x150.png" class="attachment-thumbnail" alt="ZACon3-spybadge" title="ZACon3-spybadge" /></a>
<a href='http://andrewmohawk.com/2011/09/27/zacon-badges/zacon3-selloutflame/' title='ZACon3-selloutflame'><img width="150" height="150" src="http://andrewmohawk.com/wp-content/uploads/2011/09/ZACon3-selloutflame-150x150.png" class="attachment-thumbnail" alt="ZACon3-selloutflame" title="ZACon3-selloutflame" /></a>
<a href='http://andrewmohawk.com/2011/09/27/zacon-badges/zacon3-badcloud4/' title='ZACon3-badcloud4'><img width="150" height="150" src="http://andrewmohawk.com/wp-content/uploads/2011/09/ZACon3-badcloud4-150x150.png" class="attachment-thumbnail" alt="ZACon3-badcloud4" title="ZACon3-badcloud4" /></a>

<p><strong>UPDATE</strong></p>
<p>Decided to go with the Spy badges, what do you think?</p>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://andrewmohawk.com/2011/09/27/zacon-badges/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>pasteLert *facepalm*</title>
		<link>http://andrewmohawk.com/2011/09/09/pastelert-facepalm/</link>
		<comments>http://andrewmohawk.com/2011/09/09/pastelert-facepalm/#comments</comments>
		<pubDate>Fri, 09 Sep 2011 10:01:07 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[alerting]]></category>
		<category><![CDATA[pastebin]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://andrewmohawk.com/?p=284</guid>
		<description><![CDATA[Sorry guys, I noticed that I haven&#8217;t been getting any pasteLert updates, and i just realised why (see above picture for my reaction). Change line 4 in truncPastes.php from: mysql_query(&#8220;truncate pastebin&#8221;); To: mysql_query(&#8220;delete from pastebin&#8221;); &#160; Explanation: Truncate automatically resets the auto-incrementing IDs so that when the table was truncated pastes started from ID 0 [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://assets.sbnation.com/assets/562900/facepalm_medium.jpg" alt="facepalm" /></p>
<p>Sorry guys, I noticed that I haven&#8217;t been getting any pasteLert updates, and i just realised why (see above picture for my reaction).</p>
<p>Change line 4 in <strong>truncPastes.php</strong> from:</p>
<p>mysql_query(&#8220;truncate pastebin&#8221;);</p>
<p><strong>To:</strong></p>
<p>mysql_query(&#8220;delete from pastebin&#8221;);</p>
<p>&nbsp;</p>
<p><strong>Explanation:</strong></p>
<p>Truncate automatically resets the auto-incrementing IDs so that when the table was truncated pastes started from ID 0 again, which when checked against what the last ID sent to the user was obviously lower. Sorry for the headache, to fix it, apply the above then run:</p>
<p><strong>update alerts set LastID = 0;</strong></p>
<p>&nbsp;</p>
<p>Mah bad,<br />
-AM</p>
]]></content:encoded>
			<wfw:commentRss>http://andrewmohawk.com/2011/09/09/pastelert-facepalm/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PasteLert Source</title>
		<link>http://andrewmohawk.com/2011/08/24/pastelert-source/</link>
		<comments>http://andrewmohawk.com/2011/08/24/pastelert-source/#comments</comments>
		<pubDate>Wed, 24 Aug 2011 00:26:26 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[alerting]]></category>
		<category><![CDATA[pastebin]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://andrewmohawk.com/?p=276</guid>
		<description><![CDATA[Ohhi Archive for pasteLert So i finally got round to putting the source together and writing this out. We&#8217;ve been really busy with Blackhat training at work and so on and i&#8217;m generally just lazy. Also releasing now mostly because the mysql database on my linode keeps crashing, its just too small a box to [...]]]></description>
			<content:encoded><![CDATA[<p>Ohhi</p>
<p><a title="Archive for pasteLert" href="http://andrewmohawk.com/pasteLert/pasteLert.zip">Archive for pasteLert</a></p>
<p>So i finally got round to putting the source together and writing this out. We&#8217;ve been really busy with Blackhat training at work and so on and i&#8217;m generally just lazy. Also releasing now mostly because the mysql database on my linode keeps crashing, its just too small a box to keep *all* pastebin entries. The code is messy, so expect arb/no commenting but its pretty straight forward, feel free to shoot through any questions you have. Also i messaged pastebin to see if they&#8217;d implement something like this or let me do it, but i didnt get any responses to any of the messages :(</p>
<p>Anyway, here is the basic rundown:</p>
<ul>
<li>Setup your mysql, create a database &#8216;pastebin&#8217; &#8211; Google will give you this info :D</li>
<li>Drop the structure in, its in the archive as pastebinStructure.sql. <em>mysql -u root -p pastebin &lt; pastebinStructure.sql</em></li>
<li>Extract the archive to its own directory in your webroot, preferably &#8216;pasteLert&#8217; :)</li>
<li>Change the setdb.php file to your mysql details. Edit alerts.php to include your email and location information rather than mine</li>
<li>Setup the crons as below</li>
</ul>
<p><strong>Crons:</strong></p>
<p>Basically there are 4 cron jobs that you need to add:</p>
<ul>
<li><strong>pullPastebin.php</strong> &#8211; this will go to http://www.pastebin.com/archive.php and get the pasteIDs and add them to `pastebin`.`pastebin`, I generally run this every 2 minutes and my cron looks like this:
<ul>
<li>*/2 * * * * php /var/www/html/andrewmohawk.com/pasteLert/pullPastebin.php</li>
</ul>
</li>
<li><strong>pullPastes.php &#8211; </strong>this script then goes and pulls each paste with a random delay between 0-5 seconds (see line 14 if you want to change that). I generally let this run every 10 minutes and looks as follows:
<ul>
<li>*/10 * * * * php /var/www/html/andrewmohawk.com/pasteLert/pullPastes.php</li>
</ul>
</li>
<li><strong>sendAlerts.php &#8211; </strong>this script sends out the alerts via email, this is really up to you, obviously as close to 10 minutes means its as close to when you have the data, mines at 15 mins:
<ul>
<li>*/15 * * * * php /var/www/html/andrewmohawk.com/pasteLert/sendAlerts.php</li>
</ul>
</li>
</ul>
<p><strong>Cron Part 2!<br />
</strong>So the reason my box was falling over was that every day i&#8217;d push all the pastebin&#8217;s from that day into another table (pastebinOldData). Essentially i have now changed mine to stop doing this and rather truncated the daily log instead of saving the data.  You however hopefully have a bigger box and can store all the data, or you can always just truncate the data, so you need to pick one of the two files, either truncPastes.php or rotatePastes.php.</p>
<p><strong>Truncate:<br />
</strong>0 1 * * * php /var/www/html/andrewmohawk.com/pasteLert/truncPastes.php</p>
<p><strong>Rotate:<br />
</strong>0 1 * * * php /var/www/html/andrewmohawk.com/pasteLert/rotatePastes.php</p>
<p>I think that pretty much covers it, feel free to mail in what you are looking for if you need any help.</p>
<p>Kthnx,<br />
Andrew</p>
]]></content:encoded>
			<wfw:commentRss>http://andrewmohawk.com/2011/08/24/pastelert-source/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PasteLert! Pastebin Alerts!</title>
		<link>http://andrewmohawk.com/2011/06/30/pastelert-pastebin-alerts/</link>
		<comments>http://andrewmohawk.com/2011/06/30/pastelert-pastebin-alerts/#comments</comments>
		<pubDate>Thu, 30 Jun 2011 21:14:41 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[alerting]]></category>
		<category><![CDATA[pastebin]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://andrewmohawk.com/?p=266</guid>
		<description><![CDATA[ANDREW I DONT CARE ABOUT YOUR STORIES! JUST GIVE ME THE LINK! &#62;&#62; http://andrewmohawk.com/pasteLert/ Hey guys, So here is my latest project, extending from the previous pasteScraper to do something a little different with the pastebins. Essentially i recreated google alerts but with a bit more searchiness (yes, i make up words now too). How [...]]]></description>
			<content:encoded><![CDATA[<p><code>ANDREW I DONT CARE ABOUT YOUR STORIES! JUST GIVE ME THE LINK! &gt;&gt; <a href="http://andrewmohawk.com/pasteLert/" target="_blank">http://andrewmohawk.com/pasteLert/</a></code></p>
<p>Hey guys,</p>
<p>So here is my latest project, extending from the previous <a href="http://andrewmohawk.com/2011/06/22/pastescraper-update-now-without-config/">pasteScraper</a> to do something a little different with the pastebins. Essentially i recreated google alerts but with a bit more searchiness (yes, i make up words now too).</p>
<h2>How it Works</h2>
<ul>
<li>I enumerate all new pastes from http://www.pastebin.com/archive/ every minute and add them to a &#8216;download&#8217; queue.</li>
<li>New pastes are then downloaded to a local database</li>
<li>Alerts are periodically cron&#8217;d</li>
<li>Search functionality is via a fulltext search of pastes</li>
</ul>
<h2>What does it give me?</h2>
<ul>
<li>The ability to search for *anything* on pastebin.com</li>
<li>Semi-realtime searches</li>
<li>Email alerts when your term is hit!</li>
<li>RSS feeds for searches</li>
<li>The ability to search with AND keywords in pastebins</li>
</ul>
<h2>How it is all going to fall apart</h2>
<p>I dont really see this as a long term project, merely something that  shows a PoC for how much stuff is leaking out via PasteBin.com and how  cool it really is. Some issues i see that may happen with this:</p>
<ul>
<li>People will switch to more secure pastebins that don&#8217;t allow  indexing, don&#8217;t have archive pages and arent indexed by search engines</li>
<li>My small linode will fall to pieces because the fulltext like queries are painfull</li>
<li>Pastebin.com will not be impressed with me doing this and start blocking it</li>
</ul>
<h2>Linkage</h2>
<p><a href="http://andrewmohawk.com/pasteLert/">http://andrewmohawk.com/pasteLert/</a>, feel free to play/comment/etc :)</p>
<p>-AM</p>
<p>&nbsp;</p>
<p>p.s. Thanks to <a title="Chris Hadnagy" href="https://twitter.com/#%21/humanhacker">Chris Hadnagy</a> and Roelof Temmingh :D</p>
]]></content:encoded>
			<wfw:commentRss>http://andrewmohawk.com/2011/06/30/pastelert-pastebin-alerts/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Plot wardrives without a GPS</title>
		<link>http://andrewmohawk.com/2011/06/26/plot-wardrives-without-a-gps/</link>
		<comments>http://andrewmohawk.com/2011/06/26/plot-wardrives-without-a-gps/#comments</comments>
		<pubDate>Sun, 26 Jun 2011 16:29:41 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[airodump-ng]]></category>
		<category><![CDATA[google]]></category>
		<category><![CDATA[google earth]]></category>
		<category><![CDATA[GPS]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://andrewmohawk.com/?p=261</guid>
		<description><![CDATA[So this is the only entry i have where i&#8217;ve built an app that wont work from day 1. &#8220;Oh why andrew, why?&#8221; you might say, but as I shrug, this was not my fault. So a while back Samy Kamkar produced his geolocation proof of concept code which works awesomely at being able to [...]]]></description>
			<content:encoded><![CDATA[<p>So this is the only entry i have where i&#8217;ve built an app that wont work from day 1.</p>
<p>&#8220;Oh why andrew, why?&#8221; you might say, but as I shrug, this was not my fault. So a while back <a title="Samy Kamkar" href="http://samy.pl/" target="_blank">Samy Kamkar</a> produced his <a href="http://samy.pl/mapxss/" target="_blank">geolocation proof of concept code</a> which works awesomely at being able to take an AP MAC Address to GPS Co-ordinates. Sadly now however Google location services seem to be broken at the moment with both Samy&#8217;s and my code being horribly broken with the results either being the same GPS Co-ordinates or 0,0.</p>
<p>This happened of course only *after* i had completed my app (had to do multithreading and slap a design on it) .</p>
<p>But anyway, here is the basic idea of it:</p>
<ul>
<li>Recieve in a <strong>NON GPSd</strong> airodump-ng csv file</li>
<li>Parse out all of the AP MAC Addresses</li>
<li>Take these to GPS co-ordinates to street addresses via <a href="http://wiki.openstreetmap.org/wiki/Nominatim" target="_blank">opennominatim</a></li>
<li>Return this response either as a KML file (plotted on google earth)</li>
<li>OR as a text file to simply display the results</li>
</ul>
<p>So anyway, you can have a look at the application over at <a title="Airodump vs GEO" href="http://andrewmohawk.com/airodumpvsgeo/" target="_blank">http://andrewmohawk.com/airodumpvsgeo/</a> . Currently still in my shite naming &#8216;convention&#8217; this one is called &#8220;AirodumpvsGEO&#8221;.</p>
<p>-AM</p>
]]></content:encoded>
			<wfw:commentRss>http://andrewmohawk.com/2011/06/26/plot-wardrives-without-a-gps/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PasteScraper (now sans config)!</title>
		<link>http://andrewmohawk.com/2011/06/22/pastescraper-update-now-without-config/</link>
		<comments>http://andrewmohawk.com/2011/06/22/pastescraper-update-now-without-config/#comments</comments>
		<pubDate>Tue, 21 Jun 2011 23:54:56 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[pastebin]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://andrewmohawk.com/?p=255</guid>
		<description><![CDATA[So i was chatting to Chris Hadnagy and he was having a bit of an issue getting an API key for yahoo BOSS and it seemed troublesome. So i popped off a mail to yahoo to ask how i could get a key to share and they basically said i can just use mine. So [...]]]></description>
			<content:encoded><![CDATA[<p>So i was chatting to <a title="Chris Hadnagy" href="https://twitter.com/#!/humanhacker">Chris Hadnagy</a> and he was having a bit of an issue getting an API key for yahoo BOSS and it seemed troublesome.</p>
<p>So i popped off a mail to yahoo to ask how i could get a key to share and they basically said i can just use mine. So i quickly repackaged the pasteScraper with my key so now its as simple as extracting the zip in your webroot directory and browsing to it :)</p>
<p><a href="http://andrewmohawk.com/pasteScrape/pasteBinScrape2.zip">Get the new one here</a></p>
<p>Of course you can still use the one on my site over at <a title="http://www.andrewmohawk.com/pasteScrape/" href="http://www.andrewmohawk.com/pasteScrape/">http://www.andrewmohawk.com/pasteScrape/</a></p>
<p>Enjoy!<br />
-AM</p>
]]></content:encoded>
			<wfw:commentRss>http://andrewmohawk.com/2011/06/22/pastescraper-update-now-without-config/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>VMWare User Information Leak</title>
		<link>http://andrewmohawk.com/2011/04/13/vmware-user-information-leak/</link>
		<comments>http://andrewmohawk.com/2011/04/13/vmware-user-information-leak/#comments</comments>
		<pubDate>Wed, 13 Apr 2011 21:05:21 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[information leak]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[VMWare]]></category>

		<guid isPermaLink="false">http://andrewmohawk.com/?p=246</guid>
		<description><![CDATA[Click here to search the VMWare user database! So last week some time Chris Hadnagy linked me to the following URL: http://info.vmware.com/content/opt-out which was pretty interesting last week. Basically it allowed someone to full in their email address to manage their VMWare subscriptions, i noticed a couple of things from the next pages: The fields [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.andrewmohawk.com/VMWareScraper" target="_blank">Click here to search the VMWare user database!</a></p>
<p>So last week some time <a href="http://www.social-engineer.org/" target="_blank">Chris Hadnagy</a> linked me to the following URL: <a href="http://info.vmware.com/content/opt-out" target="_blank">http://info.vmware.com/content/opt-out</a> which was pretty interesting last week. Basically it allowed someone to full in their email address to manage their VMWare subscriptions, i noticed a couple of things from the next pages:</p>
<ul>
<li>The fields auto populated with details like Name, Phone Number etc (i know, without auth and only an email address &#8211; worriedface)</li>
<li>Another tab became available that allowed you to <strong>update</strong> your details &#8211; again, no auth, scary</li>
</ul>
<p>So i whipped out the good old <a title="firebug" href="http://getfirebug.com/" target="_blank">firebug</a> and started looking through the ajax calls till i came across this little gem:</p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;">http://now.eloqua.com/visitor/v200/svrGP.aspx?pps=50&amp;amp;siteid=524&amp;amp;DLKey=&lt;strong&gt;&amp;lt;sessionkey&amp;gt;&lt;/strong&gt;&amp;amp;DLLookup=%3CC_EmailAddress%3E&lt;strong&gt;&amp;lt;email_address&amp;gt;&lt;/strong&gt;%3C/C_EmailAddress%3E&amp;amp;ms=59</pre></div></div>

<p>and the resulting page looked something like:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">function</span> GetElqContentPersonalizationValue<span style="color: #009900;">&#40;</span>strDataField<span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
<span style="color: #003366; font-weight: bold;">var</span> strTemp <span style="color: #339933;">=</span> <span style="color: #3366CC;">''</span><span style="color: #339933;">;</span>
<span style="color: #006600; font-style: italic;">//alert('Data Field: ' + strDataField);</span>
<span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>strDataField <span style="color: #339933;">==</span> <span style="color: #3366CC;">'C_EmailAddress'</span> <span style="color: #339933;">||</span> strDataField <span style="color: #339933;">==</span> <span style="color: #3366CC;">'EmailAddress'</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>strTemp <span style="color: #339933;">=</span> <span style="color: #3366CC;">'andrewmohawk<span style="color: #000099; font-weight: bold;">\x</span>40gmail.com'</span><span style="color: #339933;">;</span><span style="color: #009900;">&#125;</span>
<span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>strDataField <span style="color: #339933;">==</span> <span style="color: #3366CC;">'C_FirstName'</span> <span style="color: #339933;">||</span> strDataField <span style="color: #339933;">==</span> <span style="color: #3366CC;">'FirstName'</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>strTemp <span style="color: #339933;">=</span> <span style="color: #3366CC;">'Andrew'</span><span style="color: #339933;">;</span><span style="color: #009900;">&#125;</span>
<span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>strDataField <span style="color: #339933;">==</span> <span style="color: #3366CC;">'C_LastName'</span> <span style="color: #339933;">||</span> strDataField <span style="color: #339933;">==</span> <span style="color: #3366CC;">'LastName'</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>strTemp <span style="color: #339933;">=</span> <span style="color: #3366CC;">'MacPherson'</span><span style="color: #339933;">;</span><span style="color: #009900;">&#125;</span></pre></div></div>

<p>Yeah, great info straight in that.. EEEK! So being the script kiddie (seriously, scripting languages FTW) i wrote a tiny PHP application to pull this info and display.</p>
<p>However the issue was that if you could update someones account, then you could simply change their email address, do a password reset and gain access to a commercial account giving people access to software that someone else paid loads for &#8212; this isnt cool so i didnt put the link out. However this week VMWare have removed the update page and the auto-populating fields &#8212; yet my scraper still works so i figured i&#8217;d put it out.</p>
<p>I&#8217;ve specifically left out the sessionkey to make it at least not a trivial cut and paste to get info yourself since it may still be possible to update from that code.</p>
<p>Just another leak i guess. But if anyone has any other links/ideas/stuff for me to play with, contact form&#8217;s on the left :)</p>
<p>Cheers,<br />
Andrew</p>
<p><a href="http://www.andrewmohawk.com/VMWareScraper" target="_blank">Click here to search the VMWare user database!</a></p>
]]></content:encoded>
			<wfw:commentRss>http://andrewmohawk.com/2011/04/13/vmware-user-information-leak/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Pastebin Scraper</title>
		<link>http://andrewmohawk.com/2011/03/25/pastebin-scraper/</link>
		<comments>http://andrewmohawk.com/2011/03/25/pastebin-scraper/#comments</comments>
		<pubDate>Fri, 25 Mar 2011 18:29:55 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[pastebin]]></category>

		<guid isPermaLink="false">http://andrewmohawk.com/?p=233</guid>
		<description><![CDATA[Yeah im really lazy, so im not gonna write a lot about it, basically, if you wanna use it on my site hit it up at http://www.andrewmohawk.com/pasteScrape/ otherwise feel free to download it and run it yourself from this archive Basically, go to http://www.andrewmohawk.com/pasteScrape/ and try some of these: &#8220;gmail/facebook Password&#8221; &#8211; free facebook/gmail/whatever accounts [...]]]></description>
			<content:encoded><![CDATA[<p>Yeah im really lazy, so im not gonna write a lot about it, basically, if you wanna use it on my site hit it up at <a title="http://www.andrewmohawk.com/pasteScrape/" href="http://www.andrewmohawk.com/pasteScrape/">http://www.andrewmohawk.com/pasteScrape/</a> otherwise feel free to download it and run it yourself from <a title="this archive" href="http://www.andrewmohawk.com/pasteScrape/pasteBinScrape.zip">this archive</a></p>
<p>Basically, go to <a title="http://www.andrewmohawk.com/pasteScrape/" href="http://www.andrewmohawk.com/pasteScrape/">http://www.andrewmohawk.com/pasteScrape/</a> and try some of these:</p>
<ol>
<li>&#8220;gmail/facebook Password&#8221; &#8211; free facebook/gmail/whatever accounts</li>
<li>&#8220;rbot&#8221; &#8211; find rbot config files, including the passwords and the irc network that it connects to, ie, if you have an irc client you get a free botnet</li>
<li>&#8220;enable password&#8221; &#8211; Cisco goodness</li>
<li>&#8220;BEGIN PGP&#8221; &#8211; pgp keys anyone?</li>
<li>&#8220;DB_PASSWORD&#8221; &#8211; loads of database passwords</li>
<li>&#8220;Shellcode&#8221; or &#8220;Exploit&#8221;</li>
</ol>
<p>You get the idea :)</p>
<p>&nbsp;</p>
<p>Enjoy my readme  after the break :D<br />
<strong>INDEX</strong><br />
&#8212;&#8212;&#8212;&#8212;-<br />
<strong>1 //</strong> What is PasteBinScraper?<br />
<strong>2 //</strong> How does it work?<br />
<strong>3 //</strong> How do i use it?<br />
<strong>4 //</strong> How do i install?<br />
<strong>5 //</strong> Extending<br />
<strong>6 //</strong> TODO<br />
<strong>7 //</strong> Thanks<br />
<span id="more-233"></span></p>
<p><strong>1. What is PasteBinScraper</strong><br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br />
Originally concieved as a method to enumerate various pastebins (slexy,pastie,pastebin,gisthub) as a response to corelans<br />
pastenum &#8211; <a title="http://www.corelan.be/index.php/2011/03/22/pastenum-pastebinpastie-enumeration-tool/" href="http://www.corelan.be/index.php/2011/03/22/pastenum-pastebinpastie-enumeration-tool/">http://www.corelan.be/index.php/2011/03/22/pastenum-pastebinpastie-enumeration-tool/</a>, its changed slightly to a more general enumerator.<br />
Pastenum is a ruby application that runs client side to enumerate various bins, this just took it a bit further by putting it in a web application<br />
as mine kept crashing trying to load the previous results.</p>
<p>Think of it as a means of searching various pastebins for information.</p>
<p><strong>Pro Tip:</strong><br />
Try &#8220;facebook password&#8221;,&#8221;gmail password&#8221;,&#8221;password enable&#8221;,&#8221;scada&#8221;,etc</p>
<p><strong>2. How does it work?</strong><br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br />
PasteBinScraper works in one of two ways:</p>
<p><strong>Using Yahoo!BOSS Search API:</strong><br />
Basically does &lt;term&gt; site:&lt;site&gt; and returns all the results with highlighting of the phrases.<br />
eg. go to yahoo, and search for &#8220;DB_PASSWORD site:pastebin.com&#8221;</p>
<p><strong>Using Cusom Scraping Scripts:</strong><br />
At the moment i&#8217;ve just included a basic (read ugly, badly coded) script to enumerate pastie.org (i did speak to the owner to ask if it was alright!),<br />
essentially the frontend simply calls the script and returns the results under one of the tabs. It calls the script with a &#8216;q&#8217; GET parameter so something like</p>
<p>http://&lt;server&gt;/libs/myscript.php?q=Search+Term</p>
<p>These scripts are all located in the libs/ directory under the root.</p>
<p><strong>3. How do i use it?</strong><br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
Err, type in a phrase top right and click search :D The tabs will show which have loaded and once you see the &#8216;show&#8217; button you can simply click on it<br />
to view the results :)</p>
<p><strong>4. How do i install?</strong><br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
Pretty simple, pull the archive from wherever (not sure where it will be hosted at time of writing this) and extract it to somewhere within your<br />
webservers (apache/iis/etc) webroot&#8230; something like /var/www/PasteBin/</p>
<p>Next change your config file (libs/config.php) and add the yahoo API key (get it at http://developer.yahoo.com/search/boss/ &#8211; its free!)<br />
^ its line 14 :)</p>
<p>You can then simply browse to it and go :)</p>
<p>For it to work you will need a webserver that has php, php5-curl and you may want to change the &#8216;memory_limit =&#8217; field in your php.ini to something like<br />
memory_limit = 128MB. This is because the multi-threaded requests take a bit of mem :)</p>
<p>If you are on ubuntu basically its:<br />
sudo apt-get install apache2 php5 libapache2-mod-php5 php5-curl<br />
(but most hosts should have this)</p>
<p><strong>5. Extending</strong><br />
&#8212;&#8212;&#8212;&#8212;&#8212;<br />
Extending is a relatively simple process whereby you either add a site, or you add a custom script.</p>
<p>Within libs/config.php you will see two arrays under the pastebin section:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">/* PasteBin Section
--------------------
Please note there needs to be the same number of identifiers as types... *duh*
*/</span>
<span style="color: #000088;">$PasteBin_Identifiers</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
<span style="color: #0000ff;">&quot;Pastie.org&quot;</span><span style="color: #339933;">,</span>
<span style="color: #0000ff;">&quot;Pastebin.com&quot;</span><span style="color: #339933;">,</span>
<span style="color: #0000ff;">&quot;Codepad.org&quot;</span><span style="color: #339933;">,</span>
<span style="color: #0000ff;">&quot;Slexy.org&quot;</span>
<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//Types can either be 'yahoo' (for doing term site:identifier) or a custom script, like 'mypastie.php'</span>
<span style="color: #000088;">$PasteBin_Types</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
<span style="color: #0000ff;">&quot;pastie.php&quot;</span><span style="color: #339933;">,</span>
<span style="color: #0000ff;">&quot;yahoo&quot;</span><span style="color: #339933;">,</span>
<span style="color: #0000ff;">&quot;yahoo&quot;</span><span style="color: #339933;">,</span>
<span style="color: #0000ff;">&quot;yahoo&quot;</span><span style="color: #339933;">,</span>
<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Basically you want to add to both of these to extend it. $PasteBin_Identifiers is an array of the sites to enumerate and $PasteBin_Types defines the method.<br />
For the types you can set it as a specific script (which you need to put in libs/) such as &#8216;pastie.php&#8217; in the default application. Alternatively you can use<br />
the keyword &#8220;yahoo&#8221; to tell the app to use a search engine.</p>
<p>So with the above definitions if i wanted to add gist.github.com to search aswell and i didnt want to code anything i would change them as follows:</p>
<p>Before:<br />
&#8212;&#8212;-</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$PasteBin_Identifiers</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
<span style="color: #0000ff;">&quot;Pastie.org&quot;</span><span style="color: #339933;">,</span>
<span style="color: #0000ff;">&quot;Pastebin.com&quot;</span><span style="color: #339933;">,</span>
<span style="color: #0000ff;">&quot;Codepad.org&quot;</span><span style="color: #339933;">,</span>
<span style="color: #0000ff;">&quot;Slexy.org&quot;</span>
<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$PasteBin_Types</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
<span style="color: #0000ff;">&quot;pastie.php&quot;</span><span style="color: #339933;">,</span>
<span style="color: #0000ff;">&quot;yahoo&quot;</span><span style="color: #339933;">,</span>
<span style="color: #0000ff;">&quot;yahoo&quot;</span><span style="color: #339933;">,</span>
<span style="color: #0000ff;">&quot;yahoo&quot;</span>
<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>After:<br />
&#8212;&#8212;</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$PasteBin_Identifiers</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
<span style="color: #0000ff;">&quot;Pastie.org&quot;</span><span style="color: #339933;">,</span>
<span style="color: #0000ff;">&quot;Pastebin.com&quot;</span><span style="color: #339933;">,</span>
<span style="color: #0000ff;">&quot;Codepad.org&quot;</span><span style="color: #339933;">,</span>
<span style="color: #0000ff;">&quot;Slexy.org&quot;</span><span style="color: #339933;">,</span>
<span style="color: #0000ff;">&quot;gist.github.com&quot;</span>
<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$PasteBin_Types</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
<span style="color: #0000ff;">&quot;pastie.php&quot;</span><span style="color: #339933;">,</span>
<span style="color: #0000ff;">&quot;yahoo&quot;</span><span style="color: #339933;">,</span>
<span style="color: #0000ff;">&quot;yahoo&quot;</span><span style="color: #339933;">,</span>
<span style="color: #0000ff;">&quot;yahoo&quot;</span><span style="color: #339933;">,</span>
<span style="color: #0000ff;">&quot;yahoo&quot;</span>
<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>BAM! now refresh the interface and you will notice it updated and now has a new tab &#8211; with just 2 lines added! :)</p>
<p>Alternatively if you wanted to code something up you would place your script in the libs/ directory and then change it to the following:<br />
Before:<br />
&#8212;&#8212;-</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$PasteBin_Identifiers</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
<span style="color: #0000ff;">&quot;Pastie.org&quot;</span><span style="color: #339933;">,</span>
<span style="color: #0000ff;">&quot;Pastebin.com&quot;</span><span style="color: #339933;">,</span>
<span style="color: #0000ff;">&quot;Codepad.org&quot;</span><span style="color: #339933;">,</span>
<span style="color: #0000ff;">&quot;Slexy.org&quot;</span>
<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$PasteBin_Types</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
<span style="color: #0000ff;">&quot;pastie.php&quot;</span><span style="color: #339933;">,</span>
<span style="color: #0000ff;">&quot;yahoo&quot;</span><span style="color: #339933;">,</span>
<span style="color: #0000ff;">&quot;yahoo&quot;</span><span style="color: #339933;">,</span>
<span style="color: #0000ff;">&quot;yahoo&quot;</span>
<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>After:<br />
&#8212;&#8212;</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$PasteBin_Identifiers</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
<span style="color: #0000ff;">&quot;Pastie.org&quot;</span><span style="color: #339933;">,</span>
<span style="color: #0000ff;">&quot;Pastebin.com&quot;</span><span style="color: #339933;">,</span>
<span style="color: #0000ff;">&quot;Codepad.org&quot;</span><span style="color: #339933;">,</span>
<span style="color: #0000ff;">&quot;Slexy.org&quot;</span><span style="color: #339933;">,</span>
<span style="color: #0000ff;">&quot;gist.github.com&quot;</span>
<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$PasteBin_Types</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
<span style="color: #0000ff;">&quot;pastie.php&quot;</span><span style="color: #339933;">,</span>
<span style="color: #0000ff;">&quot;yahoo&quot;</span><span style="color: #339933;">,</span>
<span style="color: #0000ff;">&quot;yahoo&quot;</span><span style="color: #339933;">,</span>
<span style="color: #0000ff;">&quot;yahoo&quot;</span><span style="color: #339933;">,</span>
<span style="color: #0000ff;">&quot;my_gist_script.php&quot;</span>
<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>again, BAM! etc etc</p>
<p><strong>6. TODO</strong></p>
<p>&#8212;&#8212;&#8211;</p>
<p>6.1 The app definitely needs to be checked for anything dodgy (xss etc). (if you find it, PLEASE dont own my box, i will cry.)</p>
<p>6.2 &#8216;API&#8217; functionality &#8212; something to just change the output to be xml so that other applications can use it (although they have the code anyway -shrug-)</p>
<p>6.3 Rework the code into a real framework (but im lazy and just like coding PoC stuff)</p>
<p>6.4 Suggestions?</p>
<p><strong>7. Thanks</strong></p>
<p>&#8212;&#8212;&#8212;&#8211;</p>
<p>Just wanna say thanks to the corelan guys for getting me off my ass and doing something else (hey 2 days is better than 0).</p>
<p>Thanks for the motivation from nullthreat,corelanc0d3r,ekse,singe,etc. Josh from pastie.org for giving me the A-OK etc.</p>
<p>If theres any changes/stuff/hatemail feel free to mail me (<a title="andrew@andrewmohawk.com" href="mailto:andrew@andrewmohawk.com">andrew@andrewmohawk.com</a>) or <a title="@andrewmohawk" href="http://www.twitter.com/andrewmohawk">@andrewmohawk</a>.</p>
<p>Payments in alchoholic beverage form, attractive females and other will be considered.</p>
<p>﻿</p>
]]></content:encoded>
			<wfw:commentRss>http://andrewmohawk.com/2011/03/25/pastebin-scraper/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

