loading
Hello guys, i make this instructable for the people that  liked the electronics and the botanic, with this you have the data about  the temperatura and the humidity of your orchard and register this in a data base MySQL.

For this proyect you need some knowledge of programing in PHP and MySQL, we will make three archive .php, but this I'll explain in the following steps.

Step 1: You need this

For this project, you need:

Arduino UNO or similar board  ($29.95)

http://www.sparkfun.com/products/11021

WiFly Shield ($89.95)
http://www.sparkfun.com/products/9954

Grove - Moisture sensor ($4.99)
http://www.seeedstudio.com/depot/grove-moisture-sensor-p-955.html?cPath=144_147

Six Jumper Wires ($4.50)
http://www.sparkfun.com/products/9387

DS18B20 Temperature Sensor with metal tip ($10.59)
http://www.olimex.cl/product_info.php?cPath=21_138&products_id=872&product__name=Breadborad_jumper_wire_pack

If only  need, One protoboar ($9.58)
http://www.olimex.cl/product_info.php?currency=USD&products_id=170&product__name=Proto_Board_Bread_board


AND....

you need a server WEB, with PHP and database MySQL. I used the NAS of QNAP TS-110, is perfect for this project.


Advertisement

<p>hello. I just want to asking about the connect.php. What do you mean by &quot;your_ipserver&quot; ?</p>
Hi, &quot;your_ip server&quot; is the address where you host the server MySQL. In this case, is &quot;127.0.0.1&quot;, to connect the localhost.
<p>will you help me to use ethernet shield to do the same task...</p>
<p>which one in it?</p>
<p>None of these data will be used , if you are using phpMyAdmin , go to the tab &quot; Estado Actual&quot; ( as from image ) and in the section of server, have the direction of you need.</p>
<p>hai. I'm having a problem with the arduino coding. It said as shown in the image:</p>
<p>This error is because you have not included the OneWire library, I recommend you download the version 2.0 from here: http://www.pjrc.com/teensy/td_libs_OneWire.html</p>
<p>can i do this without WiFly Shield? (using cable in serial connection)</p>
<p>Use Arduino.h or arduino.h instead of Wprogram.h hope it works for you too...</p>
<p>thnx i will try</p>
<p>Hi Camilo i got some problem, i got some error with ur arduino codes. Here the message : </p><p>Arduino: 1.6.6 (Windows 10), Board: &quot;Arduino Nano, ATmega328&quot;</p><p>In file included from C:\Program Files\Arduino\libraries\WiFly/SpiUart.h:7:0,</p><p> from C:\Program Files\Arduino\libraries\WiFly/WiFly.h:4,</p><p> from C:\Users\Documents\Arduino\Coba\Coba.ino:8:</p><p>C:\Program Files\Arduino\libraries\WiFly/_Spi.h:8:22: fatal error: WProgram.h: No such file or directory</p><p> #include &lt;WProgram.h&gt;</p><p> ^</p><p>compilation terminated.</p><p>exit status 1</p><p>Error compiling.</p><p> This report would have more information with</p><p> &quot;Show verbose output during compilation&quot;</p><p> enabled in File &gt; Preferences.</p>
<p>Hi XiongL. I think you need to set IP Address of your PHP Server (Web server + PHP + MySQL). In short means, in your ardunio, you will build a link address like this http://192.168.1.199/add.php?temp1=temp&amp;moi1=sensorValue. Obviously, vars &quot;temp&quot; and &quot;sensorValue&quot; will contain measured values from sensors. In the file add.php you will catch this data and then run code PHP to insert them in MySQL.</p>
<p>hi can tell me </p><p>Client client( &quot;your_website&quot;, 80 );</p><p>your_website what should i put ? </p>
<p>i`m using arduino yun via wifi can use the same code as yours ?</p>
<p>Hi ,i use this code in arduino but nothin works</p><p>client.print(&quot; GET / add.php?value=&quot;);<br> <br> client.print(&quot;54&quot;);<br> client.println( &quot; HTTP/1.1&quot;);<br> client.println( &quot;Host: <a href="http://www.dnb1654.com" rel="nofollow"> www.dnb1654.com&quot; </a> );<br> client.println( &quot;Content-Type: application/x-www-form-urlencoded&quot; );<br> client.println( &quot;Connection: close&quot; );<br> client.println();<br> client.println();<br> <br> client.stop();</p>
Hello, <br> I need help regarding sending my sensor's values to database. I am unable to send the values instead variable to which i am passing these values is showing me zero at database.
<p>I love u..., I'm many grateful! :D </p>
<p>hi i am using cc3000 wifishield so i have to send sensor data to phpserver how to modify code and where plzz help me in this </p><p>thanks</p>
<p>Hello again, I did the same steps which you were did till I reached to show the content of database in the website, but it seems there is a problem between add php and arduino. the arduino sends the data but it is not shown in the website can have a look at it thanks</p>
Hi! Send me the code for review and test to see what is going wrong . My email is camilo.nunez@cnf.cl
<p>thanks for your efforts. can I use the blue WiFi shield instead of the red one that you use it. what is the example you suggest to use it.</p>
If you mean the original Shield Arduino WiFi , you need to read the page of the project : https://www.arduino.cc/en/Main/ArduinoWiFiShield<br><br>Good luck !
<p>Nice Tutorial. <br>Can I Add a LCD to display the temperature on it and also save it in the database.</p>
<p>Hello camilo. <br>thanks for your nice post which was very helpful.</p><p>i want to make a data storage and monitoring using Arduino uno &amp; Arduino ethernet shield W5100. please help me by PHP &amp; Arduino code.</p><p>Thanks and waiting for replay.</p>
<p>Hi ! In the case for the Ethernet Shiel, you only need modify the data of the Shield, then, you work with the variables &quot;temp&quot; and &quot;sensorValue&quot;. If you have more doubts, write me to my email camilo.nunez@cnf.cl</p><p>Regards and good luck !</p>
<p>Hola Camilo:</p><p>Muy buen tutorial, felicidades.</p><p>Que tendria que cambiar en el script de arduino, estoy utilizando un Wifi Shield cc3000 de Adafruit en lugar del WiiFly?</p>
<p>Hola Victor ! Bueno para serte honesto, no he trabajado nunca con ese modulo, pero como el programa es gen&eacute;rico en sus variables, lo que te debe importar al momento de trabajar con otros m&oacute;dulos, es que tus variables &quot;temp&quot; y &quot;sensorValue&quot; no cambien cuando manipules el Script. Si tienes m&aacute;s dudas me avisas ! Exito y muchas gracias !</p>
<p>hye.. nice posting..can you help me?because im beginner in this programming. where to put all of the code for database mysql?</p>
Hi ! For the use of MySQL you must have a server that hosted on same hosting or plan, then you only need to upload the .sql file to import the table. Greetings!
<p>Is it possible to do the same with Ultrasonic sensor and what code is necessary to do?</p>
<p>how to that?im really newbie...</p>
<p>hi,can we implement this using arduino ethernet shield</p>
<p>hye..where i have to put all this files?i just manually added?</p>
<p>Hello,</p><p>Can this work with water flow sensor? I need to create a similar project but to measure the flow rate of water. The sensor type i'm intending to use is SKU: POW110D3B. </p><p>Thanks and awaiting for your reply</p>
Hi !<br>Yes, you can, I recommend use this tutorial to get the sensor code: http://goo.gl/HBoZyr<br><br>Good luck !
<p>Hola... excelente trabajo... por lo que he visto envias datos desde tu arduino a una base de datos en SQL, y la visualizas en un browser.... pero en el caso que quieras activar una se&ntilde;al digital, lo haces desde tu front por medio del SQL o desde tu front directamente hacia Arduino?</p>
Hola Eddie. Si te refieres al Front-end de una se&ntilde;al digital, debe ser por medio del Arduino. Saludos !
<p>Hi</p><p>I tried the link goo.gl/g1lbSm but the page could not be found. Any idea?</p><p>Best regards Carl</p>
<p>Thanks for the great instructions! </p><p>one small error/typo found in the arduino code:</p><p>client.print(&quot;temp<strong>t</strong>1=&quot;);<br>should be:<br>client.print(&quot;temp1=&quot;);</p><p>Being dyslectic it took my 20 minutes to figure this out (-:</p><p>But once I found the error, ot worked like a charm and was easily adjusted for my needs.</p>
<p>Hi ! Thanks for correct the mistake, not pass without noticing. I've already changed the page. Thank you very much!</p>
<p>Hey guys, I am new here. How can I download the files (.php and .ino)?</p><p>Thanks. :)</p>
Hi Ivan ! This is the link where you can download the files : http://goo.gl/D20rsE<br><br>Good lucky !
<p>Hello. I'm doing a project that is based on receiving data of temperature, wind speed and things like that. But I'm using Arduino Y&uacute;n in case of Arduino Uno+Wifly. </p><p>Which differences will be having the code?</p>
Hi Oscar, well, for your case, I recommend you read this Instructables: <br><br>http://goo.gl/g1IbSm<br><br>The difference lies in Bridge and in which language you want to work with to the database, if PHO or Python. It will depend on your project.<br><br>If you need more information about working with databases Arduino YUN, please tell me to help.<br><br>Many luck!
<p>Hi Camilo,</p><p>Nice tutorial !!</p><p>I am trying to upload temperature from temperature sensor. I am using temperature sensor, arduino uno, arduino ethernet shield and RJ 45 cable. I am using Xampp(<a href="https://www.apachefriends.org/index.html" rel="nofollow">https://www.apachefriends.org/index.html</a>) database running on my PC. I have created a table(temp) in this database(temp_database). I have saved php files in my computer at C:xampp/htdocs/temp_database. I have hooked up Ethernet Shield to one of internet ports in my home. After all this i don't find table getting updated by temperature values. Is there any mistake? Please guide me.Here is the source code for Arduino:</p><p>#include &quot;SPI.h&quot;</p><p>#include &quot;Ethernet.h&quot;</p><p>const int temperaturePin = A0;</p><p>byte mac[] = { 0x90, 0xA2, 0xDB, 0x0F, 0x3A, 0xDF };</p><p>byte ip[] = { 131, 247, 19, 140 }; this is the ip address for Ethernet Shield</p><p>byte gateway[] = { 131, 225, 3, 254 }; </p><p>byte subnet[] = { 255, 255, 252, 0 };</p><p>EthernetClient client ;</p><p>char server[] = &quot;www.localhost.com&quot;;</p><p>void setup() {</p><p> // Open serial communications and wait for port to open:</p><p> Serial.begin(9600);</p><p> while (!Serial) {</p><p> ; // wait for serial port to connect. Needed for Leonardo only</p><p> }</p><p> // start the Ethernet connection:</p><p> if (Ethernet.begin(mac) == 0) {</p><p> Serial.println(&quot;Failed to configure Ethernet using DHCP&quot;);</p><p> // no point in carrying on, so do nothing forevermore:</p><p> // try to congifure using IP address instead of DHCP:</p><p> Ethernet.begin(mac, ip);</p><p> }</p><p> // give the Ethernet shield a second to initialize:</p><p> delay(1000);</p><p> Serial.println(&quot;connecting...&quot;);</p><p>}</p><p>void loop()</p><p>{</p><p> if( client.connect(server, 80)) </p><p> {</p><p> float tem = getTemp();</p><p> Serial.println( tem );</p><p> client.print( &quot;GET /add.php?&quot;);</p><p> client.print(&quot;tempt1=&quot;);</p><p> client.print( tem );</p><p> client.println( &quot; HTTP/1.1&quot;);</p><p> client.println( &quot;Host: localhost&quot; );</p><p> client.println( &quot;Content-Type: application/x-www-form-urlencoded&quot; );</p><p> client.println( &quot;Connection: close&quot; );</p><p> client.println();</p><p> client.println();</p><p> client.stop();</p><p> }</p><p> delay( 5000 );</p><p>}</p><p>float getTemp() {</p><p> float voltage, V,t ;</p><p> voltage = analogRead(temperaturePin) ;</p><p> V = voltage * 0.004882814 ;</p><p> t = (V - 0.5) * 100.0;</p><p> return t;</p><p>}</p><p>Here is the conec.php file</p><p>&lt;?php</p><p>function Conection(){</p><p> if (!($link=mysql_connect(&quot;localhost&quot;,&quot;root&quot;,&quot;8282&quot;))) {</p><p> exit();</p><p> }</p><p> if (!mysql_select_db(&quot;temp_database&quot;,$link)){</p><p> exit();</p><p> }</p><p> return $link;</p><p>}</p><p>?&gt;</p><p>Here is the add.php file:</p><p>&lt;?php</p><p> include(&quot;conec.php&quot;);</p><p> $link=Conection();</p><p>$Sql=&quot;INSERT INTO 'temp'('temp1') VALUE ('&quot;.$_GET[&quot;temp1&quot;].&quot;')&quot;; </p><p> mysql_query($Sql,$link);</p><p> header(&quot;Location: insertareg.php&quot;);</p><p>?&gt;</p><p>Here is the insertareg.php file:</p><p>&lt;html&gt;</p><p>&lt;head&gt;</p><p> &lt;title&gt;Data of Sensor&lt;/title&gt;</p><p>&lt;/head&gt;</p><p>&lt;body&gt;</p><p>&lt;h1&gt;Data from the temperature sensor&lt;/h1&gt;</p><p>&lt;form action=&quot;add.php&quot; method=&quot;get&quot;&gt;</p><p>&lt;TABLE&gt;</p><p>&lt;tr&gt;</p><p> &lt;td&gt;Temperature &lt;/td&gt;</p><p> &lt;td&gt;&lt;input type=&quot;text&quot; name=&quot;temp1&quot; size=&quot;20&quot; maxlength=&quot;30&quot;&gt;&lt;/td&gt;</p><p>&lt;/tr&gt;</p><p>&lt;/TABLE&gt;</p><p>&lt;input type=&quot;submit&quot; name=&quot;accion&quot; value=&quot;Grabar&quot;&gt;</p><p>&lt;/FORM&gt;</p><p>&lt;hr&gt;</p><p>&lt;?php</p><p> include(&quot;conec.php&quot;);</p><p> $link=Conection();</p><p> $result=mysql_query(&quot;select * from temp order by id desc&quot;,$link);</p><p>?&gt;</p><p>&lt;table border=&quot;1&quot; cellspacing=&quot;1&quot; cellpadding=&quot;1&quot;&gt;</p><p> &lt;tr&gt;</p><p> &lt;td&gt;&nbsp;Temperature &nbsp;&lt;/td&gt;</p><p> &lt;/tr&gt;</p><p>&lt;?php </p><p> while($row = mysql_fetch_array($result)) {</p><p>printf(&quot;&lt;tr&gt;&lt;td&gt; &nbsp;%s &lt;/td&gt;&lt;/tr&gt;&quot;, $row[&quot;temp1&quot;]);</p><p> }</p><p> mysql_free_result($result);</p><p>?&gt;</p><p>&lt;/table&gt;</p><p>&lt;/body&gt;</p><p>&lt;/html&gt;</p>
<p>Hi! I'm having an error in instareg.php It says </p><p><b>Warning</b>: mysql_select_db() expects parameter 2 to be resource, object given in <b>C:\xampp\htdocs\WEB2\php_files\conec.php</b> on line <b>9</b></p><p>Can\'t use sensordata :</p><p>what should I do in here? anyone help?</p>
<p>Hi! What will I write in this? Can you provide an example? </p><p>if (!($link=mysql_connect(&quot;your_ipserver&quot;,&quot;your_user&quot;,&quot;your_pass&quot;)))</p>
<p>Hi! very nice tutorial. thanks!</p><p>is there any Ethernet version?</p>
<p>Hi! Nice tutorial!</p><p><br>I have a question</p><p>Where specifically are suppose to be the add.php, conec.php, insertareg.php???</p><p>Thanks for your time! :)</p>
<p>Hi ! These files must be hosted on your serve to be consulted for the database.<br></p><p>Much success and regards !<br>Camilo</p>

About This Instructable

273,585views

280favorites

License:

More by camilo.n1012:Control Access of Arduino YÚN with MySQL, PHP5 and Python Access control with Arduino + Keypad 4x4 + Servo (UPDATE) Save data of temperature and humidity on MySQL with Arduino Uno and Wifly 
Add instructable to: