This is a trackside cabinet and hall effect sensor holder to help automate a Garden Railway.
The sensor fits standard 45mm Gscale track.
The electronics is a NodeMCU, which fits in the cabinet, and has a HALL sensor fiitted in the center of the track. When a loco with a suitable magnet passes over the sensor, it sends a signal to the railway controller to indicate that the line is occupied.
I have used a hall sensor as it should be reliable, although it will need good sealing from rain etc. My previous sensors were current sensing which was great, but my Tram does not take current from the track, so is not able to be seen by this method. By changing to magnetic sensing, all my locos can now work together. I have used 25mm circular magnets mounted on the locos with epoxy, but other magnets will work. Be sure to have the hall sensors all in the same orientation, and that all the magnets are correctly oriented to activate the sensors.
The NodeMCU consumes about 10mA when running so it can be powered from batteries. My code for the ESP8266 allows for up to 8 I/O which can be hall sensors, or outputs such as servos or PWM or on/off for lights, signals etc. Using Wireless allows easy movement of the hardware, but for ultimate reliability, you should use wired sensors, and there are plenty of commercial and DIY alternatives to my NodeMCU powered system presented here. When an IO is set as Input, it also activates an internal pull up, so the simplest "circuit" is just the NodeMCU plus a Battery and a "3144" Hall effect sensor.
To drive a servo, for example, for points, the i/o port is set to "servo" and directly coupled to the servo, the output is 3.3V, but most servos seem to accept this. The Servo power must be 5V, and a separate power supply for this is recommended. I simply used 4AA batteries to power the servo and NodeMCU for my tests.
If you want to try it, the current (and very experimental) code for the NodeMCU is in https://github.com/dagnall53/RocNetNodeAutoConnect, but please check to see if there is an update, as the MQTT broker search I have implemented is crude and I plan to update this soon. You will need a PC running RocRail (http://wiki.rocrail.net/doku.php) , set to use a "RocNet" Controller with the MQTT interface, and a MQTT broker, such as Mosquitto to accept and pass the NodeMCU signals back and forwards to RocRail.
Here is a Video of it working with my tram, and two sensors all connected with NodeMCU interfaces.