Installation & Device Setup

Complete guide for setting up and configuring your ESP32 LoRaWAN water quality monitoring devices.

Prerequisites

Arduino IDE
For ESP32 development and code upload
Download Arduino IDE →
TTN Account
The Things Network for LoRaWAN backend
Create TTN Account →
LoRaWAN Gateway
Use public TTN gateways in your area or deploy your own

Hardware Requirements

ESP32 LoRaWAN Device:
• ESP32 Development Board (30-pin)
• LoRaWAN Module (SX1276/SX1278 - 868/915 MHz)
• pH Sensor with analog probe
• TDS (Total Dissolved Solids) sensor
• DS18B20 waterproof temperature probe
• OLED Display (128×64 SSD1306, I²C)
Additional Components:
• USB Cable (Type-C or Micro-USB) for programming
• LiPo 3.7V battery + TP4056 charger (optional)
• 4.7 kΩ resistor (for DS18B20 pull-up)
• Jumper wires for connections
• Breadboard or PCB for assembly
• Waterproof enclosure (for outdoor deployment)

Arduino IDE Setup for ESP32

1. Add ESP32 Board Manager

• Open Arduino IDE → File → Preferences

• In "Additional Board Manager URLs" add:

https://dl.espressif.com/dl/package_esp32_index.json

2. Install ESP32 Boards

• Go to Tools → Board → Boards Manager

• Search for "ESP32" and install "ESP32 by Espressif Systems"

• Wait for installation to complete

3. Install Required Libraries

Go to Tools → Manage Libraries and install the following:

MCCI LoRaWAN LMIC
For LoRaWAN communication
Required
OneWire
For DS18B20 temperature sensor
Required
DallasTemperature
DS18B20 temperature library
Required
Adafruit SSD1306
For OLED display
Required
Adafruit GFX Library
Graphics library for display
Required
ArduinoJson
For JSON payload handling
Optional

4. Configure LMIC Library for Region

⚠️ Important: Region Configuration Required

BEFORE uploading code, you must configure the LMIC library for your LoRaWAN frequency region.

📍 For India Region (IN866):

  1. Navigate to: My Documents > Arduino > libraries > MCCI_LoRaWAN_LMIC_library > project_config
  2. Open lmic_project_config.h using Notepad or any text editor
  3. Find the line: #define CFG_us915 1
  4. Comment it out by adding // at the beginning: // #define CFG_us915 1
  5. Find the line: // #define CFG_in866 1
  6. Uncomment it by removing //: #define CFG_in866 1
  7. Save and close the file

Other Regions:

Europe/India: Use CFG_eu868 or CFG_in866
United States: Use CFG_us915
Asia-Pacific: Use CFG_as923
Australia: Use CFG_au915

Only ONE region should be enabled at a time. Make sure all other regions are commented out.

Board Configuration

Before uploading code, configure Arduino IDE settings for your ESP32:

Board:ESP32 Dev Module
Upload Speed:921600
CPU Frequency:240MHz (WiFi/BT)
Flash Size:4MB (32Mb)
Partition Scheme:Default 4MB
Port:COM3 (or your ESP32 port)

Installation Complete!

Your development environment is now ready.

Next, review the circuit diagram to understand hardware connections, then use the code generator to create your custom Arduino sketch.