Posted on — Leave a comment

Control a 5V relay module safely with ESP32 (low voltage only)

By EEDIY Team. Difficulty ★★ · Written with electricians and beginners in mind Low voltage only. This tutorial switches a small DC load such as an LED strip on its own adapter. Do not connect mains (120/240 V) loads.

What you need

  • ESP32 board (set up with the LED blink post)
  • 1 relay module rated for a 5 V supply. A module is a relay plus a driver circuit on one small board
  • Jumper wires
  • A low-voltage DC load (for example a 5 V or 12 V LED strip) with its own power adapter
  • Multimeter (optional, to check connections)
Words to know
  • Relay: A relay is an electrically operated switch: current through a coil pulls the contacts (e.g. Songle SRD-05VDC: 5 V coil, about 71 mA). That’s more than an ESP32 pin can supply (about 40 mA on the C6), and the coil kicks back a voltage spike when switched off, so it needs a transistor driver and a flyback diode. A relay module includes both. (The C6 datasheet lists a typical 40 mA source current at the strongest drive setting. The default drive strength is 20 mA on most pins.)
  • COM / NO / NC: the relay’s switch terminals: common, normally open (connected only when the relay is on), and normally closed.
  • Flyback diode: a diode that absorbs the coil’s turn-off spike. TE’s relay coil suppression note says a 12 VDC relay may generate 1,000 to 1,500 V at turn-off without suppression. Example driver chip: TI’s ULN2003A has these diodes built in.

Why use a module, not a bare relay?

A relay coil needs a driver circuit, and dedicated relay-driver chips such as the ULN2003A include clamp diodes for inductive loads. A module puts the driver next to the relay. Check your module’s documentation for what it includes. The ESP32 works at 3.3 V (the ESP32-C6 datasheet recommends a 3.0-3.6 V supply), so check that your module’s input accepts a 3.3 V control signal. If your module’s documentation asks for a 5 V input signal, choose a different module or ask on the forum. Caution: some active-low optocoupler modules have their input pulled up to 5 V. A 3.3 V “high” may not fully switch them off. Prefer modules rated for a 3.3 V input. Tip for active-low modules: call digitalWrite(RELAY_PIN, HIGH); before pinMode(RELAY_PIN, OUTPUT); in setup() to help avoid a click at boot.

Step 1: Read your module’s label and documentation

Find the VCC, GND and IN pins, and whether the input is “active high” or “active low”.

Step 2: Wire the control side

  1. Module VCC to the board’s 5V pin (or the supply named in the module’s documentation).
  2. Module GND to ESP32 GND.
  3. Module IN to a GPIO. The example uses GPIO 18, which is not a strapping pin on the classic ESP32 or the ESP32-C6. Avoid strapping pins: a relay module connected to one can affect how the board boots.

Step 3: Wire the load side (low voltage only)

  1. Unplug the load’s adapter.
  2. Run one wire of the load through COM and NO, so the relay breaks that wire.
  3. Plug the adapter back in.

Step 4: Upload

const int RELAY_PIN = 18;  // not a strapping pin on classic ESP32 or C6
void setup() { pinMode(RELAY_PIN, OUTPUT); }
void loop() {
  digitalWrite(RELAY_PIN, HIGH); delay(2000);   // relay on (or off, if your module is active-low)
  digitalWrite(RELAY_PIN, LOW);  delay(2000);
}

Expected result

Every 2 seconds you hear a click, the module’s LED changes, and the load turns on or off.

Common mistakes

Problem Fix
Module LED lights but no click Check the module’s documentation for the VCC and input voltages it needs
Load is on when it should be off (works backwards) Load is wired to NC; move it to NO, or the module is active-low
Load never turns on Adapter not plugged in, or the load wire isn’t actually through COM/NO. Check continuity between COM and NO when the relay clicks.
Board resets when the relay clicks Tip: this can be a power problem. Power the module from a separate 5 V supply with a common ground (GND connected to the ESP32’s GND), or add a capacitor across the module’s supply (around 100 µF is a typical value)

About mains wiring (read this)

In Canada, electrical installation work is regulated provincially, and the rules differ. In Quebec, electrical installation work, even in your own home, must be done by a licensed electrical contractor (RBQ/CMEQ). In Ontario, a homeowner may do some work in their own home but must file a notification with ESA and have it inspected. Check your province’s rules before wiring anything to mains; when in doubt, hire a licensed electrician. Don’t treat a hobby relay module as a safety device. Check its documentation for its ratings, and never rely on code for an emergency stop.

Sources

Keep going

Posted on — Leave a comment

Read a temperature sensor with ESP32

By EEDIY Team. Difficulty ★★ · About 30 minutes · Do the LED blink post first We’ll use the TMP235, a small analog temperature sensor from Texas Instruments. Its output voltage rises as the temperature rises, and the ESP32 measures that voltage and converts it to °C.

What you need

  • ESP32 board (already set up in Arduino IDE)
  • 1 TMP235 analog temperature sensor (a breadboard-friendly package or breakout board)
  • Breadboard and 3 jumper wires
Words to know
  • Analog input / ADC: a pin that measures a voltage instead of just on or off.
  • mV: millivolt, one thousandth of a volt.

How the sensor works (the only maths)

From the TMP235 datasheet: the output is 500 mV at 0 °C and rises 10 mV for every 1 °C. So: Temperature (°C) = (output mV − 500) ÷ 10 Example: 750 mV gives (750 − 500) ÷ 10 = 25 °C. The TMP235 runs from a 2.3 V to 5.5 V supply, so the ESP32’s 3.3V pin works.

Step 1: Wire it

Check the pinout in the datasheet (or on your breakout board) for VDD, GND and OUT.
  1. VDD to the ESP32’s 3.3V pin.
  2. GND to GND.
  3. OUT to an analog-capable GPIO (check your board’s pinout). On a classic ESP32, use an ADC1 pin such as GPIO 34 (ADC1_CH6). Avoid GPIO 2 on the classic ESP32: it’s an ADC2 pin and a strapping pin. On an ESP32-C6, GPIO 2 is fine (ADC1_CH2, not a strapping pin).
  4. Optional but recommended: TI strongly recommends power-supply bypassing. Put a 0.1 µF capacitor between VDD and GND, close to the sensor.

Step 2: Upload the sketch

const int SENSOR_PIN = 34;  // classic ESP32: an ADC1 pin like GPIO 34. ESP32-C6: GPIO 2 (ADC1_CH2)
void setup() {
  Serial.begin(115200);
}
void loop() {
  int mv = analogReadMilliVolts(SENSOR_PIN);   // reading in millivolts
  float tempC = (mv - 500) / 10.0;             // TMP235 formula
  Serial.print(mv); Serial.print(" mV  ->  ");
  Serial.print(tempC); Serial.println(" C");
  delay(1000);
}
analogReadMilliVolts() is part of Arduino-ESP32 and returns the pin voltage in millivolts.

Step 3: Watch the reading

Open the Serial Monitor and set it to 115200 baud.

Expected result

A new line every second, showing something close to room temperature. Pinch the sensor gently between your fingers and the number should rise slowly.

Common mistakes

Problem Fix
Garbled text Set the Serial Monitor to 115200 baud. A few garbage characters right after reset are normal
Reading near 0 or the maximum Check the wiring; you may be using the wrong pin or a pin that isn’t analog-capable
Temperature way off VDD and OUT may be swapped. Unplug first, then check the pinout. Wiring it wrong can damage the sensor
Numbers jump around Normal for a little noise. Average 10–20 readings
ADC tip: the TMP235 output stays under about 1.3 V across normal room temperatures, so a lower attenuation setting (analogSetAttenuation()) can improve resolution. The measurable range for each setting differs by chip; see the tables in the Arduino-ESP32 ADC docs.

Next step

Show the reading on a web page over Wi-Fi (coming soon).

Sources

Keep going

Posted on — Leave a comment

Your first ESP32: install Arduino IDE and blink an LED

By EEDIY Team. Difficulty ★ · About 30-45 minutes Making an LED blink is the “hello world” of electronics. Once it works, you know your computer, cable, board and code are all working together.

What you need

  • 1 ESP32 development board (any common one)
  • 1 USB cable that carries data (some cables only charge)
  • 1 solderless breadboard
  • 1 LED and 1 resistor (from a starter kit’s LED section)
  • 2 jumper wires
  • A computer (Windows, macOS or Linux)
Words to know
  • GPIO: a general-purpose pin your code can switch on and off.
  • Sketch: an Arduino program.
  • Upload: sending the sketch from your computer to the board.

Step 1: Install the Arduino IDE

Download it from arduino.cc/en/software and install it like any other program.

Step 2: Add ESP32 support

  1. Open Preferences and paste Espressif’s board-manager URL into “Additional boards manager URLs”: https://espressif.github.io/arduino-esp32/package_esp32_index.json
  2. Open Boards Manager, search for esp32 and install the package by Espressif Systems.

Step 3: Wire the LED

An LED needs a series resistor to keep the current below the maximum forward current in the LED’s datasheet. For example, one common red LED datasheet lists 30 mA. Which resistor? 220–330 Ω is a typical choice. To work it out: R = (3.3 V − Vf) ÷ current, where Vf is the LED’s forward voltage from its datasheet. Example: the Kingbright WP7113ID has a typical Vf of 1.9 V at 10 mA, so (3.3 − 1.9) ÷ 0.010 = 140 Ω minimum. A 220 Ω resistor gives about 6 mA, which is still visible and safely below the limit.
  1. Connect a GPIO pin to one end of the resistor.
  2. Connect the other end of the resistor to the LED’s positive leg (anode).
  3. Connect the LED’s other leg (cathode) to a GND pin.
Not sure which leg is the anode? On the Kingbright WP7113ID drawing, the cathode (−) is the lead on the flat edge of the rim, and the anode (+) is the longer lead. Many 5 mm LEDs follow this, but check your LED’s datasheet. Check your board’s pinout to pick a normal GPIO pin, and write down its number. Avoid strapping pins (pins the chip reads at startup to decide how to boot): GPIO 0, 2, 5, 12 and 15 on the classic ESP32, and GPIO 4, 5, 8, 9 and 15 on the ESP32-C6. The example uses GPIO 18, which is not a strapping pin on either chip.

Step 4: Select your board and port

Plug in the board. In Tools, choose the board that matches the chip on yours: ESP32 Dev Module for a classic ESP32, ESP32C6 Dev Module for an ESP32-C6, or your exact model if it’s listed. Then choose the port that appeared.

Step 5: Upload the sketch

const int LED_PIN = 18;  // change to the GPIO you used
void setup() {
  pinMode(LED_PIN, OUTPUT);        // make the pin an output
}
void loop() {
  digitalWrite(LED_PIN, HIGH);     // LED on
  delay(500);                      // wait half a second
  digitalWrite(LED_PIN, LOW);      // LED off
  delay(500);
}
Click Upload.

Expected result

The upload reaches 100%, the board restarts, and the LED turns on for half a second, then off for half a second (one blink per second).

Common mistakes

Problem Fix
No port appears Tip: try a different USB cable (some cables only charge) or a different USB socket
Upload fails to connect Hold BOOT, press reset (or replug), release BOOT, then upload again
Uploads but LED stays dark The LED is in backwards (flip it; at 3.3 V that’s within the 5 V reverse-voltage rating in the example datasheet, so it’s usually not damaged), or the pin number in the code doesn’t match the wire
Wrong board selected Pick your exact board model in Tools

Next step

Change both delay(500) values to delay(100) and upload again. You just wrote your first change! Questions? The forum (ESP32 & MCUs) is coming soon.

Sources

Keep going

Posted on — Leave a comment

What is EEDIY?

By EEDIY Team. EEDIY (eediyca.com) is a friendly place in Canada for beginners and hobbyists to learn electronics, build real projects and ask questions. No question is too basic.

Who it’s for

  • Newcomers to the hobby: you’ve never wired a circuit, and that’s fine.
  • Students: you want a first project that actually works, and a parts list that makes sense.
  • Electricians: you know wiring and safety, and want to try microcontrollers, sensors and automation at low voltage.

How we teach

Every how-to follows the same simple pattern, so you can learn it once and get it:
  1. What you need: a parts list before you start.
  2. Numbered steps: one action per step.
  3. Expected result: what you should see when it works.
  4. Common mistakes: what usually goes wrong, and how to fix it.
New words are explained the first time they appear. Specs link to the manufacturer’s documentation, and when something isn’t confirmed, we say so.

What you’ll find

  • Project ideas and builds: small, real projects you can copy and change.
  • Tutorials on three themes:
    • ESP32 and microcontrollers: your first board, your first blink, reading sensors.
    • Hardware + AI: simple, hands-on ways small boards can use AI.
    • Automation basics: relays, Modbus and RS-485, explained simply, with low voltage first.
  • Community forum (coming soon): ask anything and share your builds. Sections: ESP32 & MCUs, Hardware + AI, Industrial Automation, and Project Showcase.
  • Dev boards and tools (shop coming later): for now, we’re focusing on learning content.

Honest by default

We show what works and what doesn’t. If we ever use affiliate links or receive free samples, we’ll say so clearly on that page.

Start here

Read our first board tour on the blog. The forum is coming soon, and you’ll be able to bring your questions there.

Keep going

Posted on — Leave a comment

Waveshare ESP32-C6 Touch-AMOLED-1.8: board tour

By EEDIY Team. Sample bought by us; no sponsorship and no affiliate links.

The Waveshare ESP32-C6-Touch-AMOLED-1.8 is a small development board in a black case. It combines an Espressif ESP32-C6 with a 1.8-inch touch AMOLED screen, power management, sensors and audio. This post covers what is on the board, based on the label on our unit and Waveshare’s own documentation.

New to this? Don’t worry about every chip name. The short version: it’s a tiny computer with Wi-Fi and Bluetooth, a colour touch screen, a motion sensor, a clock, a speaker and microphone, and a memory-card slot, all in one small case. We explain each part below in plain words.

Check your hardware revision first

Waveshare ships two revisions that use the same pins but different display and touch chips [1][3]:

RevisionAMOLED driverTouch controller
V1SH8601FT3168 / FT6146
V2CO5300CST820

Our unit’s label says SH8601 / FT3168, so it is a V1 board. Arduino examples are split by revision (examples/arduino for V1, examples/arduino-v2 for V2). The ESP-IDF BSP tells them apart by touch I2C address: 0x38 means V1, 0x15 means V2 [1][3].

What’s on the board (label vs. official docs)

Label on our unitWhat it isOfficial source
ESP32-C632-bit RISC-V SoC, up to 160 MHz. Wi-Fi 6, Bluetooth 5 (LE), IEEE 802.15.4 (Zigbee 3.0 / Thread). 512 KB HP SRAM, 16 KB LP SRAM, 320 KB ROM. Onboard antenna[1][2]
16MB FLASHExternal 16 MB NOR flash. No PSRAM[1][3]
1.8inch AMOLED, 368×4481.8″ capacitive touch AMOLED, 368 × 448, 16.7M colours, QSPI. Waveshare lists 350 cd/m² brightness and 100000:1 contrast[1][2]
Display SH8601AMOLED driver (V1)[1][2]
Touch FT3168Capacitive touch controller over I2C (V1)[1][2]
PMIC AXP2101Power management: multiple voltage rails, battery charging and management[1][2]
6-Axis IMU QMI86583-axis accelerometer and 3-axis gyroscope[1][2]
RTC PCF85063Real-time clock, kept powered from the Li battery through the AXP2101. Pads for a backup cell[1][2]
Codec ES8311Low-power audio codec[1][2]
SPKOnboard speaker output[1]
MICMicrophone for audio capture[1][3]
Micro SDTF (microSD) card slot, connected over SPI[1][3]
IO Expander TCA9554I2C I/O expander (TCA9554PWR on the schematic). Waveshare’s own docs page does not list it, but the official schematic does[4]
BOOT, PWRProgrammable BOOT and PWR buttons[1]

Also on the board [1][2]:

  • USB Type-C for flashing and log output
  • 3.7 V MX1.25 lithium battery header. The battery is optional: SKU 33305 includes one, and SKU 33366 (the “-EN” version) has none
  • Pads for one I2C, one USB and one UART connection

About the USB-C port: device only, no host

In plain words: the USB port is for uploading code and seeing debug messages. It can’t connect to a USB keyboard or mouse.

The ESP32-C6’s native USB is a USB Serial/JTAG Controller. Espressif describes it as “a fixed-function USB device … that cannot be reconfigured to perform any function other than a serial port and JTAG debugging functionality” [5]. As a result:

  • The port shows up on your computer as a serial port plus JTAG debugger. You can flash and debug with no USB-UART bridge chip.
  • It cannot act as a USB host, so you cannot plug a USB keyboard, mouse or flash drive straight into it.
  • It also cannot pretend to be a USB keyboard (HID) to a PC. Chips with a USB OTG controller, such as the ESP32-S3, can do that [5].

To get keyboard or mouse behaviour, the C6 has to use Bluetooth LE HID. Our next post shows a demo that does this.

Development options

Beginners: start with Arduino IDE.

Waveshare supports Arduino IDE and ESP-IDF. ESP-IDF projects use the waveshare/esp32_c6_touch_amoled_1_8 BSP from the ESP Component Registry [1][3]. The schematic, examples and factory recovery images are in Waveshare’s GitHub repository [3][4].

Sources

  1. Waveshare documentation: https://docs.waveshare.com/ESP32-C6-Touch-AMOLED-1.8 (the legacy wiki https://www.waveshare.com/wiki/ESP32-C6-Touch-AMOLED-1.8 now redirects or is empty)
  2. Waveshare product page: https://www.waveshare.com/esp32-c6-touch-amoled-1.8.htm
  3. Waveshare official GitHub: https://github.com/waveshareteam/ESP32-C6-Touch-AMOLED-1.8
  4. Waveshare schematic (PDF): https://files.waveshare.com/wiki/ESP32-C6-Touch-AMOLED-1.8/ESP32-C6-Touch-AMOLED-1.8-Schematic.pdf
  5. Espressif ESP-IDF, USB Serial/JTAG Controller Console (ESP32-C6): https://docs.espressif.com/projects/esp-idf/en/stable/esp32c6/api-guides/usb-serial-jtag-console.html

Keep going