GUIDE IS ONLY FOR WINDOWS
This content is not my own. It was based on my research made on this topic. So I just share how things done in-order to achieve this.Not any sample code, Because I copied everything.
- Install XAMPP, open it’s control panel and start apache and mysql. and click admin button, and goto phpmyadmin and create this your relavent database to store the data and create the corresponding tables.
- Install Python 2.7, and install “pyserial“, “MYSQLdb” libraries.
- Install “pyserial“, you can download it from https://pypi.python.org/pypi/pyserial/2.7#downloads. Download the “.exe” file and just run it.
- Install “MYSQLdb“, you can download it from https://pypi.python.org/pypi/MySQL-python/1.2.5#downloads. Download the “.exe” file and just run it
- Then create the require python program to write to database. for this you need to add two statements “import serial” and “import MysqlDb”.
- Install Arduino, and Write the code You want to operate. and to read values form sensor , print the data using “Serial.Println(readData);” this will acquired by the relevant python file.
In some cases if mysqlDb is not figured out by the python include the following line.It is because of two reasons, any other installation of python related products such as anaconda etc, or you tried the stuff using pip installer(for this you may also have to set path variable) .
import sys sys.path.insert(0, u'/…/…/…/python2.7/site-packages')
- https://github.com/surendharreddy/Arduino-MySQL ( this is not my code, I actually referred this code for my project, hope this will help you)