Part 2
We left off with a ESP8266 sending its ChipID every 3 seconds to our server with LapTackerTK running. This is great but now we will complete the build of the transponder so the ESP8266 will send that ID when it has sensed that the car has crossed a magnetic strip.
I tried to get reed switches that were as sensitive as possible. I ended up with: Amico 10 Pcs MKA-10110 10-15AT Magnetic Sensor N/O SPST Contact Reed Switches. These seem to be working well so far.
The solder board was just something cheap and random that would work. Vktech 5pcs 6x8cm Double-Side Prototype PCB Universal Printed Circuit Board.

I needed a good strong magnet to trigger the reed switch. 6 Neodymium Magnets 1 x 1/4 x 1/4 inch Bar N48. These seem to work really well. If we build a raised track we can inlay these into the plywood. I've seen the flexible magnetic strips but I don't know if those will work. Testing needed...

I broke the PCB board with a utility knife and some pliers. Then carefully bent the reed leads to slip into the holes.

Solder the reed switch and extend some wires. I'm not getting cute here, just quick and dirty. One end of the leads should connect to your GND on the ESP8266. The other, to GPIO0. I soldered from the top of the unit to keep the pins usable for flashing etc...

Connect the other end of the cables to the ESP8266. Any electrical engineers out there, Avert your eyes, I'm not using any 'pull up resisters'. I'm keeping it simple...

Complete!?... Hold you horses there cowboy.

The first post was a proof of concept for the ESP8266. The Lua code on the ESP8266 would run every 3 seconds and send the ChipID to the server. Now the code needs to read a GPIO pin and see if its high or low. The pin I set to read is GIPO0, which is usually pulled high. When the reed switch passes over the magnetic field the pin is pulled to ground and is read as low. The init.lua and sendid.lua scripts both need to change in order to make this happen. Here is the new code
init.lua - Change the time from 3000ms to 25ms. Once I get this transponder in a car and get some laps under it this value might change. Is working though at the moment.
init.lua:
tmr.alarm(0,25,1,function() dofile('sendid.lua') end)
sendid.lua - The GPIO0 ping is pin 3. When the pin is read as Low, the chipID will be sent. The pin is set to high in code if its not physically pulled low by the reed switch. This is essential as the ESP8266 remembers what the pin setting is, regardless whether you do this in code, or physically pull the pin High or Low.
sendid.lua:
function check_pin(pin)
pinValue = gpio.read(pin);
id = node.chipid()
if pinValue == 0 then
conn=net.createConnection(net.TCP, 0);
conn:on("receive", function(conn, payload) print(payload) end);
conn:connect(65000,'192.168.1.254');
conn:send(id);
conn:send("\r");
gpio.write(3, gpio.HIGH)
else
gpio.write(3, gpio.HIGH)
end;
end;
gpio.mode(3, gpio.INPUT);
check_pin(3);
UPDATE!!! -- [ESP8266 Part3] -- In vehicle power! No additional battery required.
Enjoy!