I placed the nodeMCU into my locomotive. So the heart (power buffer), the legs (motor amplifier) and the brain (microcontroller) is now imbedded.
The nodeMCU – containing the ESP8266 microcontroller with WIFI functionality – is acting as webserver, that is getting connected to my private network. I stored all files such as HTML, CSS, javascript and icon and the SPIFFS area. While downloading the website a websocket connection is getting established from the browser to the controller, which is much faster than using the AJAX-technology. Using the slider, it is possible to control the speed of my locomotive. Using the “FWD” and “BWD” buttons, it is possible to change the direction. Controlling the lights will be next.
For all, who are interrested in the technology: I used the PWM functionality to control the speed. The websocket connection is not only working one way. As a usual webserver, it is possible to connect from several devices to the website. So it is possbile to control the locomotive from several devices in parallel. So I connected to the ESP8266 with my mobile, tablet and laptop in parallel. As soon as I move the speed slider on one of my devices, the slider on all other devices moves as well. Same for the state of the buttons (turned “ON” or “OFF”).