info.txt 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. ESP32 Weather Station Project Information
  2. ==========================================
  3. Project Overview:
  4. -----------------
  5. This is a comprehensive weather monitoring system built on ESP32 microcontroller
  6. with multiple environmental sensors and MQTT connectivity for IoT integration.
  7. Hardware Components:
  8. -------------------
  9. - ESP32 Development Board (main controller)
  10. - DHT11 Temperature & Humidity Sensor
  11. - BMP180 Atmospheric Pressure Sensor
  12. - Rain Sensor Module (analog)
  13. - LDR (Light Dependent Resistor)
  14. - 16x2 I2C LCD Display
  15. - LED (Status Indicator for light detection)
  16. - Breadboard and Jumper Wires
  17. Pin Configuration:
  18. ------------------
  19. - DHT11 Sensor: Pin 4
  20. - LDR Sensor: Pin 35 (input only pin)
  21. - Rain Sensor: Pin 34 (analog pin)
  22. - Status LED: Pin 2
  23. - I2C LCD (SDA): Pin 21
  24. - I2C LCD (SCL): Pin 22
  25. Software Features:
  26. -----------------
  27. - Real-time sensor data collection with timed intervals
  28. - Temperature, humidity, pressure, rain, and light monitoring
  29. - Live LCD display of weather data
  30. - WiFi connectivity for network access
  31. - MQTT client for data publishing
  32. - Automatic MQTT reconnection with random client ID
  33. - JSON data format for MQTT messages
  34. - Error handling and status indication
  35. - Serial output for debugging (115200 baud)
  36. - LED status indicator synchronized with LDR readings
  37. Code Structure:
  38. --------------
  39. - Modular sensor reading functions
  40. - Structured WeatherData for data management
  41. - Non-blocking timer-based operations
  42. - Automatic WiFi connection with timeout
  43. - MQTT client with reconnection logic
  44. - LCD display formatting and error messages
  45. MQTT Configuration:
  46. ------------------
  47. - Broker: Configurable server address
  48. - Port: 1883 (default)
  49. - Topic: weather/station (configurable)
  50. - Data Format: JSON
  51. - Client ID: Auto-generated (ESP32WeatherStation-XXXX)
  52. - Authentication: None (configurable)
  53. Sensor Reading Schedule:
  54. ------------------------
  55. - All sensors read: Every 2 seconds (2000ms)
  56. - MQTT data published: Every 30 seconds (30000ms)
  57. - LCD display updated: Every 2 seconds
  58. - LED status: Updated with each sensor read
  59. - Serial output: With each sensor reading
  60. Technical Specifications:
  61. ------------------------
  62. - Microcontroller: ESP32 (Dual Core, 240MHz)
  63. - Memory: 520KB SRAM, 4MB Flash
  64. - Wireless: WiFi 802.11 b/g/n
  65. - Sensors: DHT11 (±2°C, ±5%RH), BMP180 (±1hPa), Rain sensor, LDR
  66. - Display: 16x2 Character LCD with I2C interface (0x27)
  67. - Power: 5V via USB or external supply
  68. - Communication: I2C, WiFi, MQTT
  69. Development Environment:
  70. ----------------------
  71. - PlatformIO with ESP32 framework
  72. - Arduino IDE compatible
  73. - Libraries: DHT, LiquidCrystal_I2C, SFE_BMP180, PubSubClient
  74. MQTT Data Format:
  75. -----------------
  76. ```json
  77. {
  78. "temperature": 23.45,
  79. "humidity": 67.89,
  80. "pressure": 1013.25,
  81. "rainLevel": 15,
  82. "lightDetected": true
  83. }
  84. ```
  85. LCD Display Format:
  86. ------------------
  87. Line 1: "T:23.4C H:67%"
  88. Line 2: "R:15% P:1013"
  89. Serial Output Format:
  90. -------------------
  91. "Temp: 23.45°C, Humidity: 67.89%, Rain: 15%, Pressure: 1013.25 hPa, Light: YES"
  92. Installation Instructions:
  93. ------------------------
  94. 1. Connect hardware according to pin configuration
  95. 2. Set up MQTT broker (Mosquitto, HiveMQ, AWS IoT, etc.)
  96. 3. Update WiFi credentials (ssid, password) in sketch
  97. 4. Update MQTT broker settings (mqtt_server, mqtt_port, mqtt_topic)
  98. 5. Upload firmware using PlatformIO or Arduino IDE
  99. 6. Monitor serial output at 115200 baud rate
  100. 7. Subscribe to MQTT topic to receive weather data
  101. MQTT Broker Setup:
  102. -----------------
  103. 1. Install Mosquitto broker or use cloud service
  104. 2. Configure broker for client connections on port 1883
  105. 3. Create topic structure: weather/station (or custom)
  106. 4. Test broker connectivity with MQTT client tools
  107. 5. Configure firewall if using local broker
  108. 6. Verify broker allows anonymous connections or add auth
  109. Troubleshooting:
  110. ---------------
  111. - Check wiring connections if sensors return errors
  112. - Verify WiFi credentials if connection fails
  113. - Ensure MQTT broker is accessible and running
  114. - Check MQTT broker address and port
  115. - Verify topic permissions on broker
  116. - Check I2C address (default 0x27) for LCD
  117. - Use external power supply if sensors are unstable
  118. - Check analog pin assignments for rain sensor (Pin 34)
  119. - Monitor serial output for detailed error messages
  120. - Verify BMP180 sensor initialization
  121. - Check DHT11 sensor readings for NaN values
  122. Code Constants and Variables:
  123. ----------------------------
  124. - sensorInterval: 2000ms (sensor reading frequency)
  125. - mqttInterval: 30000ms (MQTT publish frequency)
  126. - WiFi connection attempts: 20 (10 seconds total)
  127. - MQTT reconnection delay: 5 seconds
  128. - Rain sensor mapping: 0-4095 to 0-100% (inverted)
  129. - LDR reading: Digital (HIGH/LOW)
  130. - Pressure oversampling: 3 (BMP180)
  131. Project Status:
  132. --------------
  133. Version: 3.0.0 (MQTT Edition)
  134. Last Updated: May 2026
  135. Author: Weather Station Team
  136. License: Open Source
  137. Additional Notes:
  138. ---------------
  139. - MQTT provides flexible IoT integration options
  140. - JSON format allows easy data processing and parsing
  141. - Rain sensor values are inverted and mapped to percentage (0-100%)
  142. - LDR provides digital light detection (HIGH=light detected, LOW=no light)
  143. - LED indicates light detection status (ON when light detected)
  144. - LCD shows formatted sensor data locally with error messages
  145. - System requires WiFi connection for MQTT functionality
  146. - Automatic reconnection ensures reliable data transmission
  147. - All sensor data available via MQTT subscription
  148. - Non-blocking code design prevents system hangs
  149. - Modular structure allows easy sensor additions