To make a simple LoRa-to-4G gateway, you only need an ESP32S3 based 4G LTE module and a LoRa Expansion Board.
To make the experience fit your profile, pick a username and tell us what interests you.
We found and based on your interests.
LoRa-to-4G.inoino - 5.33 kB - 03/15/2024 at 06:21 |
|
Insert two AAA batteries into the Lora Temperature/ Humidity/ Soil Moisture Sensor V3 battery compartment, burn the code into the ESP32S3 based 4G LTE module, and open the serial port, when ESP32S3 based 4G LTE module successfully receives the Lora Temperature/ Humidity/ Soil Moisture Sensor V3 information, it can extract the data and request the URL of the write channel of Thingspeak to upload the data to the "Private View" page.
#include <RadioLib.h>
#include <SPI.h>
HardwareSerial mySerial2(2);
#define DEBUG true
#define IO_RXD2 47
#define IO_TXD2 48
#define IO_GSM_PWRKEY 4
#define IO_GSM_RST 5
// LoRa
#define LORA_MOSI 16 // 23
#define LORA_MISO 18 // 19
#define LORA_SCK 8 // 18
#define LORA_CS 17 // 21
#define LORA_RST 15 // 22
#define LORA_DIO0 9 // 32
#define LORA_DIO1 14 // 35
#define FREQUENCY 915.0
#define BANDWIDTH 125.0
#define SPREADING_FACTOR 9
#define CODING_RATE 7
#define OUTPUT_POWER 10
#define PREAMBLE_LEN 8
#define GAIN 0
SX1276 radio = new Module(LORA_CS, LORA_DIO0, LORA_RST, LORA_DIO1, SPI, SPISettings());
Serial.begin(115200);
Serial.println(" Test Begin!");
mySerial2.begin(115200,SERIAL_8N1, IO_RXD2, IO_TXD2);
pinMode(IO_GSM_RST, OUTPUT);
digitalWrite(IO_GSM_RST, LOW);
pinMode(IO_GSM_PWRKEY, OUTPUT);
digitalWrite(IO_GSM_PWRKEY, HIGH);
delay(3000);
digitalWrite(IO_GSM_PWRKEY, LOW);
SPI.begin(LORA_SCK, LORA_MISO, LORA_MOSI, LORA_CS);
// initialize SX1276 with default settings
Serial.print(F("[SX1276] Initializing ... "));
int state = radio.begin(FREQUENCY, BANDWIDTH, SPREADING_FACTOR, CODING_RATE, SX127X_SYNC_WORD, OUTPUT_POWER, PREAMBLE_LEN, GAIN);
// int state = radio.begin();
if (state == ERR_NONE)
{
Serial.println(F("success!"));
}
else
{
Serial.print(F("failed, code "));
Serial.println(state);
while (true);
}
Serial.print(F("Waiting for incoming transmission ... "));
String str;
int state = radio.receive(str);
// you can also receive data as byte array
/*
size_t len = 8;
byte byteArr[len];
int state = radio.receive(byteArr, len);
*/
if (state == ERR_NONE) {
// packet was successfully received
Serial.println(F("success!"));
// print data of the packet
Serial.print(F("Data:\t\t\t"));
Serial.println(str);
// print RSSI (Received Signal Strength Indicator)
// of the last received packet
Serial.print(F("RSSI:\t\t\t"));
Serial.print(radio.getRSSI());
Serial.println(F(" dBm"));
// print SNR (Signal-to-Noise Ratio)
// of the last received packet
Serial.print(F("SNR:\t\t\t"));
Serial.print(radio.getSNR());
Serial.println(F(" dB"));
// print frequency error
// of the last received packet
Serial.print(F("Frequency error:\t"));
Serial.print(radio.getFrequencyError());
Serial.println(F(" Hz"));
} else if (state == ERR_RX_TIMEOUT) {
// timeout occurred while waiting for a packet
//Serial.println(F("timeout!"));
} else if (state == ERR_CRC_MISMATCH) {
// packet was received, but is malformed
Serial.println(F("CRC error!"));
}
String numbers[10];
int extractNumbers(String input, String numbers[]) {
int count = 0;
String number = "";
for (int i = 0; i < input.length(); i++) {
char c = input.charAt(i);
...
Read more »
ThingSpeak Is The Open IoT Platform With MATLAB Analytics.
What you need are just:
Note: detect the soil moisture/air humidity/temperature and broadcast every 60 minutes.
This gateway is composed of ESP32S3 4G LTE A7670 module and A LoRa radio expansion
Note: LoRa communication needs the sender& receiver to work at the same frequency. The frequency of the LoRa Soil Moisture Sensor is 915MHz, so the frequency of the LoRa Expansion Board needs to be 915MHz as well.
Create an account to leave a comment. Already have an account? Log In.
Become a member to follow this project and never miss any updates