Arduino LoRa Free SMS over Long distance without GSM Network, LoRa Bluetooth
Table of Contents
Arduino LoRa Free SMS:
Arduino LoRa Free SMS over Long distance without GSM Network– In this tutorial, you will learn how to send free SMS or text messages over long distances using Arduino boards, a pair of SX1278 LoRa Transceiver modules, a pair of HC05 or HC06 Bluetooth modules, a 5v Buzzer, and a pair of smartphones with my designed android Application installed in.
With my designed project, you don’t need a GSM network to send and receive free SMS or messages. We will exhibit how to use long-range LoRa transceiver modules for sending free SMS. Before I start practical demonstration, I think it is necessary to share certain useful information with you so that you can better realize the significance of this all-important project for yourself.
When we are in an area where access to a GSM network coverage is available, then we can simply use our smartphone either to send messages or receive our calls. Under such a scenario, we do not have to need any kind of reliance on a LoRa network for sending messages.
However, imagine yourself to be in an utterly different type of a situation, say you and your friends or teammates, find yourself to be in a remote or mountainous kind of a region, where GSM network facility is not available at all, then how can it be possible to keep in touch or communicate with your team members or friends.
Well, you have two options for tackling such a situation.
- You can either rely upon and carry an expensive, hand-held readymade walkie-talkie, portable two-way transceivers to such a place along with you, which obviously, you cannot modify as per your requirement or according to your needs. These devices will only serve the purpose for which they have been designed and nothing else.
- The second and more pragmatic and effective kind of option which can be relied upon is to use my specially designed long-range wireless SMS or text messaging system, which can be modified according to a situation and one’s own requirements. You can even build a whole network from this system and as such, you can easily communicate with any member of your team quite easily. Moreover, multiple teams can remain interacted and communicate with each other.
As I have said, it is a low-cost project, and if you read this article with a little bit of concentration, and follow my instructions carefully, I am sure you can design this project by yourself maximum within an hour’s time. Anyhow, enough with the talking, now let us practically see this project in action.
Practical demonstration:
You can clearly see that both sides are 100% identical. For understanding the concept conveniently, I will term one of the sides as User 1, while referring to the second side as User 2. You can design similar circuits for other users as well by means of making such connections. Thus, more and more people will get in touch and would be able to communicate and interact.
Anyways, I will opt to continue just with User 1 and User 2 for demonstration purposes. User 1 can both send as well as receive messages, likewise, User 2 can also send as well as receive messages.
The smartphones possessed by User 1 and User 2 are connected through Bluetooth. And you can see that my designed application is open on both these smartphones. Guys, if you are interested to design an exactly similar type of android application, you must read my article on how to design your own android application. And, if you want to use exactly this same application, then you can download the APK file.
The working of this project is pretty simple. First, a message is transmitted to Bluetooth from a smartphone and then Bluetooth forwards it to Arduino. Then using LoRa, Arduino sends this message wirelessly to the remote side LoRa module “user2 side”.
On the other side, Arduino receives a message from LoRa, and then forwards it to the smartphone application through Bluetooth. Exactly the same process will be carried out on the User 2 side. So, let us move ahead and try to send some messages.
You have seen how easily we can send and receive free SMS or messages. However, one issue needs to be pointed out over here. If the application in a cell phone is not open, or if the cell phone is OFF, then how will User 1 or User 2 come to know that a person on the other side wants to talk to him.
Let us say, right now User 1 wants to talk with User 2. But the cell phone of User 2 is unluckily OFF. Under such a situation, even if User 1 sends hundreds of messages, User 2 will remain absolutely unaware of it. To solve this issue.
I have connected a 5v buzzer with User 2 and connected an Led with User 1. If you want, buzzers or LEDs can be connected on both sides, otherwise, you can also fix vibrators. Anyhow, I have made a slight modification in its code after the connection of the buzzer and Led.
Now I can send SMS or messages as well as commands. For example, suppose I need to talk to User 2, so I will send 45 number as the command from my cell phone, which will turn ON the buzzer on User 2 side. This will let User 2 know that User 1 wants to talk to me. Then, User 2 can open the application and start communicating with User 1. Let me practically demonstrate it for you.
45 is the command and when I sent this command buzzer on the User 2 side was turned ON. For the practical demonstration, you can watch the video given at the end of this article. User 2 can also send a command to User 1 in a similar fashion.
Guys, modification in its code is not much of an issue and you can easily modify it according to your need. You can also define multiple commands as per your requirements, e.g., you can use and send a distinct command for coping with any sort of dangerous situation. Anyway, I am sure by now you might have got an idea of how does this system work. So, without any further delay, let’s get started!!!
Amazon Links:
Arduino Nano USB-C Type (Recommended)
*Disclosure: These are affiliate links. As an Amazon Associate I earn from qualifying purchases.
SX1278 LoRa Module:
Features:
- Frequency Range: 868 / 915 MHz
- Sensitivity up to -139dBm @Lora
- Maximum output power: 20 dBm
- 13mA@receiver mode
- Sleep current <200 nA
- Data transfer rate: @FSK,1.2-300 Kbps
- @Lora TM, 0.018-37.5 Kbps
- Lora TM, FSK, GFSK & OOK Modulation mode
- Built-in ESD Protection
- 127 dB Dynamic Range RSSI
- Packet engine up to 256 bytes with FIFO and CRC
- Hopping frequency
- Built-in temperature sensor and low battery indicator
- Excellent blocking immunity
- Operating Temperature Range:-40 ~ + 85 °C
Applications:
- Remote control
- Remote meter reading
- Home security alarm and remote keyless entry
- Industrial control
- Home automation remote sensing
- Individual data records
- Toys control
- Sensor network
- Tire pressure monitoring
- Health monitoring
- Wireless PC peripherals
- Tag reading and writing
Bluetooth HC-05:
- Bluetooth module HC-05 Master and slave Two in one module.
- Use the CSR BC417 mainstream bluetooth chip, bluetooth V2.0 SPP protocol standards
- Module working voltage 3.6 V to 6V
- Default rate of 9600,default pin:1234, the user can be set up.click the button into AT MODE
- Can be switched via AT commands as master or slave mode , the device can be connected via AT commands specified
User1 & User2 Circuit Diagram:
User1 and User2 shares the same circuit diagram.
The VCC of the LoRa module is connected with the 3.3V of the Arduino. The MISO Pin of the LoRa module is connected with the Arduino pin 12. The MOSI pin is connected with pin 11. The SCK pin of the LoRa module is connected with pin 13. The NSS pin is connected with the Arduino’s pin 10 and the ground pin of the LoRa module is connected with the Arduino’s GND.
On the left side, you can see a 5V regulated power supply based on the LM7805 voltage regulator. We use this regulated 5 volts to power up the Arduino and all the other electronics.
The VCC and GND pins of the HC05 Bluetooth module are connected with the Arduino 5V and GND pins. While the TXD and RXD pins of the Bluetooth module are connected with the RX0 and TX1 pins of the Arduino Nano.
A 5V buzzer is connected with the Arduino Pin 3. If the buzzer draws more current and it doesn’t turn ON then you can use a driver circuit as explained in my previous LoRa based project.
Before, you start the programming, first of all, make sure you download the LoRa library.
Arduino LoRa Free SMS, Programming:
User1 Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 |
/* User1 side */ #include <SPI.h> // include libraries #include <LoRa.h> byte msgCount = 0; // count of outgoing messages byte localAddress = 0xBB; // address of this device byte destination = 0xFF; // destination to send to int buzzer=3; String outgoing; // outgoing message String Mymessage; // stores message from the bluetooth int calling; // stores the command void setup() { Serial.begin(9600); // initialize serial Serial.println("LoRa Duplex"); if (!LoRa.begin(433E6)) { // initialize ratio at 915 MHz Serial.println("LoRa init failed. Check your connections."); while (true); // if failed, do nothing } Serial.println("LoRa init succeeded."); pinMode(buzzer,OUTPUT); } void loop() { if(Serial.available()>0) { //read data Mymessage=Serial.readString(); sendMessage(Mymessage); delay(100); Mymessage = ""; } // parse for a packet, and call onReceive with the result: onReceive(LoRa.parsePacket()); } void sendMessage(String outgoing) { LoRa.beginPacket(); // start packet LoRa.write(destination); // add destination address LoRa.write(localAddress); // add sender address LoRa.write(msgCount); // add message ID LoRa.write(outgoing.length()); // add payload length LoRa.print(outgoing); // add payload LoRa.endPacket(); // finish packet and send it msgCount++; // increment message ID } void onReceive(int packetSize) { if (packetSize == 0) return; // if there's no packet, return // read packet header bytes: int recipient = LoRa.read(); // recipient address byte sender = LoRa.read(); // sender address byte incomingMsgId = LoRa.read(); // incoming msg ID byte incomingLength = LoRa.read(); // incoming msg length String incoming = ""; while (LoRa.available()) { incoming += (char)LoRa.read(); } if (incomingLength != incoming.length()) { // check length for error //Serial.println("error: message length does not match length"); ; return; // skip rest of function } // if the recipient isn't this device or broadcast, if (recipient != localAddress && recipient != 0xFF) { // Serial.println("This message is not for me."); ; return; // skip rest of function } // if message is for this device, or broadcast, print details: //Serial.println("Received from: 0x" + String(sender, HEX)); //Serial.println("Sent to: 0x" + String(recipient, HEX)); //Serial.println("Message ID: " + String(incomingMsgId)); // Serial.println("Message length: " + String(incomingLength)); // Serial.println("Message: " + incoming); // Serial.println("RSSI: " + String(LoRa.packetRssi())); // Serial.println("Snr: " + String(LoRa.packetSnr())); // Serial.println(); String q = getValue(incoming, ',', 0); // Serial.println("q: " + q); calling = q.toInt(); //Serial.println(q); if(calling== 45) { digitalWrite(buzzer, HIGH); delay(1000); digitalWrite(buzzer,LOW); delay(1000); digitalWrite(buzzer, HIGH); delay(1000); digitalWrite(buzzer,LOW); delay(1000); digitalWrite(buzzer, HIGH); delay(1000); digitalWrite(buzzer,LOW); delay(1000); calling = 0; } else Serial.println(q); } String getValue(String data, char separator, int index) { int found = 0; int strIndex[] = { 0, -1 }; int maxIndex = data.length() - 1; for (int i = 0; i <= maxIndex && found <= index; i++) { if (data.charAt(i) == separator || i == maxIndex) { found++; strIndex[0] = strIndex[1] + 1; strIndex[1] = (i == maxIndex) ? i+1 : i; } } return found > index ? data.substring(strIndex[0], strIndex[1]) : ""; } |
User2 Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 |
/* User2 side */ #include <SPI.h> // include libraries #include <LoRa.h> byte msgCount = 0; // count of outgoing messages byte localAddress = 0xFF; // address of this device byte destination = 0xBB; // destination to send to int buzzer=3; String outgoing; // outgoing message String Mymessage; // stores message from the bluetooth int calling; // stores the command void setup() { Serial.begin(9600); // initialize serial Serial.println("LoRa Duplex"); if (!LoRa.begin(433E6)) { // initialize ratio at 915 MHz Serial.println("LoRa init failed. Check your connections."); while (true); // if failed, do nothing } Serial.println("LoRa init succeeded."); pinMode(buzzer, OUTPUT); } void loop() { if(Serial.available()>0) { //read data Mymessage=Serial.readString(); sendMessage(Mymessage); delay(100); Mymessage = ""; } // parse for a packet, and call onReceive with the result: onReceive(LoRa.parsePacket()); } void sendMessage(String outgoing) { LoRa.beginPacket(); // start packet LoRa.write(destination); // add destination address LoRa.write(localAddress); // add sender address LoRa.write(msgCount); // add message ID LoRa.write(outgoing.length()); // add payload length LoRa.print(outgoing); // add payload LoRa.endPacket(); // finish packet and send it msgCount++; // increment message ID } void onReceive(int packetSize) { if (packetSize == 0) return; // if there's no packet, return // read packet header bytes: int recipient = LoRa.read(); // recipient address byte sender = LoRa.read(); // sender address byte incomingMsgId = LoRa.read(); // incoming msg ID byte incomingLength = LoRa.read(); // incoming msg length String incoming = ""; while (LoRa.available()) { incoming += (char)LoRa.read(); } if (incomingLength != incoming.length()) { // check length for error // Serial.println("error: message length does not match length"); ; return; // skip rest of function } // if the recipient isn't this device or broadcast, if (recipient != localAddress && recipient != 0xFF) { //Serial.println("This message is not for me."); ; return; // skip rest of function } // if message is for this device, or broadcast, print details: // Serial.println("Received from: 0x" + String(sender, HEX)); // Serial.println("Sent to: 0x" + String(recipient, HEX)); //Serial.println("Message ID: " + String(incomingMsgId)); // Serial.println("Message length: " + String(incomingLength)); //Serial.println("Message: " + incoming); //Serial.println("RSSI: " + String(LoRa.packetRssi())); //Serial.println("Snr: " + String(LoRa.packetSnr())); //Serial.println(); String q = getValue(incoming, ',', 0); calling = q.toInt(); // Serial.println(q); if(calling== 45) { digitalWrite(buzzer, HIGH); delay(1000); digitalWrite(buzzer,LOW); delay(1000); digitalWrite(buzzer, HIGH); delay(1000); digitalWrite(buzzer,LOW); delay(1000); digitalWrite(buzzer, HIGH); delay(1000); digitalWrite(buzzer,LOW); delay(1000); calling = 0; } else Serial.println(q); //incoming = ""; } String getValue(String data, char separator, int index) { int found = 0; int strIndex[] = { 0, -1 }; int maxIndex = data.length() - 1; for (int i = 0; i <= maxIndex && found <= index; i++) { if (data.charAt(i) == separator || i == maxIndex) { found++; strIndex[0] = strIndex[1] + 1; strIndex[1] = (i == maxIndex) ? i+1 : i; } } return found > index ? data.substring(strIndex[0], strIndex[1]) : ""; } |
If you take a look at the code of User1 and User2 you will find that both the codes are 100% the same.
The only difference is in the local address and destination address. If you want to add another user then simply add another address, for this you can read my article on LoRaWAN in which multiple LoRa nodes communicate with the Master LoRa node. Anyway, Let me explain the user1 code.
The buzzer is connected with pin 3 of the Arduino. I also defined some variables of the string and integer types which are well commented.
Inside the loop() function. We check if any data is available on the serial port means If the data is received from the Bluetooth module then read the entire string and store it in the variable Mymessage and then send this message to the remote LoRa module.
The onReceive() function monitors if any data is received from the LoRa module. Let’s say if data is received then the incoming message is split and first we check if the received data is a command, if its 45 turn ON the buzzer and if not then send this message to the Android cell phone application. You can see I am simply using Serial.println() function as the Bluetooth module is connected with the Arduino’s default serial port.
getValue() function is a user-defined function and it is used to split a string message using any character as the delimiter. I have already explained this function in very detail. So, that’s all about the programming.
Watch Video Tutorial:
I like the easy method that you explain your projects. How far would the bluetooth LoRa transmit? I am following your GPS tracker as well. Could geo fencing be incorporated into the use of Bluetooth and LoRa to SMS the lat and lon coordinates?
If you use a lora module with an antenna you can send free sms over 5km. I am already working on it. And recently i used the Xiao esp32c3 which has an onboard low energy bluetooth 5. So, i am planning on using Lora with the esp32c3. this bluetooth module can communicate over 100+ meters. You can read my article on Xiao esp32c3. And of course you can use bluetooth in geofencing project.
Sf settings for this code?
Good Day,
I would like to get the complete details on the project wires and circuit diagrams. and the complete source for the app. and what versions of the arduino and android app studio
thank you.