Save data of temperature and humidity on MySQL with Arduino Uno and Wifly

Arduino Save data of temperature and humidity (1)

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.Arduino Save data of temperature and humidity (1)

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)

WiFly Shield ($89.95)

Grove – Moisture sensor ($4.99)

Six Jumper Wires ($4.50)

DS18B20 Temperature Sensor with metal tip ($10.59)

If only  need, One protoboar ($9.58)


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

Step 2: Setting the temperature sensor and humidity

DS18B20 sensor is connected as follows. The position pin of the sensor Grove

Step 3: Connecting all in Arduino

Now, we will connect the two sensors on the Arduino shield Wifly:

-For the temperature sensor, the pin order is: GND-VCC in 5v power – SIG in digital pin 3.

-For the Moisture sensor, the pin order is: GND – 3.3V VCC in power – SIG in the analog pin 0.

Step 4: Preparing the database Mysql

In the query of NySQL you need put this code:———————————————————————
CREATE TABLE `your_database`.`tempmoi` (
`temp1` VARCHAR( 255 ) NOT NULL ,
`moi1` VARCHAR( 255 ) NOT NULL ,
PRIMARY KEY ( `id` )
) ENGINE = MYISAM ;Schematic Arduino Save data of temperature and humidity (1)

Step 5: Preparing for PHP files

You make three files:

In this file will connect to our database


function Conection(){
if (!($link=mysql_connect(“your_ipserver”,”your_user”,”your_pass”)))  {
if (!mysql_select_db(“your_database”,$link)){
return $link;

This file allows us to send the data to our table “tempmoi” located in our database, where “temp1” is equivalent to the temperature data and “moi1″ is equivalent to the humidity data. This file also allows us to Arduino send data to the base.

Step 6: Codes for the Arduino

To use this code requires the following libraries:

– OneWire librarie

– Wifly librarie

Well, i will briefly explain the code for the arduino, use the client that offers us the shield Wifly to send the data entering the digital pin 3 and pin analogue 0, these are sent as a sentences to file “agregar.php” for this we use the client.print.

I must remember to modify the data written in bold in the code:


#ifndef __CREDENTIALS_H__
#define __CREDENTIALS_H__
char passphrase[] = “pass_WIFI“; //password Wi-Fi
char ssid[] = “name_WIFI“; //name Wi-Fi

Read more: Save data of temperature and humidity on MySQL with Arduino Uno and Wifly

Leave a Comment

Your email address will not be published. Required fields are marked *