Try   HackMD

Here’s a full overview of how to build a LoRa-based temperature sensor — perfect for remote IoT applications like smart farming, warehouse monitoring, or environmental tracking.

Image Not Showing Possible Reasons
  • The image was uploaded to a note which you don't have access to
  • The note which the image was originally uploaded to has been deleted
Learn More →

LoRa-Based Temperature Sensor: Project Overview
What It Does:
A temperature sensor (e.g., DS18B20 or DHT22) measures ambient temperature. A microcontroller reads this data and transmits it via a LoRa module (e.g., SX1276/RFM95) to a remote LoRa gateway or receiver node.

Hardware Components

Image Not Showing Possible Reasons
  • The image was uploaded to a note which you don't have access to
  • The note which the image was originally uploaded to has been deleted
Learn More →

Hardware Connection (Example: Arduino + RFM95 + DS18B20)

Image Not Showing Possible Reasons
  • The image was uploaded to a note which you don't have access to
  • The note which the image was originally uploaded to has been deleted
Learn More →

DS18B20 (with pull-up resistor):

  • VCC → 3.3V / 5V
  • GND → GND
  • DATA → D7 (with 4.7kΩ pull-up to VCC)

Sample Code (Arduino Framework)
Using:

  • OneWire & DallasTemperature for DS18B20
  • LoRa library (by Sandeep Mistry)
cpp

#include <SPI.h>
#include <LoRa.h>
#include <OneWire.h>
#include <DallasTemperature.h>

// LoRa Pins
#define SS 10
#define RST 9
#define DIO0 2

// Temperature Sensor Pin
#define ONE_WIRE_BUS 7

OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);

void setup() {
  Serial.begin(9600);
  sensors.begin();

  LoRa.setPins(SS, RST, DIO0);
  if (!LoRa.begin(915E6)) {
    Serial.println("LoRa init failed.");
    while (1);
  }
  Serial.println("LoRa init OK.");
}

void loop() {
  sensors.requestTemperatures();
  float tempC = sensors.getTempCByIndex(0);

  Serial.print("Sending: ");
  Serial.println(tempC);

  LoRa.beginPacket();
  LoRa.print("Temp: ");
  LoRa.print(tempC);
  LoRa.endPacket();

  delay(5000); // Send every 5 seconds
}

Receiving Side (LoRa Receiver Node)
Another Arduino or ESP32 running:

cpp

#include <SPI.h>
#include <LoRa.h>

void setup() {
  Serial.begin(9600);
  LoRa.setPins(10, 9, 2);
  if (!LoRa.begin(915E6)) {
    Serial.println("Starting LoRa failed!");
    while (1);
  }
}

void loop() {
  int packetSize = LoRa.parsePacket();
  if (packetSize) {
    String received = "";
    while (LoRa.available()) {
      received += (char)LoRa.read();
    }
    Serial.print("Received: ");
    Serial.println(received);
  }
}

Notes

  • Adjust frequency to 868E6 or 433E6 depending on your region.
  • Add sleep mode (e.g., LowPower.h) for battery-powered nodes.
  • You can use STM32 or ESP32 instead of Arduino (What is Arduino?) for better performance or wireless networking.
  • You can expand to use LoRaWAN and send data to TTN (The Things Network) or a Raspberry Pi LoRa Gateway.

Optional Add-ons

Image Not Showing Possible Reasons
  • The image was uploaded to a note which you don't have access to
  • The note which the image was originally uploaded to has been deleted
Learn More →