I want my home to know that I am home or away. This is the most important info for my house because the rules will be activated or deactivated according to my presence. For example the alarm system will be armed when I am away and must be off when I am home. If my home knows who entered the home then it can decide the appropriate settings for me or for my wife. There are different solutions for this problem. I look at them in detail and understand that this is not an easy task. There are location based systems that use your smart phone's GPS. Holding your GPS open all the time is not battery efficient. I saw some other solutions for android phone users but most of them are not working with IOS. I plan to solve this with a semi-automatic way. I will carry a small RfID tag with my keys and when I am home I will bring it closer to the RfID reader which is near the door and my home will understand my presence. My wife will carry a different key-fob so her id will be different. This way, my smart home will understand which one of us reached at home.

There are very cheap RfID readers around for a while and bringing them together with our great hero esp8266 WiFi chip seems to me a good idea. You of course can find other palaces to use this device. You can easily record the data in a database. The id and the time-stamp of reading the key-fob or RfID card can be used as workman attendance control system for your factory. I will try to code some applications and I want to hear from you some ideas for the other usages.

The main components for my design is like below:

makerstorage wifi rfid reader

The communication between our micro controller and the RfID reader is SPI. Do not worry about the details because we have a great Arduino library who is responsible with the details. The other communication protocol is serial communication between Esp8266 and our micro controller. We will simply send the scanned RfID number to Esp8266 over serial. The important part is we will add a new line character at the end so that Esp8266 will understand that it received one id. The embedded code inside Esp8266 then publish this id over MQTT. Let me quote here one sentence about MQTT from mqtt.org/faq.

MQTT stands for MQ Telemetry Transport. It is a publish/subscribe, extremely simple and lightweight messaging protocol, designed for constrained devices and low-bandwidth, high-latency or unreliable networks

MQTT is our messaging protocol and we will use it in all our IoT projects. Please take some time and watch some MQTT videos from YouTube.

Hardware:

There isn't so much to say about the schematics. The problem I faced here is the RfID connection headers. The SPI protocol needs robust connection so I replaced the regular headers with the precision headers. Please keep in mind this detail. You can always solder some wires to make the connection permanent.

makerstorage wifi rfid reader schematics

You can find the source files including the firmware at MakerStorage Github Repo

Software:

Actually we have two micro controllers in this project so we have two embedded code here. Our Atmega328p will be responsible to read the RFID and send it to Esp82266 over serial. The other code inside Esp8266 which will listen to the serial bus and when it receive the RfID number it will publish it over MQTT. Please find our repo above about these software.

Our device publishes MQTT messages with a payload of the scanned RfID. So what about the receiving part.

In order to see and debug the coming messages the great tool is MQTTLens

But This is not enough for MQTT communication. If you read about it you know about the Broker. MQTT Broker is a server which is a bridge between the communicating parties. Every party must connect to the broker in order to send and receive messages. In MQTT jargon sending messages means Publishing a message and this message will be send to the Subscribers over the broker. This mean that we need a MQTT broker. For this example I use mosquitto public broker The other important part about this example is we do not use any secure communication....

Read more »