The Mir:ror is an RFID reader produced by the company Violet, which also produced the Nabaztag. With the idea of the Internet of Things in mind, this device is a mass-market RFID reader really easy to use. You just have to connect it to your computer via USB, and associate any RFID tag to an action trough Violet’s website.

But here is the problem. Since the service is hosted on a remote server run by a service provider, how can you be sure of how long the service will be provided ? The company Violet does not exist anymore, so the device had become useless.

Actually, it is really easy to find a new usage for the Mir:ror. The behavior is really simple: it sends a data flow trough the USB. All you have to do is to understand the data flow and define how it will trigger some actions.

Set up

First, from your computer, you have to find out where it is connected. You juste need to use the dmesg command to find out that the Mir:ror can be found on /dev/hidraw1. Usage of dmesg | grep Mirror should return something like:

generic-usb 0003:1DA8:1301.0002: hiddev96,hidraw1: USB HID v1.00 Device [Violet Mirror] on usb-0000:00:1d.2-2/input0

and of course, you can check that by issuing a ls /dev/hidraw1.

Of course, this path is only accessible as root. So we’ll fix this issue by adding a UDEV rule. Lets just edit the file /etc/udev/rules.d/mirror.rules (as root) and add the following line:

KERNEL=="hidraw*", ATTRS{idVendor}=="1da8", ATTRS{idProduct}=="1301", SYMLINK+="mirror", MODE="0666"

The Mir:ror can now be accessed by anyone on /dev/mirror. We’ll just need to reload the UDEV rules with a /etc/init.d/udev restart on Debian based disto or with udevadm control restart on Archlinux.

Using the Mir:ror

The Mir:ror sends a data as a 16 bites flow. All we have to do is to parse that flow. Of course, this may be done with any computer language. Lets do it using Python.

So, we are going to read the input flow, keep anything that is not null and chose an action depending on the message type. The two first bites indicates what the message is about, which may be:

  • The device is turned upside down.
  • The device is turned the right side up.
  • The device detects that a tag is put on.
  • The device detects that a tag is put away.

So the code could look like this:

#!/usr/bin/python
# -*- coding: utf-8 -*-

import binascii

# Opening mirror.
mirror = open("/dev/mirror", "rb")

while 1:
    mirror_flow = mirror.read(16)
    if mirror_flow != '\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00':
        rfid_id = binascii.hexlify(mirror_flow)[4:]
        if mirror_flow[0:2] == '\x02\x01': # A tag is put on
            print "Tag with ID %s on the device." % rfid_id

        elif mirror_flow[0:2] == '\x02\x02': # A tag is put away
            print "Tag with ID %s taken away." % rfid_id

This code only display the ID of the tag read as it is put on or away from the device. An easy way to add some action is to create some shell scripts for each ID and action (put on or away). By convention, lets name those files rfid_id-in.sh and rfid_id-out.sh where rfid_id is the ID read in our code (I kept the same variable name on purpose). We just have to change the execution bloc as

        if mirror_flow[0:2] == '\x02\x01': # A tag is put on
            os.system(rfid_id + "-in.sh")

        elif mirror_flow[0:2] == '\x02\x02': # A tag is put away
            os.system(rfid_id + "-out.sh")

Of course, this code should be improved. If an unknown tag is detected, an ugly error message will be displayed. Lets delegate the execution to a function:

def executeRfidAction(scriptName):
    if not os.path.isfile(scriptName):

        if pynotify.init("icon-summary-body"):
            n = pynotify.Notification(
                "Action not found",
                "The file %s was not found." % (os.path.join(prop.scriptPath, scriptName)),
                "/path/to/my/icon.png")
            n.show()
        print "The file %s does not exist, you should create it." % (scriptName))

    else:
        os.system(os.path.join(prop.scriptPath, scriptName))

Now we’ll have a nice notification. I kept the print statement to help copy/past the ID and let you improve this part at your convenience (automatically create the file, better notification, addition in a datasource…).

A practical case…

… fun for kids: with the Mir:ror, you had 2 little rabbits which are tags. Lets use one of it to take control over a light trough the X10 protocol. You just need to put in your corresponding scripts the statement heyu on a1 and heyu off a1 (of course, the light id should be adapted and heyu should be installed and configured). So, when you put the rabbit on the Mir:ror, the light is turned on, when you put it out, the light is turned off… Kids love it.

This is a nice start to use the Mir:ror. As you saw, it should be considered as a simple action trigger. All you have to do is associate an action to an ID and its behavior (in or out). All the rest, is just coding the action.

So, what usage did you find ?

About Darko Stankovski

Darko Stankovski is the founder and editor of Dad 3.0. You can find more about him trough the following links.