• Skip to main content
  • Skip to primary sidebar

RNTLab.com

The Ultimate Shortcut to Learn Electronics and Programming with Open Source Hardware and Software

  • Courses
  • Forum
    • Forum
    • Ask Question
  • Shop
  • Account
  • Blog
  • Login

Using GET Request to a local server (XAMPP) to insert values in DataBase (phpMyAdmin) using .php script

Q&A Forum › Category: ESP32 › Using GET Request to a local server (XAMPP) to insert values in DataBase (phpMyAdmin) using .php script
0 Vote Up Vote Down
Pedro Silva asked 3 years ago

I’m doing a simple projecto where the goal is to read values from a sensor em send them to a MySQL database (phpMyAdmin) using Wifi.

I base myself on the project Send Sensor Readings via Email (pag. 192 of the manual). But instead of a POST request I’m trying to use a GET request.

To do so, i’m using a ESP32-WROOME-32 board and a XAMPP local server on my machine.

I have a .php file responsible for receive the GET request, establish the connection to the DB and insert the values on the DB.

save_data_GET.php
https://pastebin.com/C062F86c

The server is working fine. If I type < http://localhost:8090/esp32/save_data_GET.php?sensor1=6 >  The value 6 is inserted correctly in my DataBase.

The problem came when i try to do the GET request from the ESP32

boot.py:
https://pastebin.com/RvY1vq1N
It always gives me the following error:
#########################################
Connection successful
(‘10.12.81.65’, ‘255.255.255.0’, ‘10.12.81.254’, ‘10.12.68.200’)
Traceback (most recent call last):
File “boot.py”, line 18, in <module>
File “urequests.py”, line 108, in get
File “urequests.py”, line 58, in request
OSError: [Errno 104] ECONNRESET
#########################################
Complete output:

https://pastebin.com/fU4eyzrM

Can anyone help me with this?

This should heve been a simple mission, but i’ve been stuck with it for over a week…

———————————————————————————————————————–
And by the way

Awsome job guys!

I think no one have soo much content (high quality) on this matter of MicroPython.

You definitely get me fired up to learn more MicroPython.
Thank you so much!

3 Answers
1 Vote Up Vote Down
Best Answer
Rui Santos Staff answered 3 years ago

Hello Pedro, I hope you are doing well and I apologize for taking so long to get back to you, but I’ve been with very limited Internet for the last couple of days. I’m finally catching up and I’ll try to give you a faster response.

The error should be very easy to solve:

response = urequests.get("http://YOUR_IP_ADDRESS_PHP_SERVER:8090/esp32/save_data_GET.php?sensor1=6")

localhost only works if your using the device with the same IP address, you must use the IP address when sending an HTTP request.

Let me know if that solves your problem. Thanks for your patience!

0 Vote Up Vote Down
Pedro Silva answered 3 years ago

Hi Rui,
What a mistake…It’s SOLVED! 🙂
Thank you so much

0 Vote Up Vote Down
Rui Santos Staff answered 3 years ago

I’m glad it worked!
Regards,
Rui

Primary Sidebar

Login to Ask or Answer Questions

This Forum is private and it’s only available for members enrolled in our Courses.

Login »

Latest Course Updates

  • [eBook Updated] SMART HOME with RPi, ESP32, and ESP8266 (version 1.2) March 8, 2023
  • [eBook Updated] ESP32-CAM Projects (version 1.3) January 7, 2023

You must be logged in to view this content.

Contact Support - Refunds - Privacy - Terms - MakerAdvisor.com - Member Login

Copyright © 2013-2023 · RandomNerdTutorials.com · All Rights Reserved

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.