ESP-01 Captive Portal -PLUS- reachign out to .php script?

Hello group-

I have successfully created a 'captive portal' app for my ESP-01 device.

(which is great for me!.. making little wi-fi GUI's for things/apps is awesome! and neat to control things form almost any phone..etc)

Summary:

  • Captive portal = no local network needed, wi-fi deices connect directly to my ESP device.

  • HTML content is store on ESP module itself (no external SD card, although that might be nice to add later?) and server up by the module itself as well.

  • My HTML/CSS 'gui' has several links/button on the page.. then when clicked or submitted, is parsed for the form submission data, and displayed out as serial data to serial monitor (eventually serial monitor will be replace by Pro-Micro, so parse/execute the serial commands sent from the ESP module)

I am on the last leg of my Arduino parsing portion of things... but want to expand on the capabilities a bit.

Knowing my current project status (above)..

I want to (also) be able to send this data (submitted from the local, captive portal served HTML page) send this info out to some .php script.

finding a live server and the php script portion is not a concern/focus here...

The question/foucs is:

Can I be running a captive portal 'app' (code).. and also reach out to save some data to MySQL table somehow? (behind the scenes, so to speak)

Is this a difficult task to add?
Is is a lot more code to 'reach out' to some IP (or even a locally connected WAMP server via USB/serial?) to save some data with all the captive portal stuff going on?

I guess what is the most 'MINIMAL' code needed to reach out to a .php script and dump some data to it?

(sorry, I'm at work currently and can not post my latest captive portal code, but wanted to get the discussion going before I got home from work and can post it)

Any discussion is appreciated.

thanks!

You can use your ESP as a WiFi access point and client at the same time, so in theory, it would be possible to let devices connect to it, while being connected to a WiFi router, to connect to a server on that router's local network.

You can set up a HTTP server for the locally connected devices, and set up a HTTP client to send a POST request to the server.

I haven't tried this yet, however, maybe you'll have to set up some routes to make sure that the POST requests are sent over the right WiFi connection ...

OK.. so HTTP Client is my 'keyword' here for me to start searching on? (thanks)

In hindsight... I'm thinking maybe a local SD card might be a better option for 'saving' things? (ie: submitted data)

hm.. or if this device is constantly connected to a PC.. maybe some sort of way to save the submitted data via serial to a local file/DB system.

Anyways.. thanks for the chit-chat... and the suggestion!

xl97:
In hindsight... I'm thinking maybe a local SD card might be a better option for 'saving' things? (ie: submitted data)

You could use an SD card (I've managed to get my ESP hosting some files off of an SD card using the default SD library), or you could use SPIFFS, it's a small file system for the ESP, that supports reading and writing data on the onboard flash memory. It supports files and directory structures, really handy. I usually dump all my web data on there, html files, css, javascript ... even hi-res favicons.

I don't know how much flash your ESP-01 has, but if it has 1MB (like mine does), you could store up to 512KB of data, which is plenty if you're just storing some numbers. You could then download the data over WiFi.

SPIFFS!

nice!

Thanks for the suggestion. Sounds like a great solution to the problem at hand!

I dont care for the size limiting factor!.. but really its just for a proof of concept/fun project anyways. :slight_smile:

I just need to read up on how to 'save'.. and then later retrieve it.

Thanks again!