Robojax

Send Temperature to over 1.4km using Wifi LoRa ESP32 | Robojax

Send Temperature to over 1.4km using Wifi LoRa ESP32 | Robojax

Please select other codes for this lecture from the links below.

Related or required files and link to this lesson

Transmitter Code to send DHT22 Temperature WiFi LoRa 32 ESP32 V3

As explained in the video, this code is to help you display Temperature, or Humidity on the itself and transmit it over LoRa RF band to killimeters away. Make sure to set the security key and set the TX Power. The TX_POWER can be set between 2 to 21. The value is dBm, the higher the the value the longer the range and the shorter the battery life if powering it using battery. See video for full details and 2dBm vs mW.

Projects in this video

In Project 1: Dispaly a simpe text on OLED display

Timing of chapters in the video

00:00 Start
3:51 Specs
8:32 Documentation page
9:52 Package
12:58 Powering it up
16:37 Installing Library
18:19 Transmitter Basic code
19:43 Receiver Basic Code
20:39 Demonstration of sending receiving text
23:02 OLED demo code
24:06 Basic Text on OLED display code
26:26 Basic Text on OLED demo
26:58 Reading temperature with DHT22
28:49 LoRa Transmitter Temperature and Display
30:07 LoRa Receiver Temperature and Display
32:13 Triggering LED when temperature increases
22:26 LoRa Transmission Range Test
35:01 dBM and Milli Watt

 /*
This is a simple code to display text on the OLED display
WiFi LoRa 32 V3 ESP32 module
Written by Ahmad Shamshiri 02 April 2025
Watch full video explaination https://youtu.be/WkyQMXkQhE8
*/
#include <Wire.h>               
#include "HT_SSD1306Wire.h"


static SSD1306Wire  display(0x3c, 500000, SDA_OLED, SCL_OLED, GEOMETRY_128_64, RST_OLED); // addr , freq , i2c group , resolution , rst


void setup() {
  Serial.begin(115200);
  Serial.println();
  Serial.println();
  VextON();
  delay(100);

  // Initialising the UI will init the display too.
  display.init();

  display.setFont(ArialMT_Plain_10);

}


void displayTemperature(double temperature, int unit) {
    display.clear();  // Clear display before new content
    
    // Line 1: "Temperature:" in 16pt font
    display.setTextAlignment(TEXT_ALIGN_LEFT);
    display.setFont(ArialMT_Plain_16);
    display.drawString(0, 0, "Temperature:");

    // Line 2: Temperature value in 24pt font
    display.setFont(ArialMT_Plain_24);
    
    // Format temperature with correct unit symbol
    String tempString = String(temperature, 1); // 1 decimal place
    switch(unit) {
        case 1:  tempString += "�C"; break;  // Celsius
        case 2:  tempString += "�F"; break;  // Fahrenheit
        default: tempString += "�U"; break;  // Unknown unit
    }
    
    display.drawString(0, 20, tempString);  // Display at Y=20 (below label)
    display.display();  // Update OLED
}



void VextON(void)
{
  pinMode(Vext,OUTPUT);
  digitalWrite(Vext, LOW);
}

void VextOFF(void) //Vext default OFF
{
  pinMode(Vext,OUTPUT);
  digitalWrite(Vext, HIGH);
}



void loop() {
  // clear the display
  display.clear();
  displayTemperature(23.5, 1); // Displays "23.5�C" /1
  delay(2000);

}