Close
0%
0%

LZRTag - Flexible DIY Lasertag

An easy to build, program, modify and use AVR and ESP based Lasertag system for everyone!

Similar projects worth following
Ever wanted to play Lasertag just ... Anywhere?
Maybe with a different game mode too, or for longer periods than those offered by arenas?
I know I wanted to - so I decided to create my own version of it!

LZRTag (and yes, I know, that's not really a good abbreviation but whatever) has been a long-running project of mine. It's actually a couple of years old, but only recently got started!

Its main motivation has always been, and will always be, to have an easily customizable, cheap to create Lasertag system whose capabilities rival those of professional sets, without adding proprietary software or complex hardware.
Based on an ATMega168P, an ESP-01 (soon to be replaced with an ESP32!), and a simple but powerful MQTT interface and Ruby-based server script, I am proud to say that I am managing just that!

The Hardware

In this regard, I fear, most people won't find my project particularly enticing.

Utilizing only a simple ATMega168 clocked at 4MHz, together with an ESP-01 is enough to perform most tasks. While the ATMega handles the "hard-side" work like flashing the built-in and external LEDs, sending and receiving IR pulses, and generating noise, the ESP is there for communication.

The interface between ESP and AVR is a simple bidirectional UART line, but will eventually be replaced with a I2C line to improve quality and make expanding the system easy.

The mainboard has been kept simple to keep things easy. With only a few passives like capacitors and oscillators, as well as a few driving components like transistors for the LEDs, and not even a voltage regulator (as the LiPo cell never quite exceeds the ESP's acceptable voltage range), it's pretty bare. The addition of a buzzer, vibration motor, and connector for a "trigger" button complete it.

Communication between sets is done via an easy but effective IR channel. A strong LED (OSRAM SFH 4346) sends out pulses at a 40kHz modulation, which are received by standard VISHAY TSOP 4840. Add a small checksum, a ID code for each set, and a small lens or other focus mechanism, and you have a surprisingly precise, long-range (about 40m in good conditions!) way for one set to hit another!

The Software

Now the software is where it gets interesting. While I tried to keep things somewhat simple, it's become a bit of a mess of C++, NodeMCU LUA and Ruby, so stick with me here for a bit.

The AVR Side

The ATMega168, controlling the core of the Lasertag Sets, was programmed in C++, using Eclipse IDE. All libraries are custom and self-created (even though that probably wasn't necessary >.<), but aside from that there isn't much magic here.

All tasks are handled in Interrupts, so the main loop is free for anyone to use, should that be necessary!

It mostly just listens for commands coming in from the ESP, and reports back events, like a detected hit or when the trigger button is pressed. 

Currently, the AVR handles the following tasks:

  • Blinking the RGB LEDs of the board in various patterns (configurable)
  • Beeping the buzzer and vibrating the haptic feedback
  • Sending out IR pulses and decoding received pulses
  • Detecting when the trigger button is pressed down.

The ESP Side

The ESP-01 is the most complex part of the module. It runs using NodeMCU, however it might eventually be switched over to a more powerful C++ code to alleviate some of the annoying limitations of the LUA language.

Using it's WiFi connection and MQTT, it connects to the lasertag server. It receives configuration of ... Basically everything, ranging from the Team and Client-ID, to how many shots per second the set can do. I'll probably write a bit more about the configuration options for the sets one day.

Aside from acting as a receiver for configuration, the ESP also handles all the logic of a client. 

It tells the AVR to shoot out in regular intervals, tracks ammunition and reloads, handles respawing the player after a specific time, and provides some other statistics like battery charge and ping of the set itself.

In theory, the ESP could even be configured to run in a sort-of stand-alone mode! Though that wouldn't allow for very dynamic or interesting games, as no tracking of scores or such are done :P

The Ruby side

The server side code of the lasertag system is written in Ruby. Utilizing my own mqtt-gem, it connects up to a Broker, using it to communicate with the lasertag sets. This is mainly to simplify hack-ability of the whole thing, as well as giving me a well-developed communication protocol with low overhead.

Once the Ruby server is started, it handles a multitude of tasks:

  • It hands out unique IDs to any connected lasertag sets. Up...
Read more »

  • App-solute progress

    Xasin10/02/2018 at 18:41 0 comments

    Whew!
    Finally, I got this lazy butt moving on something I've been wanting to have for my Lasertag project (or actually, anything that has the tiniest bit of WiFi capability) - a proper App!

    Thanks to my student helper job making me learn Qt, I recently found myself possessing that last tool I needed to make an appealing, responsive UI, without worrying about the graphics and the "how" behind it too much.
    QML is just too good in that regard.

    Enough of this though, let's have some pictures!

    Very WIP front page
    The front page - This'll hold the most important stats. Life, Ammo left, a small map, and a list of teammates and their status.
    The settings
    The slightly more developed settings page. Connection status, server IP and (later) login data, as well as a custom name and profile icon link can be entered here - all stored persistently!

    The whole thing is still in the works, but thanks to the Qt MQTT library, it was easy to integrate in the running system - it'll receive game data as quickly as the sets itself!

    As an added bonus, the "Material Style" was used to get a unified, sleek look, and some of the theme colors are adjusted live to match your current theme color. Pretty neat, huh?

    In the future I'll fine-tune the front page to be easy to read, while still holding the important information, and add other gimmicks like an enemy proximity radar, but ... That's still a while off.

  • Adding a few more bits

    Xasin09/05/2018 at 16:36 0 comments

    The lasertag MCU board, in its curent state, is powered by an AVR microcontroller, which is in control of all vital functions. It blinks the LEDs, creates the sounds and vibration patterns, and much more. To add Wi-Fi, an ESP-01 was added in the later versions, communicating via UART.

    Both are simple chips to use and program, and have always been my go-to device for projects that need a small but powerful processor, or need a little bit of Wi-Fi capability.
    Slowly though I am starting to feel like a device with more "juice" to it would provide more flexibility and more interesting features, as well as reduce some of the problems I am getting with for example the ESP<->AVR communication, the fairly slow Wi-Fi speed of the ESP-01, and the hardware limitations of the AVR.

    For this reason, over the next few weeks I will be working my way into the ESP32, programmed in C++
    If all goes well it will have enough power as well as hardware features to take over the job of both the ESP-01 AND the AVR, reducing the complexity of the main board and code!
    Additionally, it'll bring in juicy new features like Bluetooth, capacitive touch support, high-speed 16bit LED PWM, faster WiFi, and potentially even proper sound playback.

    Let's see how this goes, shall we!

View all 2 project logs

Enjoy this project?

Share

Discussions

Michael Obed wrote 09/25/2018 at 12:04 point

This looks awesome, man! Very promising!

I've implemented a Laser Tag project myself using a very similar method...I initially used an ESP8266 + Arduino IDE for the hardware side and C for the software side. It worked well, but for scalability and reliability I re-did the server side in C++ and implemented checksums and a HTTP web server. I want to do the hardware with the ESP-32 as well, as the extra power and comms are attractive...

Who knows, maybe that project will make it here too! ;)

  Are you sure? yes | no

Xasin wrote 10/02/2018 at 18:27 point

You made the server with HTTP and in C? 
Now that's kind of impressive! I had no idea how to make something like that, so I chose Ruby for my server software. I intend to stick with it though, as it is a lot more flexible than C or C++ in terms of live reloading of software - something that could come in very useful for custom servers or similar.

At least I didn't use the Arduino IDE - I prefer the cleaner, more professional environment of Eclipse (as well as the C++ autocompletion it offers <3)

  Are you sure? yes | no

HP (@banjohat) wrote 09/12/2018 at 05:23 point

This is great!

Some interresting details in your build - how uncool of visahy to call the IR receiver TSOP >_< it's not even an SMD package :P

Are you only registering hits on the gun? I would love to see a vest with targets as well!

  Are you sure? yes | no

Xasin wrote 09/13/2018 at 17:04 point

Oh, thanks for pointing out my mistake!
I accidentally called it that because the vendor I buy my parts from has their own naming scheme. Their IDs vary quite a bit from the original ones, I must have mistaken that!

Also, it's exactly the opposite - the guns don't have any built-in sensors (although adding one is trivial), and it's only the "vest piece" (or in this case a tiny strap-on shoulder sensor) that registers the hits.
Since the sensors I use have a pull-down output they're easy to connect in parallel, to have as much sensor coverage as you need.

  Are you sure? yes | no

dlhavema wrote 09/08/2018 at 05:30 point

post some code.  Super cool start man

  Are you sure? yes | no

Xasin wrote 09/08/2018 at 06:49 point

The link to the GitHub is already there. I'm still working on a bit of documentation, but it's mostly self-explanatory. 

There's also a directory with one or two example game scripts ^^

  Are you sure? yes | no

dendad51 wrote 09/07/2018 at 07:54 point

Oh, the IR camera is just to be used to sight the gun in as the "image" is invisible.

I use these sort of flashlights and have IR LEDs to put in them. Just the LED and lens is used, in a 3D printed housing.

https://www.ebay.com.au/itm/5x-CREE-Q5-LED-Zoomable-Focus-Bright-Flashlight-Torch-1200LM-Light-AA-14500/172292965071?epid=2256915909&hash=item281d7602cf:g:4r4AAOSwK8BbQ~4V

And that feeds into one of these...

https://www.ebay.com.au/itm/Clip-on-12x-Optical-Zoom-HD-Telescope-Camera-Lens-For-Universal-Mobile-Phone-JFA/253742359147?epid=730731908&hash=item3b1439226b:g:GWAAAOSwR6RaRD~E

Yes, the WT558D modules are great. But don't forget to buy a programmer too.

  Are you sure? yes | no

Cor van Essen wrote 09/07/2018 at 07:16 point

That looks cool. I made something similar with everything stuffed in a toy gun. And the receiver LED were on the gun itself. Yours looks way nicer. I used an Adafruit board to connect to my phone which would then upload to the internet.  I have a proof of concept, but then other things came along. So this is inspiration to pick it up again.
How good is your IR range? 

  Are you sure? yes | no

Xasin wrote 09/07/2018 at 07:32 point

I'm using a strong IR led, probably over driving it a bit, and it's run through a fairly small hole (0.7mm diameter) to focus it. 

That gives me about 40m of range in low light conditions, some 20m if the sun is out. 

I'm still looking for a good IR lens though. With it I could focus a much larger beam, and the range could skyrocket. How much I sadly don't know.

  Are you sure? yes | no

Nick wrote 09/09/2018 at 11:08 point

Im not sure  how well they work, but have you tried lens's for arcade light guns? https://na.suzohapp.com/products/optical_guns/96-0068-00

They can usually be bought for cheap used on ebay,, or from local arcade operators.

  Are you sure? yes | no

Xasin wrote 09/09/2018 at 11:37 point

@Nick, that lens looks fairly good, thanks for the hint! But I fear glass lenses aren't the best option for IR - some materials don't let those wavelengths through very well. It's also a bit very expensive, so I'll stick with a simple lense-less design for the time being

  Are you sure? yes | no

denys wrote 09/06/2018 at 22:35 point

This is really interesting. I've stalled a bit on my Laser Tag system that was aimed at being finished last Christmas!

Mine is built into Nerf guns and uses an Arduino Pro Mini driving the IR LED from one of those metal flashlights. The LED and lens from the flashlight is mounted in a 3D printed housing that is stuck on the end of a mobile phone telephoto lens so it shows the "picture" of the LED at quite long range. Visible LEDs are used to setting up, but an IR enabled camera will be the way to go.

Sound is from a WT588D module. Various gunshot sounds can be selected, along with an empty click, and any other sound wanted.

It may be worth looking at these for your gun.

Power is an 18650 call with a USB charger/protector board.

But I like your ESP8266 idea.

Maybe I'll get back to it so my son gets it for this Christmas ;)

  Are you sure? yes | no

Xasin wrote 09/07/2018 at 07:32 point

The WT588D module is definitely something I'll have to look at! 

Sound is still something that my project is lacking at, I'm just using a variable frequency PWM output for the buzzer. 

I like the idea of using nerf gun casings, but my system doesn't care about what it's inside. 

As for using the IR LED of a flashlight together with a IR camera, I'm not sure if that is a good idea. A camera wouldn't be capable of decoding a modulated IR signal, meaning that any source of IR light would look like a shot. 

Plus, you wouldn't be able to discern individual players, which would not allow for different weapon types or teams to be used effectively.

Isn't a IR camera a bit expensive too? >.<

If you want, you can look at the code of my AVR chip. With a few modifications it can run in stand-alone mode, without the need for an ESP and server. 

You'd have to change it a bit to work with the sound module too, but that's doable.

  Are you sure? yes | no

Similar Projects

Does this project spark your interest?

Become a member to follow this project and never miss any updates