I am not sure if this is the correct forum for my question. I am trying to control a stepper motor from an AP on my android phone via WiFi. I am using Arduino IDE 1.8.19 and MIT APP Inventor in the project. I do not expect help on the Android AP from this forum, but included it only for reference. I am using a Windows PC.
I have followed several tutorials on YouTube to turn LED's on and off, but most of them seem to create a web-page inside the sketch, connect using a browser, and redraw it to make changes. The figure below explains what I want to accomplish.
There are two parts, the stepper motor controller using an ESP8266, and the Android AP on my cell phone. I want both connected to my home network which has internet access. I only want the ESP8266 to be controlled via my local network, not from the internet (similar to not sharing a printer for example).
I have created global variables in both devices to determine motor speed for example. In the ESP8266 motor speed is determined by "int Speed". When commanded to move forward or reverse, the motor moves for a fixed number of steps and then stops. I want to send a status message such as "Forward" or "Reverse" from the ESP8266 to the Anddroid AP to be displayed in a label.
The variable "int speed" can be increased or decreased in the Android AP by a button press, stored in a database, and saved as a variable. I then want to send the new speed to the ESP8266, by simply changing the value of its speed variable. The new speed variable is stored in a database and retrieved when the Android AP initializes.
I also want to control the direction and starting time of the stepper motor from the Android AP by a button click sending a command handled by the appropriate method in the ESP8266.
I have the ESP8266 controlling the stepper motor.
I have the Android AP built and it increases or decreases the speed, displays the value, stores the new value, and retrieves it on initialization. I can configure it for any IP that is required, and I can send HTML text to that IP (not sure just what to send?).
Where I am confused is the WiFi interface between the two. I don't know if I need to program the ESP8266 as an Access Point, a Client, a Station, or just what. I do have other problems.
I have been able to create an Access Point and connect to it via a browser using the ESP8266. I can turn LED's on and off with button clicks. Where I am having problems is getting the ESP8266 to connect to my home network. I am confused about the "Network Credentials" I am supposed to enter. For an Access Point I enter whatever name I want the Access point to have, and whatever password I want to connect to it. I have tried to use the IDE examples for Client, Web Server, WebSocket, ESP8266_Async_Web_Server, and PostHttpClient all with the same result. I have also downloaded many great examples from Rui Santos (Random Nerd Tutorials), same result.
For ssid I enter the name of my home network exactly as it appears when in my network and sharing center:
I have tried both HOME-8DC2-2.4 and HOME-8DC2-2.4 3.
For password I enter the password I use when I connect to this network from my PC. The sketch compiles and loads into the ESP8266, it tries to connect, but always fails to connect.
For example I installed the example ESP8266HTTPClient/PostHttpClient sketch, changed the ssid and password, and uploaded to the ESP8266 Wemos D1 R2 board. My serial monitor displays:
Any help will be greatly appreciated.