Blinking LED Circuit Design
Table
| J2 Pin | Signal | ESP32 Firmware Function |
|---|---|---|
| 1 | 3.3V | Power supplied by ESP32 board/regulator |
| 2 | GND | Common ground |
| 3 | ADS1115 SDA | I2C SDA GPIO |
| 4 | ADS1115 SCL | I2C SCL GPIO |
| 5 | DS18B20 DQ | 1-Wire GPIO |
Cpp
#include <Wire.h> #include <Adafruit_ADS1X15.h> #include <OneWire.h> #include <DallasTemperature.h> // Set these to the actual ESP32 pins used with J2. static const int PIN_I2C_SDA = 8; static const int PIN_I2C_SCL = 9; static const int PIN_ONEWIRE_DQ = 10; Adafruit_ADS1115 ads; OneWire oneWire(PIN_ONEWIRE_DQ); DallasTemperature ds18b20(&oneWire); float readAdsDiffMv(uint8_t mux) { int16_t raw = 0; if (mux == 0) raw = ads.readADC_Differential_0_1(); // pH else raw = ads.readADC_Differential_2_3(); // ORP // Adjust multiplier to match selected ADS1115 gain. // For GAIN_ONE on Adafruit ADS1X15, scale is commonly 0.125 mV/bit. return raw * 0.125f; } float filteredAdsMv(uint8_t mux) { const int N = 15; float sum = 0; for (int i = 0; i < N; i++) { sum += readAdsDiffMv(mux); delay(20); } return sum / N; } void setup() { Serial.begin(115200); Wire.begin(PIN_I2C_SDA, PIN_I2C_SCL); ds18b20.begin(); if (!ads.begin(0x48)) { Serial.println("ADS1115 not found at 0x48"); while (true) delay(1000); } ads.setGain(GAIN_ONE); // confirm range/noise tradeoff for ORP ads.setDataRate(RATE_ADS1115_128SPS); } void loop() { ds18b20.requestTemperatures(); float tempC = ds18b20.getTempCByIndex(0); float phMv = filteredAdsMv(0); float orpMv = filteredAdsMv(1); // TODO: replace with calibrated conversion. float ph = phMv; // placeholder float orp = orpMv; // mV before calibration offset Serial.printf("T=%.2f C, pH_raw=%.3f mV, ORP_raw=%.3f mV\n", tempC, phMv, orpMv); delay(1000); }
Hardware Interface
Libraries
ADS1115 Settings
Example Arduino-Style Skeleton
Calibration Notes
Simulation-Based Limits