![]() |
Ubuntu 22.04 LTSubuntu
|
|
![]() |
InfluxDBInfluxdata
|
|
![]() |
KiCad 8.0KiCad
|
Digitally Controlled Electric Load
About This
An Electronic Load is a device that simulates the behavior of an electronic component under various load conditions. It is used to test the performance of power supplies, batteries, and other electronic devices. The Digitally Controlled Electric Load (DCEL) is an advanced electronic load that can be controlled digitally using a microcontroller. In this article, I made a DCEL using the ESP32S3 microcontroller, INA228 current sensor, and MOSFETs to control the load. The DCEL can measure power consumption up to 100W and send the data to a server via WiFi. This data can be visualized using a dashboard graph in InfluxDB. It features a touchpad interface for local control and a PID controller for automatic current regulation.
How it works
The DCEL operates by regulating the current consumption of the load device. It measures the current across the load using the shut resistor. The shut resistor voltage is I*R, where I is the current and R is the resistance of the shut resistor. The INA228 measures the shut voltage and sends it to the ESP32S3 microcontroller via I2C communication. The microcontroller processes current and adjusts the gate voltage of the MOSFET to control the load current. However, ESP32S3 does not have a DAC to generate an analog voltage. Therefore, I used a PWM signal to generate an analog voltage using a low-pass filter (LPF). The LPF filter out the high-frequency components of the PWM signal, resulting in a smooth analog voltage. The PWM signal is generated by the ESP32S3 as 14-bit resolution and 1kHz frequency. It can be generated the signal using the LEDC library. The LPF consists of a resistor and a capacitor. The resistor and capacitor values are chosen to achieve the desired cutoff frequency about 100Hz. The LPF output is connected to the OPAmp, which is used to amplify 3-times gain. The OPAmp output is connected to the gate of the MOSFET, which control the load current.
I used IRF530PBF as MOSFET, which can handle up to 100V and 14A. However, the maximum current is limited by the MOSFET heat dissipation. The MOSFET is mounted on a heatsink to dissipate the heat generated during operation. The IRF530PBF has a maximum junction-to-case thermal resistance of 1.7°C/W. The heatsink has thermal resistance of 0.3°C/W. The direct-heat-sink-to-flat-plate-grease-surface has a thermal resistance of 0.1°C/W. The total thermal resistance is 2.1°C/W. If the environment temperature is 25°C, the maximum junction temperature is 175°C. The maximum power dissipation is about 70W. This limit is designed to protect the MOSFET from overheating. Actually, the DCEL can handle up to 100W power consumption.
The load current is measured by the INA228 current sensor. The INA228 is a high-precision current sensor with a 20-bit Ultra-precise delta-sigma ADC. The current data is sent to the ESP32S3 microcontroller via I2C communication. The ESP32S3 processes the current data and adjusts the gate voltage of the MOSFET to control the load current. The ESP32S3 can control the load current with PID control. The PID (Proportional-Integral-Derivative) controller is used to adjust the gate voltage of the MOSFET to maintain the desired current value. The PID controller calculates the error between the desired current value and the measured current value. The DCEL can control the load current from 10mA to 10A with 10mA resolution.
The current can be controlled using a touchpad interface. This touchpad interface consists of 7 x 7 touch sensor array. These sensor lines are arranged in a matrix form. If touch is the orange color circle, the touch sensor line R4, R3, C4 and C5 are active. The touch sensor line is connected to the ESP32S3 microcontroller directly. The ESP32S3 microcontroller scans the touch sensor lines and detects the touch position. In this case, the touch position is (+0.5, -0.5).
Additionally, It needs to detect the touch movement of the touch clockwise or counterclockwise. If first position is (X1, Y1) and second position is (X2, Y2), S = X1*Y2 - X2*Y1. If S is positive, the touch is counter-clockwise. If S is negative, the touch is clockwise. I used the touchpad interface to set the desired current value. If the touch is clockwise, the current value is increased by 10mA. If the touch is counter-clockwise, the current value is decreased by 10mA. If the touch movement is fast, the current value is increased or decreased by 100mA.
After desired current value is set, touch the center of the touchpad interface as during 1 second to start the current control and PID control. To prevent the current overload, the DCEL increase the current slowly with PID control.
The DCEL has a heat sink that dissipates the heat generated during operation. As the heat sink, I used the CPU cooler LGA115x for PC. It can work with DC 12V and PWM control. Because the ESP32S3 have a PWM output, the fan speed can be controlled too. Between the temperature 40 degree and 50 degree, the fan speed is increased linearly. If the temperature is over 50 degree, the fan speed is set to 100%. Usually, the fan has a detect the rotation speed. The rotation speed can be read to count the pulse signal by the ESP32S3 microcontroller.
The MOSFET is mounted on between the board and heat sink. The MOSFET, Blocking Diode and temperature sensor just fit the heat sink. The DCEL has a heat sink temperature sensor to monitor the heat sink temperature. The heat sink temperature is measured by the LM75 temperature sensor. The LM75 outputs the voltage as temperature value. The voltage is Vout = 10mV/°C * T. Then, the voltage is amplified by the OPAmp with 2-times gain. The amplified voltage is connected to the ESP32S3 microcontroller to ADC function. The ESP32S3 microcontroller can read the heat sink temperature. And the heat sink has a fan to cool down the heat sink. The DC FAN needs power supply as DC 12V. The DC 12V is supplied by the USB PD. The fan power is controlled by a MOSFET switch.
The ESP32S3 microcontroller processes the measurement data and sends it to InfluxDB server via WiFi. The ESP32S3 microcontroller has a WiFi module to connect to the WiFi network. The ESP32S3 microcontroller sends the measurement data to the InfluxDB server using the HTTP POST method. The InfluxDB server stores the measurement data in the database. The measurement data can be visualized using the dashboard graph. You can see the real-time measurement current, voltage, power, heat sink temperature, the PWM value and fan speed.
How to build the DCEL
I designed the schematic and PCB using KiCad. The schematic file is here.
Since the load current path is designed to handle up to 10A, the current path is designed to be wide. And GND line is separated from the load current path. The INA228 is placed near the load current path.
After it is designed, I ordered PCBWay to manufacture my board. It is pretty easy to order the board. Click the "Add Gerber File" button, and you can upload the Gerber file. Then, you can choose solder mask color. I chose the Matte Black color I like this one. The board is manufactured in only few days. When I ordered the board, PCBWay engineers checked my Gerber file and sent me an email about the design. The Matte Black color has limit gap between the IC pads <0.22mm for 1oz copper. They asked me to choose the three options. 1. Accept No solder mask bridge. 2. Modify the design to meet the Matte Black color requirements. 3. Change the solder mask color. I chose the option 1. However, the board is manufactured without any solder mask bridge. The board is very good quality. I am very satisfied with the board. I think the PCBWay's board price is very reasonable to with the service.
Here is the how to build the DCEL. In this video, I am creating a board using hand soldering.
Install Software
After build the DCEL, write the firmware to the ESP32S3 microcontroller. To write the firmware, you need to build the code on the Ubuntu Linux OS.
Using Ubuntu 22.04.3 LTS and ESP-IDF V5.2.1
Prerequisites
Ensure that your system meets the following requirements before proceeding with the installation:
Operating System: Linux-based distribution
Required Packages: git, python3, python3-pip, gcc, build-essential, curl, pkg-config, libudev-dev, libtinfo5, clang, libclang-dev, llvm-dev, udev, libssl-dev, python3.10-venv
Installation Steps
1. System Update and Package Installation
Update your system and install the necessary packages using:
sudo apt update && sudo apt -y install git python3 python3-pip gcc build-essential curl pkg-config libudev-dev libtinfo5 clang libclang-dev llvm-dev udev libssl-dev python3.10-venv
2. Rust Installation
Install Rust programming language and Cargo package manager:
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
After installation, activate Rust by sourcing the environment:
. "$HOME/.cargo/env"
3. Additional Tools Installation
Install the following Rust tools:
ldproxy
espup
cargo-espflash
Use the following commands:
cargo install ldproxy
cargo install espup
cargo install cargo-espflash
4. ESP Environment Setup
Run the following command to install and update the Espressif Rust ecosystem:
espup install
espup update
Set up environment variables:
. ./export-esp.sh
5. Udev Rules Configuration
Configure udev rules for device permissions:
sudo sh -c 'echo "SUBSYSTEMS==\"usb\", ATTRS{idVendor}==\"303a\", ATTRS{idProduct}==\"1001\", MODE=\"0666\"" > /etc/udev/rules.d/99-esp32.rules'
sudo udevadm control --reload-rules
sudo udevadm trigger
6. Clone Repository
Clone the TimeLeapCam repository:
git clone https://github.com/hnz1102/electricload.git
cd electricload/code
7. Setting WiFi SSID, Password, etc.
Change the following configuration file: `cfg.toml`
You have to set the following parameters. WiFi SSID, Password, InfluxDB Server IP Address, InfluxDB API Key, and InfluxDB API with your ORG.
You can get the API Key from the InfluxDB Web Console. Please see the 'How to Install the influxDB and Configure the Dashboard' section No.3.
[electricload]
wifi_ssid = "<Your AP SSID>" # Set your AP SSID
wifi_psk = "<Your AP Password>" # Set your AP Password
http_server = "<InfluxDB Server IP Address:Port>" # Set your InfluxDB Server IP Address and Port ex. 192.168.1.100:8086
pid_kp = "0.001"
pid_ki = "0.022"
pid_kd = "0.00001"
pwm_offset = "4500"
max_current_limit = "15.0"
max_power_limit = "105.0"
influxdb_api_key = "<InfluxDB API KEY>" # Set your InfluxDB API Key
influxdb_api = "/api/v2/write?org=<ORG>&bucket=LOGGER&precision=ns" # Set your InfluxDB API with your ORG and BUCKET ex. /api/v2/write?org=ORG&bucket=LOGGER&precision=ns
influxdb_tag = "currentch1"
influxdb_measurement = "electricload"
8. Build and Flash
Build the project.
cargo build --release
9. Flash the Firmware
Connect the Electric Load and Logger to your PC using a USB cable. Then, flash the firmware:
cargo espflash flash --release --monitor
If your device is not detected, power on the device and during the boot, press the `BOOT` button.
Then, run the flash command again.
10. Monitor the Output
After flashing the firmware, the console shows the booting messages.
[2024-11-24T08:43:44Z INFO ] 🚀 A new version of cargo-espflash is available: v3.2.0
[2024-11-24T08:43:44Z INFO ] Serial port: '/dev/ttyACM0'
[2024-11-24T08:43:44Z INFO ] Connecting...
[2024-11-24T08:43:44Z INFO ] Using flash stub
Finished `release` profile [optimized] target(s) in 0.19s
Chip type: esp32s3 (revision v0.1)
Crystal frequency: 40 MHz
Flash size: 16MB
Features: WiFi, BLE
MAC address: xx:xx:xx:xx:xx:xx
:
:
I (7495) electricload: PID Controller: KP=0.001 KI=0.022 KD=0.00001
I (7585) electricload::touchpad: TouchPad4 threshold: 1529
I (7585) electricload::touchpad: TouchPad5 threshold: 1519
I (7585) electricload::touchpad: TouchPad6 threshold: 1433
I (7585) electricload::touchpad: TouchPad7 threshold: 1523
I (7595) electricload::touchpad: TouchPad8 threshold: 297
I (7605) electricload::touchpad: TouchPad3 threshold: 1436
I (7605) electricload::touchpad: TouchPad9 threshold: 291
I (7625) electricload::touchpad: TouchPad1 threshold: 325
I (7625) electricload::touchpad: TouchPad2 threshold: 1619
I (7625) electricload::touchpad: TouchPad14 threshold: 313
I (7645) electricload::touchpad: TouchPad13 threshold: 307
I (7645) electricload::touchpad: TouchPad12 threshold: 302
I (7645) electricload::touchpad: TouchPad11 threshold: 287
I (7645) electricload::touchpad: TouchPad10 threshold: 281
I (7665) electricload::touchpad: TouchPad charge discharge times: 500 -> 1000
How to Install the influxDB and Configure the Dashboard
1. Download [influxDB](https://docs.influxdata.com/influxdb/v2.7/install/?t=Linux) and Install.
$ wget https://dl.influxdata.com/influxdb/releases/influxdb2-2.7.0-amd64.deb
$ sudo dpkg -i influxdb2-2.7.0-amd64.deb
$ sudo service influxdb start
2. Configure the influxDB
Connect to the 'http://<influxDB installed PC Address>:8086'
Click `GET STARTED` and set `Username`, `Password`, `Initial Organization Name`, and `Initial Bucket Name`
Initial Organization Name Organization Name ex. ORG
Initial Bucket Name LOGGER
After set them, click `CONTINUE`.
3. Copy the operator API token.
You can see the operator API token on the browser. YOU WON'T BE ABLE TO SEE IT AGAIN!
If you want to get new API token, click `API Tokens` menu form `Sources` Icon, then click `GENERATE API TOKEN` and select `All access token`, click `Save`.
You can see a new API token and get it.
After copy the token, click `CONFIGURE LATER`.
4. Import the Dashboard Template.
Click the `Dashboard` icon, and select `Import Dashboard` from the `CREATE DASHBOARD` menu.
Drop the `influxdb/electric_load.json` file to `Drop a file here`, then click `IMPORT JSON AS DASHBOARD`.
You can see the `ELECTRIC LOAD` pannel on the Dashboards page.
Click this panel, and You can see the dashboard.
If you want to customize the dashboard design, click configure mark. You can change the graph design.
How to use the Electric Load and Logger
At first, connect the power supply to this electric load as shown in the image below. The Plus line is connected to the 'Input +' terminal, and the GND line is connected to the 'Input -' terminal. And Input- is connected to the GND terminal, and Input+ is connected to the 'VBUS' terminal. This allows the device to measure the voltage.
Then, connect the USB Power Delivery (PD) line to the USB-C port. The PD line must be connected to the USB PD Charger. This load gets power from the USB PD 12V.
After connecting the power supply, the display will show the current voltage, current, and power consumption. Then, you can set the current consumption by the device using the touch pad. Clockwise rotation increases the current, and counterclockwise rotation decreases the current. The current can be controlled every 10mA from 10mA to 10A. Fast rotation will increase or decrease the current quickly every 100mA. After setting the current, press the Center Position of the touch pad during over a second to start the load and measurement. The current consumption can be controlled automatically by the device using the PID controller.
The display shows the current, voltage, power consumption, target current, temperature, PWM duty and status of the load.
If you start the load, the display shows the yellow color circle in the left bottom corner and blinking. If the load is stopped, the circle disappears.
After the measure, the data is sent to the server. If the WiFi connection is not established, the data is stored in the internal memory buffer. When the WiFi connection is established, the data is sent to the server. However, the memory buffer is not stored more than 4096 samples. If the some data is stored in the memory buffer, the display shows the red bar in the bottom of the display.
You can see the real-time data using Dashboard by InfluxDB. After the measure, to stop logging, press the Center Position of the touch pad during over a second. The load is stopped and the data is not sent to the server.
The dashboard shows the graphs of voltage, current, power consumption, and PWM duty. The temperature of the heat sink and FAN RPM also shown in the dashboard.
Conclusion
In conclusion, the Digitally Controlled Electric Load (DCEL) is a sophisticated electronic load device that offers precise control over current consumption. By leveraging the capabilities of the ESP32S3 microcontroller, the device can regulate voltage effectively and provide high-resolution measurements. With features such as automatic control, WiFi data transfer, and touchpad interface, the DCEL is a versatile tool for testing and analyzing electronic components. Its ability to handle up to 100W power consumption makes it suitable for a wide range of applications.
Finally, I would like to thank PCBWay for their support of the custom PCB board.
LICENSE
This source code is licensed under MIT. Other Hardware Schematic documents are licensed under CC-BY-SA V4.0.
Digitally Controlled Electric Load
*PCBWay community is a sharing platform. We are not responsible for any design issues and parameter issues (board thickness, surface finish, etc.) you choose.

Raspberry Pi 5 7 Inch Touch Screen IPS 1024x600 HD LCD HDMI-compatible Display for RPI 4B 3B+ OPI 5 AIDA64 PC Secondary Screen(Without Speaker)
BUY NOW
ESP32-S3 4.3inch Capacitive Touch Display Development Board, 800×480, 5-point Touch, 32-bit LX7 Dual-core Processor
BUY NOW
Raspberry Pi 5 7 Inch Touch Screen IPS 1024x600 HD LCD HDMI-compatible Display for RPI 4B 3B+ OPI 5 AIDA64 PC Secondary Screen(Without Speaker)
BUY NOW- Comments(0)
- Likes(2)

- 0 USER VOTES
- YOUR VOTE 0.00 0.00
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
More by Hiroshi Nakajima
-
Digitally Controlled Electric Load About ThisAn Electronic Load is a device that simulates the behavior of an electronic component unde...
-
Time Leap Cam - Time-Lapse Cam and Monitoring by OpenAI About This CameraThis camera, named "TIME LEAP CAM," is designed for long-interval time-lapse photog...
-
Share USB Memory with One-touch Switching Between Two Device When the network is not available, data is transferred by copying data to and from a USB memory stic...
-
High-resolution Voltage-Current Digital Logger Voltage-Current Logger - High-resolution digital power monitor and loggerI wanted a tool to measure ...
-
SDCDMUX : SD Card and eMMC Device Multiplexsor with Infrared Remote Control The SDCDMUX provides a convenient and quick change of a SW image of a device that has an SD Card int...
-
MPL3115A2 Barometric Pressure, Altitude, and Temperature Sensor
39 0 0 -
-
Nintendo 64DD Replacement Shell
142 0 1 -
V2 Commodore AMIGA USB-C Power Sink Delivery High Efficiency Supply Triple Output 5V ±12V OLED display ATARI compatible shark 100W
253 4 1 -
How to measure weight with Load Cell and HX711
369 0 3 -
-
Instrumentation Input, high impedance with 16 bit 1MSPS ADC for SPI
502 0 0