How to send a data from arduino uno to a webpage through esp8266 wifi module

0 votes

I am designing an rfid attendance system with arduino uno, esp8266-01 wifi module, and a rfid reader. The task is to read a rfid card and to send its unique id number to a webpage (coded in php) which stores the data in a database. We sent at commands to the module from arduino ide serial monitor through a uno board. We used Serial_ophttp POST method first to send the read rfid number to the webpage. As that attempt was a failure we tried using GET method. But neither of those methods worked.

    <?php
    error_reporting(E_ALL ^ E_DEPRECATED);
    $dbhost = 'localhost';
    $dbuser = 'root';
    $dbpass = '';
    $conn = mysql_connect($dbhost, $dbuser, $dbpass);
    if(! $conn ) {
    die('Could not connect: ' . mysql_error());
    }
    $Data=$_GET['Data'];
    //$Data='Data test';
    echo "Data is :" . $Data;
    $sql = "INSERT INTO test_tab (Data) VALUES ('$Data')";
    mysql_select_db('robot');
    $retval = mysql_query( $sql, $conn );
    if(! $retval ) {
    die('Could not enter data: ' . mysql_error());
    }   
    echo "Entered data successfully\n";
    mysql_close($conn);
    ?>
Aug 9, 2018 in IoT (Internet of Things) by Matt
• 2,270 points
3,680 views

1 answer to this question.

0 votes

You are missing a few \r\n and the length you are giving to your AT+CIPSEND is incorrect.

Try sending this instead:

AT+CIPSEND=43\r\n
GET /test.php?Data=2\r\nHost:192.168.1.13\r\n\r\n

To send \r\n just hit Enter. Make sure that "Both NL & CR" is selected in your serial monitor. At the end, yes you hit Enter twice.

Here I am sending the value 2.

Here how I get the 43 length: You take the size of your GET (we have 49) and you subtract 1 for each \r or \n. Because they are just one character. So we have 49 - 6 = 43.

Please, make sure to try to send a value directly from the URL to verify that your PHP script is working fine. Fix any possible error before trying to send data through ESP8266.

Side Note: It is not recommended to use the API mysql, as it is deprecated and removed from new versions of php. See (http://php.net/manual/en/mysqlinfo.api.choosing.php)

answered Aug 9, 2018 by anonymous2
• 4,240 points

Related Questions In IoT (Internet of Things)

0 votes
1 answer

How to use the data I receive from Azure IoT Hub?

The payload you receive will be a ...READ MORE

answered Aug 1, 2018 in IoT (Internet of Things) by DataKing99
• 8,250 points
1,816 views
0 votes
1 answer

Transfer Data from Arduino Board to SQL Server

If you want to send it to ...READ MORE

answered Aug 29, 2018 in IoT (Internet of Things) by anonymous2
• 4,240 points
4,932 views
0 votes
1 answer

How to detect presence of a device in a WiFi network?

Finding the mac-address would probably work. Basically, ...READ MORE

answered Nov 16, 2018 in IoT (Internet of Things) by Shubham
• 13,490 points
3,370 views
0 votes
1 answer

How to prevent an application from publishing to a topic?

Devices and applications operate in a topic ...READ MORE

answered Jan 18, 2019 in IoT (Internet of Things) by Shubham
• 13,490 points
732 views
0 votes
1 answer

Using ESP8266 for controlling through Arduino

Please explain better your problem. In Arduino-Esp8266 String ...READ MORE

answered Sep 11, 2018 in IoT (Internet of Things) by anonymous2
• 4,240 points
832 views
0 votes
1 answer
0 votes
1 answer

MQTT on ESP8266 with NodeMCU - problems with publishing

Perhaps this was solved by more recent ...READ MORE

answered Aug 13, 2018 in IoT (Internet of Things) by anonymous2
• 4,240 points
2,061 views
0 votes
1 answer

MQTT protocol connection error

Ok so you need two libraries to ...READ MORE

answered Jul 6, 2018 in IoT (Internet of Things) by anonymous2
• 4,240 points

reshown Jul 6, 2018 by Vardhan 3,097 views
0 votes
1 answer

Send data from cloud to aws iot thing

Your solution is not recommend because there ...READ MORE

answered Aug 2, 2018 in IoT (Internet of Things) by anonymous2
• 4,240 points
1,412 views
0 votes
1 answer

How to read data from MQTT in Eclipse Paho?

You don't read data from a MQTT ...READ MORE

answered Aug 9, 2018 in IoT (Internet of Things) by anonymous2
• 4,240 points
954 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP