My code can be compiled either as a "Mobile" node, for a Loco, or as a Static" node for use for track sensors and points etc.
The Loco version can use either a standard RC controller to control the motor or a PWM (L293 type) interface. The Loco has front and back lights and sound effects courtesy of Earle Philhowers ESP audio codelibrary.
This is a video https://www.youtube.com/watch?v=Pg5r6MZDhww of it running (using Rocrail web interface on the tablet).
The 8 I/O on the (static) esp can all be selected as either inputs or outputs using the Rocnet interface in Rocrail. I use one ESP per "station" on a garden railway, which has two sensors per station and two points, and two controlled lights outputs for the station lamps. I use the NodeMCU motor shield as it provides a simple way to connect sensors and servos. (But it does need modification to get 5V to the servos).
On the Mobile version, there are less I/O available as some are used for audio and others for the motor controls and lights.
The code is available on github: https://github.com/dagnall53/ESPMQTTRocnetSound.
Once uploaded to an ESP (nodeMCU or Wemos) the code can be updated over wifi, and the sound effects can be changed or updated using FTP over WiFi.
(336.82 KiB) Downloaded 231 times