Build a Machine Monitoring Node
The Story
Industrial monitoring starts by measuring one signal and proving one output. GPIO35 is input-only and belongs to ADC1, while GPIO19 controls the relay module input; the ESP32 pin never powers the relay coil or machine load. The component list, wiring table, GPIO map, code constants, expected output, troubleshooting, and FAQ now describe the same bench build so a learner can verify each step instead of guessing.
Explain Like I'm 12
The sensor makes a number that changes when current changes. If the number is higher than the threshold, GPIO19 tells the relay module input to switch. Prove the local wiring and code first, then add displays, logging, or Wi-Fi after the simple version behaves exactly as expected.
Safety Standards
- Unplug USB before changing jumper wires. Recheck 3.3 V, 5 V, and GND before reconnecting power.
- Do not power motors, pumps, LED strips, or servos from the ESP32 3.3 V pin. Use a suitable external supply and common ground.
- Breadboards are for low-current prototypes. Move high-current or unattended builds to proper terminals, enclosure, strain relief, and fusing.
- Relay and mains-voltage projects require isolation, correct relay ratings, enclosed wiring, and qualified adult supervision.
What You Will Build
A bench-safe monitor that reads an analog current-sensor signal on ADC1 GPIO35 and drives a low-voltage relay module input from GPIO19.
Learning Objectives
- Wire the exact GPIO pins used by the sketch.
- Run the starter code and compare output with the wiring table.
- Explain the main sensor or input signal in plain language.
- Troubleshoot one wiring mistake using Serial Monitor evidence.
Components List
- ESP32 DevKit boardReads ADC1 GPIO35 and controls GPIO19.
- Analog current sensor moduleProvides the monitored analog signal within ESP32-safe limits.
- Relay moduleLow-voltage demo output controlled from GPIO19; isolate real loads properly.
- Jumper wiresKeep signal wiring short and inspectable.
Bill of Materials
| Part | Qty | Estimated Cost | Notes |
|---|---|---|---|
| ESP32 DevKit board | 1 | Varies | Reads ADC1 GPIO35 and controls GPIO19. |
| Analog current sensor module | 1 | Varies | Provides the monitored analog signal within ESP32-safe limits. |
| Relay module | 1 | Varies | Low-voltage demo output controlled from GPIO19; isolate real loads properly. |
| Jumper wires | 1 | Varies | Keep signal wiring short and inspectable. |
Wiring
A bench-safe monitor that reads an analog current-sensor signal on ADC1 GPIO35 and drives a low-voltage relay module input from GPIO19.
-
1
Unplug USB and any relay supply before rewiring.
-
2
Connect the current sensor signal output to GPIO35.
-
3
Connect the sensor VCC and GND according to the module label and ESP32-safe output requirements.
-
4
Connect relay module IN to GPIO19.
-
5
Connect relay module GND to ESP32 GND and provide the relay module supply required by the module.
-
6
Reconnect power and test with Serial Monitor before attaching any real load.
GPIO Mapping
| Signal | ESP32 Pin | Direction | Notes |
|---|---|---|---|
| Current sensor signal | GPIO35 | Input | ADC1 input-only pin; analogRead only. |
| Relay module IN | GPIO19 | Output | Logic control signal. |
| GND | GND | Ground | Common reference. |
Circuit Explanation
GPIO35 reads the current-sensor signal. GPIO19 changes state when the reading exceeds THRESHOLD.
Engineering Explanation
The sketch threshold is 1813 ADC counts from the imported source and must be calibrated. ADC1 is used so later Wi-Fi logging avoids ADC2 conflicts.
Libraries
- Arduino ESP32 coreInstall ESP32 board support in Arduino IDE.
Code
Copy into Arduino IDE. Install any libraries noted in the component guides first.
// ESP32 Machine Monitoring Node for Plant Floor with Cloud Sync
const int SENSOR_PIN = 35;
const int OUTPUT_PIN = 19;
const int THRESHOLD = 1813;
const int SAMPLE_DELAY_MS = 300;
void setup() {
Serial.begin(115200);
pinMode(OUTPUT_PIN, OUTPUT);
pinMode(SENSOR_PIN, INPUT);
Serial.println("Starting: machine monitoring node for plant floor with cloud sync");
Serial.print("Threshold: ");
Serial.println(THRESHOLD);
}
void loop() {
int reading = analogRead(SENSOR_PIN);
Serial.print("Current Sensor signal: ");
Serial.println(reading);
bool active = reading < THRESHOLD;
digitalWrite(OUTPUT_PIN, active ? HIGH : LOW);
delay(SAMPLE_DELAY_MS);
}
Code Explanation
SENSOR_PIN is GPIO35 and OUTPUT_PIN is GPIO19. loop() reads analog current, compares it with THRESHOLD, switches the relay signal, and prints the reading.
Expected Output
Serial Monitor prints current-sensor ADC readings about every 300 ms. Readings above 1813 turn GPIO19 on; readings at or below 1813 turn it off.
Troubleshooting
- Relay chatters Calibrate with real readings and add hysteresis before using the output.
- Reading is always 0 or 4095 Check sensor power, signal range, and GPIO35 wiring.
- Relay never switches Confirm relay IN is on GPIO19 and the module has its required supply.
Common Mistakes
- Trying to use GPIO35 as an output.
- Assuming 1813 is calibrated for every sensor.
- Connecting unsafe relay loads to a breadboard.
Testing Checklist
- Upload the sketch with only the documented circuit attached.
- Open Serial Monitor and confirm the expected messages.
- Move or trigger the input and watch the output change.
- Power-cycle the project and confirm it starts safely.
Engineering Tips
- Change one variable at a time.
- Keep wires short and labeled while testing.
- Record any calibrated threshold before installing the project.
Upgrade Ideas
- Add hysteresis and averaging.
- Publish calibrated readings to MQTT.
- Add an OLED status screen.
Real-World Applications
- Classroom lab build
- Bench prototype
- Local ESP32 learning project
FAQs
Why use GPIO35?
GPIO35 is ADC1 input-only, which is appropriate for analog monitoring.
Can this switch mains equipment?
Only with proper relay ratings, enclosure, strain relief, fusing, and qualified supervision.
Is 1813 universal?
No. It is a starter threshold that must be calibrated.
Review, Testing, and References
Author: Abdul Mubeen and the ESP32 Engine editorial team. Last updated: 2026-06-18. Reviewed: wiring logic, Arduino code structure, beginner safety, and learning sequence.
Educational level: Intermediate. Estimated completion time: 90-120 min. This project is for learning and prototyping; production or unattended hardware needs additional engineering review.
Project Complete!
You completed ESP32 Machine Monitoring Node as a real ESP32 engineering build with matching wiring, code, testing, and troubleshooting.
- Read the GPIO map
- Verify code against hardware
- Troubleshoot with Serial Monitor
