LongReach (LoRa) Environmental Sensor (HCMODU0252)

LoRa based products
Post Reply
admin
Site Admin
Posts: 884
Joined: Sun Aug 05, 2012 4:02 pm

LongReach (LoRa) Environmental Sensor (HCMODU0252)

Post by admin » Sat May 10, 2025 8:23 am

Image


Image

The Longreach environmental sensor is a LoRa-based wireless transmitter that can automatically report temperature, humidity, pressure, and light levels (ambient & white) from a remote location. Being LoRa based it is able to transmit its sensor reading over exceptionally long distances (>1 kilometer in free space) far beyond common WiFi and Bluetooth based sensors. No programming skills are required to use this module, simply connect power via its microUSB socket and the module will automatically start transmitting its sensor readings at set intervals.

Note: To receive the sensor reading you will need a compatible LongReach module. For example, to receive the sensor readings to a computer you can use a LongReach USB module (SKU: HCMODU0251), or to receive them to a microcontroller such as an Arduino you will need a LongReach mLink module (SKU: HCMODU0250). See below for examples.



Image



Specification:
Product code: HCMODU0252
Supply Voltage: 5V via microUSB connector or solder pads
Supply current: 9.8mA (idle), 150mA (Tx)
Radio Type: LoRa RM95
Range: >1 kilometre in free air
Frequency: 905MHz
Re-transmit period: 10 to 2560 seconds (default 60s)
Re-transmit accuracy: 0.5% @25oC
Address range: 0 to 255
Temp sensor range: -40 to 85oC
Temp sensor resolution: 0.01oC
Hum sensor range: 0 to 100%RH
Hum sensor resolution: 0.024%RH
Pressure sensor range: 300 to 1100hPa / mBar
Pressure sensor resolution: 0.01hPa / mBar
Light sensor range: 0 to 35232lx
Light sensor resolution: 0.54lx




Sensor output:
By default, the module sends all sensor readings to any compatible LongReach receiver once every 60 seconds. This interval can be adjusted by the user (see setting the re-transmit time section below). A compatible LongReach receiver will receive the sensor readings in a readable ASCII format, as shown:

TMP=<temp>

Where <temp> is a temperature sensor reading to 2 decimal places in oC. Values can range from -40.00 to 80.00.


HUM=<hum>

Where <hum> is a humidity sensor reading to 2 decimal places in %RH. Values can range from 0.00 to 100.00.


PRS=<pres>

Where <pres> is a barometric pressure sensor reading to 2 decimal places in hPa/mBar. Values can range from 300.00 to 1100.00.


LXA=<amb>

Where <amb> is an ambient light sensor reading to 2 decimal places in lux. Values can range from 0.00 to 35232.00.


LXW=<wht>

Where <wht> is a white light sensor reading to 2 decimal places in lux. Values can range from 0.00 to 35232.00.





Image

Receiving sensor readings with a microcontroller (Arduino):


Image



To receive the sensor readings using an Arduino you will need a mLink Longreach module (SKU: HCMODU0250) connected to your Arduino and the mLink library installed.

Image


  1. #include "mLink.h"                // Include the mLink library
  2.  
  3. mLink mLink;                      // Create an instance of the mLink class
  4.  
  5. #define I2C_ADD 0x5F              // Default I2C address for the mLink module
  6.  
  7. char rxBuffer[32];               // Buffer to hold incoming message (up to 32 characters)
  8.  
  9. // Variables to store the sensor values
  10. float temperature, humidity, pressure, lightAmbient, lightWhite;
  11.  
  12.  
  13.  
  14. void setup()
  15. {
  16.   Serial.begin(9600);          // Start the serial monitor
  17.  
  18.   mLink.init();                  // Initialize the mLink module
  19.  
  20.   // Enable LongReach mode
  21.   mLink.LORA_LR_Mode(I2C_ADD, LR_MODE_ON);
  22.   // Set to continuously receive data
  23.   mLink.LORA_Mode(I2C_ADD, LORA_MODE_RXCONTINUOUS);
  24.  
  25.   Serial.println("Listening for sensor data...");
  26. }
  27.  
  28.  
  29.  
  30. void loop()
  31. {
  32.   // Check if data has been received
  33.   if (mLink.LORA_Rx_Available(I2C_ADD))
  34.   {
  35.     // Get the number of bytes received
  36.     byte size = mLink.LORA_Rx_Size(I2C_ADD);
  37.     if (size > 32) size = 32;
  38.  
  39.     // Read the new data
  40.     mLink.LORA_Rx_Read(I2C_ADD, size, rxBuffer);
  41.  
  42.  
  43.     // Check which type of sensor data was received and print it out
  44.     if(checkSensor("TMP=", rxBuffer))
  45.     {
  46.       temperature = getSensorVal(rxBuffer);
  47.       Serial.print("Temperature = ");
  48.       Serial.println(temperature);
  49.     }
  50.     else if(checkSensor("HUM=", rxBuffer))
  51.     {
  52.       humidity = getSensorVal(rxBuffer);
  53.       Serial.print("Humidity = ");
  54.       Serial.println(humidity);
  55.     }
  56.     else if(checkSensor("PRS=", rxBuffer))
  57.     {
  58.       pressure = getSensorVal(rxBuffer);
  59.       Serial.print("Pressure = ");
  60.       Serial.println(pressure);
  61.     }
  62.     else if(checkSensor("LXA=", rxBuffer))
  63.     {
  64.       lightAmbient = getSensorVal(rxBuffer);
  65.       Serial.print("Ambient Light = ");
  66.       Serial.println(lightAmbient);
  67.     }
  68.     else if(checkSensor("LXW=", rxBuffer))
  69.     {
  70.       lightWhite = getSensorVal(rxBuffer);
  71.       Serial.print("White Light = ");
  72.       Serial.println(lightWhite);
  73.       Serial.println();
  74.     }
  75.   }
  76. }
  77.  
  78.  
  79. // Checks the first 4 characters of the received
  80. // message to see which sensor it is
  81. boolean checkSensor(char *sensor, byte *buffer)
  82. {
  83.   return strncmp(buffer, sensor, 4)  == 0;
  84. }
  85.  
  86. // Converts the measurment part of the message
  87. // to a floating point number
  88. float getSensorVal(byte *buffer)
  89. {
  90.   return atof(buffer + 4);
  91. }

Image

mLink library: viewtopic.php?f=58&t=3001




Image

Receiving sensor readings to a Raspberry Pi

Image


When connecting to a Raspberry Pi the mLink modules I2C pullup resistors should be removed. See the 'Removing the modules I2C pullup resistors' section below for more information.


  1. from mLink import mLink                             # Import the mLink module
  2. import time
  3.  
  4. ml = mLink.mLink(1)                                 # Create an instance of the module
  5.  
  6. I2C_ADD = 0x5F                                      # Default I2C address is 0x5F
  7.  
  8.  
  9.  
  10. ml.LORA_LR_Mode(I2C_ADD, ml.LR_MODE_ON)             # Put the module into LongReach mode
  11. ml.LORA_Mode(I2C_ADD, ml.LORA_MODE_RXCONTINUOUS)    # Put module into continuous receive mode
  12.  
  13.  
  14. while 1:
  15.     avail = ml.LORA_Rx_Available(I2C_ADD)           # Check for new data
  16.    
  17.     if avail:
  18.         size = ml.LORA_Rx_Size(I2C_ADD)             # Get the size in bytes of the new data
  19.         message = ml.LORA_Rx_Read(I2C_ADD, size)    # Read out the message
  20.        
  21.         sMessage = ''.join(map(chr, message))       # Convert message from list to string
  22.        
  23.        
  24.         # If message starts with "TMP=" it's a temperature measurement
  25.         if sMessage[:4] == "TMP=":                     
  26.             temperature = float(sMessage[4:])
  27.             print("Temperature = ", temperature)
  28.        
  29.         # If message starts with "HUM=" it's a humidity measurement
  30.         elif sMessage[:4] == "HUM=":
  31.             humidity = float(sMessage[4:])
  32.             print("Humidity = ", humidity)
  33.  
  34.         # If message starts with "PRS=" it's a pressure measurement
  35.         elif sMessage[:4] == "PRS=":
  36.             pressure = float(sMessage[4:])
  37.             print("Pressure = ", pressure)
  38.        
  39.         # If message starts with "LXA=" it's an ambient light measurement
  40.         elif sMessage[:4] == "LXA=":
  41.             ambientLight = float(sMessage[4:])
  42.             print("Ambient Light = ", ambientLight)
  43.        
  44.         # If message starts with "LXW=" it's a white light measurement
  45.         elif sMessage[:4] == "LXW=":
  46.             whitetLight = float(sMessage[4:])
  47.             print("White Light = ", whitetLight, "\n")
  48.  
  49.        
  50.     time.sleep(0.1)




Image

Image


To run this example, you’ll need a LongReach USB module connected to your PC to receive sensor readings. You’ll also need a serial terminal program to view the data. In this example, we’re using YAT (Yet Another Terminal).


Step 1: Connect to the Module
Open your terminal program and connect to the USB module’s serial port using a baud rate of 9600.


Step 2: Enable LongReach Mode
Type the following AT command into the terminal to enable LongReach mode:

AT+LRM=ON

Note: The command must be terminated with a Line Feed (LF) and Carriage Return (CR). Some terminal programs handle this automatically, depending on their settings. Make sure your terminal is configured correctly.

If the command is accepted, the module will reply with:

OK


Step 3: View Sensor Readings
Once the module is in LongReach mode, the terminal program will begin displaying any received sensor readings automatically.


Image




Image


Dimensions:

Image





Setting the re-transmit time:

By default the module will transmit the sensor readings once every minute. This time can be set by the user from 10 seconds to 2560 seconds in 10 second increments. To change the re-transmit time perform the following steps:


Step 1)
Download the following PDF file containing a lookup table of switch settings. Use this table to find the switch settings for your required re-transmit time.

https://hobbycomponents.com/images/foru ... Lookup.pdf


Step 2)
With power removed from the module, set the module's 8 dip switches to match the ones shown in the lookup table.


Step 3)

Image

Use a wire or paperclip to link the GND & T-A pads together as shown above.


Step 4)
With the pads still linked, connect power to the module.


Step 5)
Remove power from the module and set the dip switched back to their original state, or wherever address you require.


The module will now transmit sensor readings with the new re-transmit interval. The new interval will be stored in the modules non-volatile memory so only needs to be done once.






Disclaimer:
As with all wireless devices, external factors such as range and interference may cause transmissions to be corrupted or blocked. Therefore these devices should not be used in applications where control or monitoring is a critical requirement.

Libraries, example code, and diagrams are provided as an additional free service by Hobby Components and are not sold as part of this product. We do not provide any guarantees or warranties as to their accuracy or fitness for purpose.

Post Reply

Return to “LoRa (TM)”