RFID and LoRa on Arduino

Last time I got a LoRa Server and LoRa Client to communicate to each other. It was about time to give them something to talk about i.e. start exchanging sensor data rather than just “Hello World”.

RFID tags

I plugged in my RFID reader which I bought like a years ago. My Arduino UNO was getting scrambled data on its serial. I tried connecting the RFID reader alone. The Arduino detected the device but whenever I’d place an RF tag on it, no data would be read.


The forums suggested to solder the pins on the board for better connection but it didn’t work in my case. Most probably my device was faulty.

Fortunately my friend Damien from DM Electronics had the device is his stock which he sold to me. I’d highly recommend you to buy your electronic devices from there if you’re in Mauritius. He’s an awesome guy who has a deep understanding about how the devices actually operate on the inside.

I followed the tutorial above with Damien’s RC522 and it worked. But this is only half of my problems. I still need to put the LoRa shield back on.

Making LoRa and RFID reader work together

The LoRa shield and RC5222 use Serial Peripheral Interface (SPI) to communicate with the Arduino. SPI was new to me since I was familiar with 3 pin sensors (Ground, 3.3V and Data). SPI consists of:

  1. 3.3V: Provides power. Easy
  2. Ground: Well, ground
  3. RST: Reset: Still no idea what it does. Can you tell me in the comments?
  4. SS: Slave Select: It sends a signal when the device shall listen and transmit data.
  5. MOSI: Master Out Slave In: The line which is used to receive data from the Arduino
  6. MISO: Master In Slave Out: The line which is used to send data to the Arduino.

Since the SS line exists, it should be possible to mute the RFID reader while LoRa is transmitting/receiving data. The MFRC522 library allows the user to set a custom SS and RST pin.

#define RST_PIN 6
#define SS_PIN 7

MFRC522 mfrc522(SS_PIN, RST_PIN);

The default 9,10 pins will be used by LoRa and 6,7 pins will be used by RFID Reader. I tried manually setting turning of LoRa shield by setting the SS pin high without success

pinMode(10, OUTPUT);      // sets the digital pin as output
digitalWrite(10, HIGH);

Reading the source code of the SPI library (“SPI.h”), I came across the method `end()`. The RH_RF95 library also has a `sleep()` method. My final code looks like this:

void setup() {

void loop() {

void readCard() {

void lora(String data) {
  rf95.send(data.c_str(), data.length());

And there you go. LoRa and RFID working together.

MIT GSL Mauritius: Winners of Social Impact Award

Over the past 8 weeks, I’ve been attending the MIT GSL [1] programme for Mauritius. It has been an amazing journey. Our team won the Social Impact Award.

Credit: ict.io

Energy demand is increasing yearly but energy supply is having a hard time to catch up in Mauritius. Our project consisted of using IoT devices to reduce energy wastage and to accelerate green energy adoption.

We investigated the greatest consumers of electricity in Mauritius and we found hotels to be among the culprits we hope to tackle. One of the reasons why saving energy is so difficult right now because users don’t know exactly how much each appliance is using. With the advancement of IoT technology and prices of the latter going down, we can now afford to measure the power consumption of each and every device in near real-time.

We can thus analyze the data and remotely turn-off appliances which are wasting energy.

Future plans

Due to high demand with maintenance managers, we hope to provide water and gas monitoring solutions to detect leaks.

If you are paying too much for your electricity bills and you have no idea why? Feel free to contact us. My email address is nayar@joolfoo.com

[1] Massachusetts Institute of Technology Global Startup Lab

IoT Series: Smart Light/Sensors in the Kitchen

The Idea

The idea is simple. When someone is the kitchen, the lights should be turned on. When their’s no one,obviously it should be turned off. Wouldn’t a simple $10 IR switch from eBay do the job?

WiFi Switch with Motion Sensor attached

“Would the lights turn on even during the day” my mom asked when I presented the system to her. “Of course not” I replied. It would have be counterproductive and non-environmental friendly then.

Everyone can start using cheap sensors and all but using them in such a way that actually makes sense is what’s the challenge.

How it works

When the motion sensor detects motion, it sends a signal to via MQTT to my main app server.

The server side application calculates whether the sun is above or below horizon — the sun doesn’t rise and set at the same time throughout the year. e.g. in summer, the sun can set around 1900 but in winter, around 1800. The application will calculate the exact time  on a daily basis so I won’ have to worry about this.

If the sun is below horizon, the kitchen light will turn on. Else the motion detected will just be ignored (but still be graphed for future use).

Is that the only benefit?

Having a IoT sensors and switches would allow be to get into the next phase of my work: Machine Learning or AI (Artifical Intelligence) as you wish to call it.

For instance, you might start by looking at the graphs for each light to find a pattern visually.

Right now, I do not have the ressources to send all the data in an Elasticsearch cluster then visualise it using Kibana. Another idea would be to mine the data with Google’s Tensorflow. Alone, it will take me some time to do it all.

Previous works on IoT

If you haven’t been following me previously, I made a system that whenever I reach in front of my house, my outside lights turn on automatically for 2 minutes — the time I reverse my car and enter my house. You may find the article here: Internet of Things (IoT) in Mauritius, lemme just do it!


Wanna get into the world of Home Automation too? Wanna turn on your coffee machine from your bed and more? Feel free to contact me on LinkedIn, Facebook or Twitter.

Iot Series: Internet of Things (IoT) in Mauritius!

I reach home from work when it’s already dark. I got to park my car in front of my house. I said to myself wouldn’t it be awesome if I could light up the house exterior light using my mobile phone? I bought some WiFI enabled switches from the internet and installed it. Here’s a diagram of the installation.


‘All iz well’ except for 1 problem. Nayar’s highness has stop his car, unlock his phone, launch an app, press the LIGHT ON button, then reverse his car. Nayar is not happy!!!

So I had to make a system such that whenever Nayar reaches home, the exterior lights up automatically? Makes sense right? How did I achieve this? Simple but not so simple.


The Wireless Switch was vendor locked in; meaning it works with their cloud service and Android/iOS app. It doesn’t give me the flexibility for I need. Had to do the following steps in order to be free:

  1. Flash an Arduino firmware (from github) to the wireless switch.
  2. Create a home automation server on a raspberry pi (which I dropped in favour of cloud hosting)
  3. Create an Android app which whenever I connect to my home WiFi, I sends the TURN ON lights on

After lots of research and development, trial and error, it finally worked 😀

Is it over? Nope. Who’s gonna turn off the lights when I enter home? Ofcourse I put a 3 minutes timer in it 😛

And the Laziest Award 2016 goes to?

Coming soon. Very soon:

  • Control garage doors (R&D stage)
  • Temperature and humidity sensors (prototype stage)
  • Get status of windows/doors status: open or closed (R&D stage)
  • Home Camera Surveillance (waiting for materials)
  • Smart TVs integration (prototype stage)
  • Solar Water Tank monitoring and control inflows (R&D stage)

Wanna get into the world of Home Automation too? Wanna turn on your coffee machine from your bed and more? Feel free to contact me on LinkedIn, Facebook or Twitter.