|
Arduino Nano V3 |
x 1 | |
|
Ra-01Ra-01
|
x 1 | |
|
Mini Breadboard |
x 1 | |
|
DHT22AMAZON
|
x 1 |
|
Arduino Web Editor |
|
|
ThingSpeakThingSpeak
|
Lora Communication With Network
This was a very simple project and can come in handy for various applications. But what it can't do is establish communication with the internet for modern-day IoT applications. So in this project, we will be using the HPD13A which is a SX1276 IC-based LoRa module to establish communication with the things network, so we can use this module for IoT-related applications. So without further ado let's get right into it.
HPD13A - SX1276 Based LoRa Module Pinout
The pinout of the HPD13A - SX1276-based LoRa module is shown below. For this tutorial, we will be using the HDP13A V1.1 LoRa Module which is designed and developed by HPDTeK a well-known manufacturer in china. The pinout of the module is shown below.
GND This is the Ground Pin of the module that should be connected to the Ground pin of the ESP32 or Arduino whichever microcontroller you are using. There are a total of three ground pins on the board, all those are connected internally.
SDO(MISO) The SDO pin is the Serial Data Out pin of the Microcontroller. An output signal on a device where data is sent out to another SPI device.
SDI(MOSI) The SDI pin is the Serial Data In for the Microcontroller. An input signal on a device where data is received from another SPI device.
SCKIt is the Serial Clock Pin of the Module; the Serial Clock is generated by the microcontroller.
SELis the Chip Select pin of the Module. Activated by the controller to initiate communication with a given peripheral.
RSTThis is the Reset pin of the module board which is used to reset the microcontroller to its initial values.
IO(2-5)This is the GPIO pins of the LoRa module. This can be set to High or Low in Software.
ANTThis is the pin where the Antenna needs to be attached. You need to connect a proper antenna according to the datasheet.
VCCThis is the power pin of the module, you can connect this to the VCC pin to any 3.3V. As the max voltage level of the module is 3.3V.
The SX1276 886 MHZ LoRa Module
For this tutorial, we will be using the 868MHZ lora module which is designed and manufactured by SEMTECH. The module is a very easy-to-use, low-cost, high-efficiency module that can be used in many different applications.
The SX1276/77/78/79 transceivers feature the LoRaTM long-range modem that provides ultra-long range spread spectrum communication and high interference immunity whilst minimizing current consumption. It's said that by using SX1276 one can achieve a sensitivity of over -148dBm using a low-cost crystal and bill of materials.
What is the Difference Between HPD13A SX1276 and RFM95W Lora Module
As you can see from the above image, the name of the module is shown as the HPD13A module and the listing on the distributor's website said it was the SX1276 LoRa module. This was very confusing at first.
So we decided to decap the model to see what's underneath. And from the above image, you can see we found out that the company named HPDTek assembled the module so they are using their own part number and under the hood, you can see it's made out of the SX1276 LoRa IC.
Now the question remains what is the difference between the RFM95W and the HX1276 ic. The modules are the same so the characteristics of the modules are also the same. If your objective is to establish LoRa communication this is not that hard to do. HopeRF licenses the technology from Semtech. So the unshielded RFM95W module is virtually identical to some of the SX127x modules and its pin and software are also compatible. In the above image, you can see the difference between the two modules.
Making Breakout Board with Perfboard
If you check the pin pitch of the module, it's not breadboard friendly so we need to make a breakout board for the module, and there are two ways to do so. You can make a breakout board by soldering the module in a perf board and soldering some header pins to it. The second way is to make a PCB for the model and solder the module to the PCB. For our case, we have selected the first method as it is simple and takes very little time. The complete construction of the breakout board is shown below.
If you check out the HPA13A module it comes with a metal shield cap to reduce EMI and interference. We have removed the cap to see the internal construction of the module as you can see in the above picture. We did this because it will give us a good idea of what is inside the module.
#include <lmic.h>
#include <hal/hal.h>
#include <SPI.h>
// include the DHT22 Sensor Library
#include "DHT.h"
// DHT digital pin and sensor type
#define DHTPIN 5
#define DHTTYPE DHT22
#ifdef COMPILE_REGRESSION_TEST
#define FILLMEIN 0
#else
#warning "You must replace the values marked FILLMEIN with real values from the TTN control panel!"
#define FILLMEIN (#dont edit this, edit the lines that use FILLMEIN)
#endif
static const u1_t PROGMEM APPEUI[8] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
void os_getArtEui (u1_t* buf) {
memcpy_P(buf, APPEUI, 8);
}
// This should also be in little endian format, see above.
static const u1_t PROGMEM DEVEUI[8] = { 0xF5, 0x33, 0x05, 0xD0, 0x7E, 0xD5, 0xB3, 0x70 };
void os_getDevEui (u1_t* buf) {
memcpy_P(buf, DEVEUI, 8);
}
// This key should be in big endian format (or, since it is not really a
// number but a block of memory, endianness does not really apply). In
// practice, a key taken from ttnctl can be copied as-is.
static const u1_t PROGMEM APPKEY[16] = { 0xB8, 0x2B, 0xEA, 0xC6, 0x49, 0x5A, 0xAC, 0xBC, 0x36, 0xAC, 0x22, 0x4A, 0xF2, 0x78, 0x33, 0x72 };
void os_getDevKey (u1_t* buf) {
memcpy_P(buf, APPKEY, 16);
}
// payload to send to TTN gateway
static uint8_t payload[5];
static osjob_t sendjob;
// Schedule TX every this many seconds (might become longer due to duty
// cycle limitations).
const unsigned TX_INTERVAL = 30;
// Pin mapping for Adafruit Feather M0 LoRa
// /!\ By default Adafruit Feather M0's pin 6 and DIO1 are not connected.
// Please ensure they are connected.
const lmic_pinmap lmic_pins = {
.nss = 9,
.rxtx = LMIC_UNUSED_PIN,
.rst = 10,
.dio = {8, 7, LMIC_UNUSED_PIN},
};
// init. DHT
DHT dht(DHTPIN, DHTTYPE);
void printHex2(unsigned v) {
v &= 0xff;
if (v < 16)
Serial.print('0');
Serial.print(v, HEX);
}
void onEvent (ev_t ev) {
Serial.print(os_getTime());
Serial.print(": ");
switch(ev) {
case EV_SCAN_TIMEOUT:
Serial.println(F("EV_SCAN_TIMEOUT"));
break;
case EV_BEACON_FOUND:
Serial.println(F("EV_BEACON_FOUND"));
break;
case EV_BEACON_MISSED:
Serial.println(F("EV_BEACON_MISSED"));
break;
case EV_BEACON_TRACKED:
Serial.println(F("EV_BEACON_TRACKED"));
break;
case EV_JOINING:
Serial.println(F("EV_JOINING"));
break;
case EV_JOINED:
Serial.println(F("EV_JOINED"));
{
u4_t netid = 0;
devaddr_t devaddr = 0;
u1_t nwkKey[16];
u1_t artKey[16];
LMIC_getSessionKeys(&netid, &devaddr, nwkKey, artKey);
Serial.print("netid: ");
Serial.println(netid, DEC);
Serial.print("devaddr: ");
Serial.println(devaddr, HEX);
Serial.print("AppSKey: ");
for (size_t i=0; i<sizeof(artKey); ++i) {
if (i != 0)
Serial.print("-");
printHex2(artKey[i]);
}
Serial.println("");
Serial.print("NwkSKey: ");
for (size_t i=0; i<sizeof(nwkKey); ++i) {
if (i != 0)
Serial.print("-");
printHex2(nwkKey[i]);
}
Serial.println();
}
// Disable link check validation (automatically enabled
// during join, but because slow data rates change max TX
// size, we don't use it in this example.
LMIC_setLinkCheckMode(0);
break;
/*
|| This event is defined but not used in the code. No
|| point in wasting codespace on it.
||
|| case EV_RFU1:
|| Serial.println(F("EV_RFU1"));
|| break;
*/
case EV_JOIN_FAILED:
Serial.println(F("EV_JOIN_FAILED"));
break;
case EV_REJOIN_FAILED:
Serial.println(F("EV_REJOIN_FAILED"));
break;
break;
case EV_TXCOMPLETE:
Serial.println(F("EV_TXCOMPLETE (includes waiting for RX windows)"));
if (LMIC.txrxFlags & TXRX_ACK)
Serial.println(F("Received ack"));
if (LMIC.dataLen) {
Serial.println(F("Received "));
Serial.println(LMIC.dataLen);
Serial.println(F(" bytes of payload"));
}
// Schedule next transmission
os_setTimedCallback(&sendjob, os_getTime()+sec2osticks(TX_INTERVAL), do_send);
break;
case EV_LOST_TSYNC:
Serial.println(F("EV_LOST_TSYNC"));
break;
case EV_RESET:
Serial.println(F("EV_RESET"));
break;
case EV_RXCOMPLETE:
// data received in ping slot
Serial.println(F("EV_RXCOMPLETE"));
break;
case EV_LINK_DEAD:
Serial.println(F("EV_LINK_DEAD"));
break;
case EV_LINK_ALIVE:
Serial.println(F("EV_LINK_ALIVE"));
break;
/*
|| This event is defined but not used in the code. No
|| point in wasting codespace on it.
||
|| case EV_SCAN_FOUND:
|| Serial.println(F("EV_SCAN_FOUND"));
|| break;
*/
case EV_TXSTART:
Serial.println(F("EV_TXSTART"));
break;
case EV_TXCANCELED:
Serial.println(F("EV_TXCANCELED"));
break;
case EV_RXSTART:
/* do not print anything -- it wrecks timing */
break;
case EV_JOIN_TXCOMPLETE:
Serial.println(F("EV_JOIN_TXCOMPLETE: no JoinAccept"));
break;
default:
Serial.print(F("Unknown event: "));
Serial.println((unsigned) ev);
break;
}
}
void do_send(osjob_t* j){
// Check if there is not a current TX/RX job running
if (LMIC.opmode & OP_TXRXPEND) {
Serial.println(F("OP_TXRXPEND, not sending"));
} else {
// read the temperature from the DHT22
float temperature = dht.readTemperature();
Serial.print("Temperature: "); Serial.print(temperature);
Serial.println(" *C");
// adjust for the f2sflt16 range (-1 to 1)
temperature = temperature / 100;
// read the humidity from the DHT22
float rHumidity = dht.readHumidity();
Serial.print("%RH ");
Serial.println(rHumidity);
// adjust for the f2sflt16 range (-1 to 1)
rHumidity = rHumidity / 100;
// float -> int
// note: this uses the sflt16 datum (https://github.com/mcci-catena/arduino-lmic#sflt16)
uint16_t payloadTemp = LMIC_f2sflt16(temperature);
// int -> bytes
byte tempLow = lowByte(payloadTemp);
byte tempHigh = highByte(payloadTemp);
// place the bytes into the payload
payload[0] = tempLow;
payload[1] = tempHigh;
// float -> int
uint16_t payloadHumid = LMIC_f2sflt16(rHumidity);
// int -> bytes
byte humidLow = lowByte(payloadHumid);
byte humidHigh = highByte(payloadHumid);
payload[2] = humidLow;
payload[3] = humidHigh;
LMIC_setTxData2(1, payload, sizeof(payload)-1, 0);
}
// Next TX is scheduled after TX_COMPLETE event.
}
void setup() {
delay(5000);
while (! Serial);
Serial.begin(9600);
Serial.println(F("Starting"));
dht.begin();
// LMIC init
os_init();
// Reset the MAC state. Session and pending data transfers will be discarded.
LMIC_reset();
do_send(&sendjob);
}
void loop() {
os_runloop_once();
}
Lora Communication With Network
- Comments(0)
- Likes(0)
- 0 USER VOTES
- YOUR VOTE 0.00 0.00
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
More by electronicguru0007
- How to make an alarm clock with pic microcontroller he five push buttons will act as an input for setting the alarm for the required time. So one end of...
- How to make RMS to DC Converter using IC AD736 A True-RMS or TRMS is a type of converter which converts RMS value to equivalent DC value. Here in t...
- STM32 SPI Communcation and Data Sent SPI in STM32F103C8Comparing SPI bus in Arduino & STM32F103C8 Blue Pill board, STM32 has 2 SPI bu...
- How to Communicate Arduinos via RS-485 What project will you develop?The project consists of 3 Arduino's. We have an Arduino UNO, a Nano, a...
- PIC16F877A Temperature and Humidity Measurement Board Temperature and Humidity measurement is often useful in many applications like Home Automation, Envi...
- Diy Buck Converter n the field of DC-DC Converters, A single-ended primary-inductor converter or SEPIC converter is a t...
- Iot AC Current Measuring System Smart power monitoring is getting increasingly popular to improve energy efficiency in medium/small ...
- ESP32 Weather Station In this project, we will learn how to create a weather station, which will display reading from a BM...
- NRF Data Transfer Via 2 Boards There are various wireless communication technologies used in building IoT applications and RF (Radi...
- Iot patient monitoring system When we are talking about major vital signs of a human body, there are four major parameters that we...
- Setting up zigbee communication with nodemcu and arduino Zigbee is a popular wireless communication protocol used to transfer a small amount of data with ver...
- Ac Dimmer Remote PCB The brightness can be controlled using the IR remote of TV, DVD, etc. Dimming Control system using M...
- Esp32 Home Automation There are relay modules whose electromagnet can be powered by 5V and with 3.3V. Both can be used wit...
- Lora Communication With Network This was a very simple project and can come in handy for various applications. But what it can't do ...
- GPS Module Based Tracking Device Pcb ESP32 GPS vehicle tracker using NEO 6M GPS module and Arduino IDE. With the help of this GPS tracker...
- Traffic Management for Emergency Vehicles using AT89S52 Microcontroller These days’ traffic congestion is the biggest problem of densely populated cities. The project focus...
- Diy Multimeter Pcb This is a project based on Arduino board which can measureresistance, diode, continuity[H1] , voltag...
- Live Instagram Followers Pcb ESP8266 is capable of functioning reliably in industrial environments, with an operating temperature...
-
-
-
-
-
-
3D printed Enclosure Backplate for Riden RD60xx power supplies
154 1 1 -
-