A simple way to send data from an Arduino and save it to a database (MySQL) over WiFi.
Arduino (Uno or similar)
Arduino WiFi Shield
USB cable for Arduino
- Create MySQL Database
- Create MySQL User
- Give newly created MySQL User access to your newly created MySQL Database
- Give newly created MySQL User full privileges to your newly created MySQL Database
- Create a table for your database
- Add 2 columns to your table:
yourdata,timestamp - For timestamp column, change the
typetoDATETIMEand the index toPRIMARY
- Download
insert_mysql.php - Edit the
$username,$password,$database, and$tablenameto match your setup - Upload
insert_mysql.phpto your web-host (remember this URL for later)
- Download arduino_post/arduino_post.ino
- Edit
yournetwork(wireless network),yourpassword(wireless password) to connect to your router - Edit www.yourdomain.com (for
char server[]) to the domain you are hosting insert_mysql.php (not the full path to the file) - Edit the POST url to match the path to
insert_mysql.php - Edit the Host: www.yourdomain.com to the domain you are hosting
insert_mysql.php(not the full path to the file) - Connect the Arduino WiFi shield to your Arduino
- Connect your Arduino to your computer using your USB cable
- Upload your sketch to your Arduino
- You should now be POSTing data from your Arduino to your MySQL database. Yippee!
Dhaval Karwa
Ben Salinas
Tom Igoe's WiFiWebClientRepeating sketch