I've been trying to send some scanned values from my barcode scanner to my apache webserver. I can't for the life of me figure out how to do this with the Arduino IDE.
Basically the barcode scanner needs to scan a barcode, and then send that barcode to the server. The website I have created for this is a website with a submit button and a text field for the barcode. The goal is for me to scan a value, and then program (using Arduino IDE) some code which can submit that barcode into the text field of my website and press the submit button. I am using the post form to submit the barcodes to the database.
I have tried looking at tutorials for HTTP post requests but I couldn't get any of them to work. Any help is therefore greatly appreciated.
Juraj:
you do not call a web page or fill something there. you need to call the web server with a HTTP request the same way the page does when you submit
How do I find the HTTP request of the submit button?
You have created a browser page hosted on an Apache server. That browser page has a field for the barcode number and a submit button. Is that right ?
Does that work in that if you enter a bar code number in the field and press submit, that data gets into the database ?
If that works, then you have to issue an HTTP GET request on your Arduino of the format
"GET /barCodeSave.php?barCodeNumber=0123456789 HTTP/1.1"
which would be more or less what your existing web pages does in the background when you click submit.
Look up "ESP8266 Arduino Web Client" to find examples.
6v6gt:
You have created a browser page hosted on an Apache server. That browser page has a field for the barcode number and a submit button. Is that right ?
Does that work in that if you enter a bar code number in the field and press submit, that data gets into the database ?
If that works, then you have to issue an HTTP GET request on your Arduino of the format
"GET /barCodeSave.php?barCodeNumber=0123456789 HTTP/1.1"
which would be more or less what your existing web pages does in the background when you click submit.
Look up "ESP8266 Arduino Web Client" to find examples.
Well. When I press the button it issues a POST request and not a GET request. Is it possible to issue a POST request on Arduino?
int httpCode = http.POST("Message from ESP8266"); //Send the request
to match your environment say:
int httpCode = http.POST("barcode=12345689&submit=Scan");
If that does not help, post the full code you are attempting to use.
Sorry for the late response. Thank you very much for you help, it works! I now have another problem. Is there any way I can make the esp8266 read some text from the website, and then store that text in a variable or print it in the serial monitor?