Menu

ESP8266 Part2

BadBeef67
Attachments
Board.JPG (13444 bytes)
board_and_reeds.png (81936 bytes)
board_cut.png (149896 bytes)
complete.png (137375 bytes)
n48mag.png (22752 bytes)
reed_soldered.png (146216 bytes)
reed_wiring.png (237591 bytes)
reedswitch.JPG (3792 bytes)

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.

  1. Hardware - I went onto that big online retailer that ships in two days and found some Reed Switches, Soldering Board, and some Magnets.

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.
Reedsw

The solder board was just something cheap and random that would work. Vktech 5pcs 6x8cm Double-Side Prototype PCB Universal Printed Circuit Board.
Solder Board
Solder board and Reed switches

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...
Neodymium N48 Magnets

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

  2. 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...

  3. 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...

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

  5. 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);
  1. Once the scripts are loaded, you are now finished and have a working transponder. Check out this video that I whipped up one handed! I suggest when you load the scripts that you stick with a high timer on the init.lua until your certain that everything is working.

https://youtu.be/RX9T6FNG6qg

UPDATE!!! -- [ESP8266 Part3] -- In vehicle power! No additional battery required.
Enjoy!


Related

Wiki: ESP8266 Part3
Wiki: ESP8266
Wiki: Home