Arduino, Temp, Humidity, WiFi, MySQL and Highcharts




Introduction: Arduino, Temp, Humidity, WiFi, MySQL and Highcharts

This is my first Instructable and while it works as is, it is a prototype/proof of concept only.

This solution is one of a number that are required to monitor an indoor pool installation to allow an engineer to offer suggestions as to how we can save on our energy usage. The overall project is being undertaken by a Year 11 Design and Technology class.

Please note the solution is a remix of other builds and ideas.

Specifically, Tim Kang ( and Marco Schwartz (

If you just want to fiddle with the database and highcharts, go straight to Step 3.

If you just want to build the sensor, Steps 1 and 2


What I used:

1 Arduino UNO

(1 CC3000 WiFi breakout ( and 1 Arduino prototype board


1 CC3000 WiFi shield with ufl connector for ext antenna (

1 antenna - I used

1 adapter - I used

1 SHT15 Temp, Humidity sensor - I used

1 case - I used

rainbow cable, solder and iron, hotglue gun, stacker and break away pins

Wireless compatible computer

Arduino software

MAMP software (WAMP or LAMP depending on your OS of choice)

a text editor - TextWrangler is an excellent choice for the mac

Browser of your choice.

Step 1: Building the Sensor

Mount the Arduino UNO in the case.

Solder the CC3000 WiFi breakout onto the prototype board (note that I had to shorten the break away pins as the whole unit needs to be able to fit into the case)

Mount the sensor into or onto the case (I used hot glue and have mounted the sensor so that it is less likely to become too wet in the indoor pool environment - time will tell if this is the best orientation but it will be easy to remount if required. The SHT15 has a heater element so I guess if the humidity readings are affected by condensation, I should be able to dry the sensor out.)

Mount the antenna (I used an internal tooth lock washer on the underside of the antenna mount to stop the user from turning the fitting when screwing the antenna onto the mount - this is not in the photo)

If you used the adafruit case, break off the covers, clean them up with a utility knife and pop them into position - I hot glued them for greater security.

Step 2: Download the Sketch

download the sketch:

Open in the Arduino IDE, fill in your own information for the wifi and web server.

Upload the sketch to your arduino, open the serial browser, set it to 115200 baud and watch your solution generate the temp and humidity.

Step 3: Download and Install MAMP

download and install MAMP:

WARNING - MAMP 3, non PRO version, ships with the ability to switch between PHP 5.1.6 and 5.5.10 only.

Neither of these work with highcharts. I selected 5.1.6 via the preferences pane then renamed the 5.3.28 folder to 5.1.6 - this is a kludge and I need to find a better solution.

Locate the htdocs folder in Applications, MAMP.

download and copy the sht15_cc3000_mysql folder into the htdocs folder.

Step 4: Create Your MySQL Database

Open a terminal window and copy this text at the prompt:

/Applications/MAMP/Library/bin/mysql -uroot -p <

Now, drag the energy_project.sql file (see the photo above) located in the sht15_cc3000_mysql folder in htdocs over the terminal window - this will paste the path (location) of the energy_project.sql file into the terminal window after the <

Now press return and type root at the password prompt.

Press return and you have created your database.

Step 5: Create the Energy_user for Your Database

In a terminal window, copy this text at the prompt:

/Applications/MAMP/Library/bin/mysql energy_project -uroot -p

Now press return and type root at the password prompt.

copy this text at the prompt and replace the your_password with a password of your choice:

GRANT all ON energy_project.* TO energy_user@localhost IDENTIFIED BY 'your_password';

Press return and you have created a database user called energy_user

type exit at the prompt.

Step 6: Edit the Sensor.php File

edit the sensor.php file in the sht15_cc3000_mysql folder in htdocs.

This is the file that is called by your wifi sensor and it places the temp and humidity data into the database.

You have to set the following line so that the password you have specified for the energy_user is the same:

$result = mysql_connect("localhost", "energy_user", "your_password");

Step 7: Edit the Data.php File

edit the data.php file in the sht15_cc3000_mysql folder in htdocs.

This is the file organises the data in the database into a format that highcharts can understand.

You have to set the following line so that the password you have specified for the energy_user is the same:

$con = mysql_connect("localhost","energy_user", "your_password");

Step 8: Check Out Your Handywork!

If you have created the database correctly and adjusted your_password, you should now be able to test data.php

Make sure that MAMP has been launched

In the browser of your choice on the machine running MAMP, paste in the following URL:


You should see my test data.

Now point your browser to:

Point your browser to the following URL:


Please remember this is a work in progress - it was strung together to allow my year 11 class to meet their next milestone.



    • Water Contest

      Water Contest
    • Creative Misuse Contest

      Creative Misuse Contest
    • Metalworking Contest

      Metalworking Contest

    19 Discussions

    I got following message in arduino serial interface

    mysql_native_password ˇñ 08s01got packets out of order

    2 replies

    what's the reason for this? can u help me anyone?

    for the operating system Windows 7 using XAMPP whether there are distinguished in its programming? please help ..

    3 replies

    Disable your firewall

    I haven't tried my setup on windows using xampp but am sure that each step should be very similar.

    ok, thanks...

    before I use Wido-Open Source Node Arduino Compatible IOT, in the existing microcontroller CC3000 WiFi shield and I've tried to fit your program code but still can not.
    I think the same as you patently above but the program code does not match ..


    2 years ago

    Thanx Bro it's helped me

    Hey Tim. Thank you very much for providing this tutorial. I'm using something like this for my thesis project. I have one issue though when I compile the code for the Arduino, no header file directory. Would you know anything further on the matter?

    Arduino: 1.5.8 (Mac OS X), Board: "Arduino Uno"

    SHT15_CC3000_MySQL.ino:14:19: fatal error: SHT1x.h: No such file or directory
    compilation terminated.
    Error compiling.

    in step 2 you talk to download, but where is the link to download.


    1 reply

    Hi Tim,

    So I tried it again and it didn't work. I decided to put it on my hosting account. It seems like it's working, however I don't see any data that the arduino outputs. When I open the data.php on my website it shows the following:


    and when I open the root folder it shows the plot with no data. On the Arduino side, it says it's data sent and loops back, so it seems like it's working correctly. My guess is that it's not writing the data to the correct location? Any ideas?

    Thank again for your help,


    Hi Tim,

    Thank you for your quick response. I changed everything back to your instructions and also changed it to $con = mysql_connect("localhost","root", "root");

    I get an error saying" Could not connect: Unknown MySQL server host with some weird characters... I will try again tomorrow and redo all the steps just in case I'm missing a step. I will keep you posted.

    My end goal is to be able to have my data (300 temp sensors) to be plotted on my website and to be able to download all the data, is this possible with this method?

    Thank you so much for your help.

    Tim, let me start by saying thank you for making this page. It's great to see it's possible to do with Arduino. I followed your instructions step by step, however when I go to test my database (step 8), the webpage is blank. If I change the localhost to "localhost:8888" on step 5 and 6, than I'll get some output, however no new data from my arduino. I noticed my SQL port is 8889 and the apache is 8888... Any help would be appriciated. Thank you.

    1 reply

    Dear Mehdi

    the 'localhost' in steps 5 and 6 is the host setting for the mysql server. It has to stay as just localhost. The localhost:8888 is the web server localhost. Usually, web servers that are set up on local machines will be operating from port 80 - that is the default port that web traffic uses. Because we are using MAMP, so that the MAMP web server does not interfere with a web server that may be already operating on your machine, MAMP sets its web server port 8888.

    If you are not getting any information using the http://localhost:8888/sht15_cc3000_mysql/data.php link, please try the following:

    In data.php, change the following line:

    $con = mysql_connect("localhost","energy_user", "your_password");


    $con = mysql_connect("localhost","root", "root");

    save and test again.

    Let me know if this works.



    Steps 3 - 7 need to be completed for your external server.

    Then you need to edit the sketch lines here to point to your external server and port.


    // Local server IP, port, and repository (change with your settings !)

    uint32_t ip = cc3000.IP2U32(192,168,1,103);//your computers ip address

    int port = 8888;//your webserver port (8888 is the default for MAMP)




    How would you go about doing this with an external server?

    I have just corrected the GRANT statement. The grant needed to be on the database, not the table.