Alternative Wireless Connection For Your Arduino (or another microcontroller)

Fadhilah Rama
4 min readJun 10, 2021

--

My project with NRF24L01’s module

Arduino or other microcontroller should have a certain communication protocol to keep each board stay connected. Some of those are using internet, but have you thingking about the worst condition? In case, your automation or IoT system has placed in borderland. It could be a hard decision, yet the system should working as soon as possible and most crucial is it goes well.

Perhaps, you can use a wired for your system like using RS-485 with 3 pin CB. But it’s dreadful for outdoor and unpredicted situation. So, i would like to introduce a solution for protocol communition using Modul NRF24L01.

This module is using a radio frequency in 2.4 GHz with data transfer rate can be of 250kbps, 1Mbps, and 2Mbps. Such a good deal right? i think it’s enough for a basic or intermediate project which not need to transmit a big size of data.

How about the power consumption? This tiny module just can operate voltage from 1.9 V to 3.6 V, but the good news is that the logic pins are 5 Volt tolerant. so we can easily connect it to an Arduino or any 5 V logic microcontroller without using any logic level converter.

In this example, I using an adapter to get easier when hook with the microcontroller, and if you need a lengthy range you can use a duck-antenna. For a modul NRF24L01 without antenna you can reach up to 100m, and if you add an antenna you can extend the range until 1000m. But I quietly recommend don’t go too far with range when using this module, in the end I’ll show result of my experiment.

The Schematic

What you need for do this protipe is absolutely a microcontroller and two of module NRF24L01 (Master and Slave), and for additional i use a pin switch for send a instruction and led for sign if the instruction has been received. For the details see below:

Schematic of my project using Fritzing

The Code

As usual I use Arduino IDE to cook the program, you can copy theese program and just upload it to your board. Actually I obtain this code from internet, and just did some adjusting (i’m so sorry for not including a source, I really forget where i get this code if you mind just dm me, I’ll take credit for you).

MASTER

#include <nRF24L01.h>

#include <printf.h>

#include <RF24.h>

#include <RF24_config.h>

#include<SPI.h>

int pesan[1]={0};

const int tombol=6;

RF24 rf24(7,8);

const byte alamat = 225;

void setup() {

pinMode(tombol,INPUT);

rf24.begin();

rf24.openWritingPipe(alamat);

rf24.setPALevel(RF24_PA_MIN);

rf24.stopListening();

}

void loop() {

int bacaTombol;

bacaTombol=digitalRead(tombol);

pesan[0]=bacaTombol;

rf24.write(pesan,1);

delay(10);

}

and this one for the slave (receiver):

SLAVE

#include <nRF24L01.h>

#include <printf.h>

#include <RF24.h>

#include <RF24_config.h>

#include<SPI.h>

int pesan[1]={0};

const int led=2;

RF24 rf24(7,8);

const byte alamat = 225;

void setup() {

pinMode(led,OUTPUT);

delay(100);

rf24.begin();

rf24.openReadingPipe(0,alamat);

rf24.setPALevel(RF24_PA_MIN);

rf24.startListening();

}

void loop() {

while(rf24.available()){

rf24.read(pesan,1);

if(pesan[0]==1){

digitalWrite(led,HIGH);

}else{

digitalWrite(led,LOW);

}

delay(10);

}

}

The primary thing is dont forget to set the address both of the module should in the same address (look at const byte alamat=225).

The Test Result

Here i get, you can see from the graphic. I try on comparing between the distance of the master from the slave to the delay of transmit the instruction (and how the obstacle in between the NRF24L01’s module can be affect to the delivery process the instructions).

As you can see, obstacles really impactfull to the delivery process. Maybe the solution for this deficiency is to add some DIY an antenna booster (i haven’t tried this yet).

Graphic of my experiment

You need to examine the line of sight (LoS) too, because it’s one of factor to affect the quality process when delivering a data packages. You can see the illustration below.

(source : https://forum.huawei.com/enterprise/en/line-of-sight/thread/682371-100305)

That’s all from me, kindly to send me an advice. Thank you.

--

--

No responses yet