ESP32 project that automatically manages WiFi connections and sends sensor data to a server via HTTPS.
- Auto WiFi Management: Connects using saved credentials or opens a captive portal for setup
- HTTPS Data Transmission: Securely sends JSON data to your server with API key authentication
- Dual Data Streams: Sends both environmental data (temperature, humidity) and water quality data (pH, dissolved oxygen, etc.)
- Retry Logic: Automatically retries failed connections with exponential backoff
- Reset Function: Press EN button to clear saved WiFi credentials
- WiFi Setup: On first boot, creates "ESP32_AP" hotspot for WiFi configuration
- Auto Connect: Remembers WiFi settings and connects automatically on subsequent boots
- Data Collection: Reads sensor values (currently hardcoded for testing)
- HTTPS POST: Sends data to two endpoints:
/env_dataand/pond_data - Error Handling: Retries failed connections up to 4 times with increasing delays
Update these values in the code:
const char* server = "your-server.example.com";
const char* apiKey = "YOUR_API_KEY";- Environmental Monitoring: Temperature, humidity, pressure sensing
- Water Quality Monitoring: pH, dissolved oxygen, TDS measurement for ponds/aquariums
- IoT Data Logger: Any application requiring secure data transmission to a server
- Remote Monitoring: Monitor sensors from anywhere with internet connection
Environmental Data:
{
"api_key": "YOUR_API_KEY",
"sensor": "SHT20",
"Temperature": 22.3,
"Humidity": 55.2,
"Pressure": 0
}Water Quality Data:
{
"api_key": "YOUR_API_KEY",
"nitrogen": 0.0,
"ammonia": 0.0,
"do": 7.2,
"waterPH": 7.1,
"waterTemp": 26.4
}- Install required libraries:
WiFiManagerandArduinoJson - Update server URL and API key in the code
- Upload to ESP32
- Connect to "ESP32_AP" hotspot and configure WiFi
- WiFiManager - For easy WiFi configuration
- ArduinoJson - For JSON data formatting
- WiFiClientSecure - For HTTPS connections