I am trying to build a webpage to control a radio antenna. I made a webpage that gives poor results due to latency, failing to send data until re-contacted, and other problems.
For tuning I need to control a stepper motor in increments and get a display of the present position count. I also want to control a rotor with simple forward/off/ reverse for the motor and get the direction from an electronic compass. I believe that a websocket will solve the problems I have.
It would seem to me that the essentials of what I need are encompassed in Build Web Servers projects 3.1 (Server sent events) and 2.5 (Control Multiple Outputs), however the description of the SSE on page 344 clearly says that there is no client input after initialization. Is this because bi directional communication is not included in the project, or is there a design limitation within the scope of the library files that are used? I am inclined to use an event listener that looks for both changes from client and from the local devices and responds appropriately.
I need the advice of someone wiser to tell me if I am thinking wrong and to make recommendations.
Hi.
It’s not a limitation of the project. It’s how server-sent events work. Events are sent to the client, but the client doesn’t communicate with the server.
For realtime bidirectional communication the best method is websockets.
I hope I answered your question.
Let me know if you have more questions.
Regards,
Sara
thank you Sara,
Your answer steers me toward a solution like section 2.3 – Control Outputs. I will try using a group of button switches to initiate the stepper driver ( analogous to the slider movement changing the duty cycle) and initiate the event to send the (motor step counter analogous to the slider postition ) on the the return from the driver function. Does this sound like something that could work?
Hi.
Yes. It seems it can work.
You can also take a look at this project that might be of your interest: https://randomnerdtutorials.com/stepper-motor-esp32-websocket/
I hope this helps.
Regards,
Sara
Hi Sara, Thank you for that example. My problem is in understanding the method of getting feedback information as well as having control.
I would like to know if what I am trying to do is possible because I don’t see examples anywhere of the type of control/feedback I want.
e.g. press button – motor moves potentiometer – potentiometer voltage is displayed, potentiometer is moved manually or by other webpage client and voltage display is updated.
In general what I am trying to do is remotely control a stepper motor by selecting buttons on a webpage and have the number of steps displayed on the webpage. I also want to remotely control a motor that operates a device and have the resulting effect from a separate input displayed on the webpage.
Specifically I am trying to rotate the tuning capacitor on a radio antenna which is located at the ESP8266/ESP32 and have the number position of the capacitor ( number of steps from reference point) displayed and also rotate the antenna direction from buttons ( forward – off – reverse }and have a display on the webpage of the reading of a magnetic compass, which rotates with the antenna.
The webpage would have buttons to increment by preset number of steps, a display of the number of steps from a reference buttons to start stop and reverse a rotator motor; and a display of the compass position.
Hi
Yes. All of that is possible using websocket.
With websocket control you can send data from the ESP32 to the web page, and from the web page to the ESP32.
I think that once you understand how it works, you can implement it in your project.
Can you be a little more specific about which steps you’re struggling with?
Are you able to control the outputs using websockets? Then, you can implement that to control the motors.
Can you send info from the webpage to the ESP32 via websocket? Is this the section that you’re having issues with?
Regards,
Sara