Using a Winson WCS Hall Effect Current Sensor with Arduino
Using a Winson WCS Hall Effect Current Sensor with Arduino
The Winson WCS series of Hall-effect current sensors makes it easy to measure both AC and DC current with full galvanic isolation. In this project we use a WCS sensor (model WCS1800 in the example) together with an Arduino to measure current from small loads up to tens of amperes. The Robojax WCS library handles the sensor’s offset, scaling and averaging for you, so you can focus on reading current values and reacting to them in your own projects.
When properly wired and calibrated, the sensor output closely follows the actual current drawn by your load. In the demonstration, an electronic DC load and thick cable are used to push the sensor toward its limit and show how accurate it is across the range. All parts used in this project, including the Winson WCS sensor module and Arduino board, can be purchased from the links provided below this article.
Understanding the Winson WCS Current Sensor Family
Winson Semiconductor (Taiwan) offers a wide range of WCS Hall-effect current sensors in different packages and current ranges. They come as:
- Direct-wiring series modules with screw terminals for the high-current path
- Through-hole versions with a circular core where the cable passes through
- PCB-mounted modules with built-in conditioning and terminals
Common features of the WCS series (exact values depend on the model and can be found in the datasheet — see the link below this article) include:
- Supply voltage typically from 3 V to 12 V (5 V with Arduino is standard)
- Low operating current, around 3–3.5 mA
- Output voltage centered at approximately VCC/2 at zero current
- Fixed sensitivity (e.g., about 66 mV/A for the
WCS1800) - Isolation voltage around 4 kV between primary conductor and electronics
- Bandwidth in the tens of kilohertz (around 23 kHz for the WCS1800)
- Zero-current temperature drift in the order of ±1 mV/°C
The example in this project uses the WCS1800 sensor:
- Measurement range: about 0–35 A DC, and around 0–25 A RMS for AC
- Sensitivity: approximately 66 mV per ampere
- Zero-current output: near 2.5 V when powered at 5 V
- Recommended for applications where up to roughly 25 A of current is needed with good linearity
Different WCS models have different maximum currents and sensitivities. For best resolution in your project, choose the model with the highest sensitivity that still covers your expected maximum current. Available models and their basic characteristics are listed in the library documentation and in the sensor datasheet accessible from the links below this article.
Project Overview
In this tutorial, we will:
- Wire the Winson WCS sensor and an indicator LED to the Arduino
- Install the Robojax WCS Arduino library
- Configure the code for the correct WCS model (for example,
WCS1800) - Record and compensate the zero-current offset automatically
- Read and display current values on the Serial Monitor
- Use the measured current in an
ifcondition as a threshold
The same code structure and library can be used for many different WCS models from Winson. You only change the model index and a few configuration values, and the rest of your sketch remains the same.
High-Current Wiring Concept (Sensor in the Load Path)
The WCS Hall-effect sensor is inserted into the high-current path of your circuit. The simplest example is:
- Power source (e.g., battery or DC supply)
- Current sensor (WCS module)
- Load (e.g., electronic load, motor, resistor bank, etc.)
You can place the sensor in either the positive line or the negative line:
- Positive-side sensing:
Power supply positive → sensor → load → back to supply negative. - Negative-side sensing:
Power supply negative → sensor → load → back to supply positive.
The direction of current through the sensor determines the sign of the reading (positive or negative), which the library interprets as positive or negative current values. In the demonstration, a thick cable (around 10 AWG) is passed through the WCS1800’s 9 mm hole to safely carry high current. For PCB-mounted modules with screw terminals, the heavy wires are fixed with those terminals instead.
Always choose wiring, cable thickness and connections that match or exceed the maximum current you intend to measure. The mechanical and safety details for each module are shown in its datasheet; you can refer to the datasheet from the link below this article.
Wiring the WCS Sensor and Arduino Connections
On the low-voltage side, all WCS modules used in this project have three signal pins or wires:
- VDD (or VCC): Sensor supply voltage
- GND: Ground reference
- VOUT (or Vout / Analog OUT): Output voltage proportional to current
The Arduino connections are:
- WCS VDD → Arduino 5 V
- WCS GND → Arduino GND
- WCS VOUT → Arduino analog input A0
On many module PCBs, the order of the pins is clearly printed (for example, VCC, GND, VOUT). For bare sensors without PCB, you must follow the pinout diagram from the datasheet and in some cases add a small capacitor between VOUT and GND to reduce noise.
For some bare WCS sensors, you should solder a capacitor between VOUT and GND:
- Capacitance around 0.01 µF (10 nF) to 0.1 µF (100 nF)
- This capacitor stabilizes the output and reduces high-frequency noise
- On many ready-made modules, this capacitor is already mounted on the PCB
All specific values and recommended external components are shown in the sensor’s datasheet. Please refer to the datasheet from the link provided below this article when using a different WCS model.
Zero-Current Indicator LED Wiring
The example code uses a status LED to indicate when the zero-current value has been recorded. This helps you know when it is safe to connect the load. Wire the LED as follows:
- Arduino pin 2 → series resistor (e.g., 300 Ω to 1 kΩ) → LED anode (long lead)
- LED cathode (short lead) → Arduino GND
Any standard 5 mm LED will work. A higher resistor value will make the LED dimmer but also reduce its current. The important point is that pin 2 is used as a digital output by the code, and when the zero-current calibration is complete, the LED is turned on to indicate success.

Installing the Robojax WCS Arduino Library
The code example for this project uses the dedicated Robojax_WCS library. This library supports many WCS models and simplifies calibration and measurement.
To install the library:
- Download the library as a ZIP file and save it somewhere on your computer.
- Open the Arduino IDE.
- From the menu, select Sketch → Include Library → Add .ZIP Library...
- Browse to the downloaded ZIP file and click Open.
- Close all open Arduino IDE windows to ensure only one instance is running.
- Reopen the Arduino IDE.
- Go to File → Examples and scroll down until you find Robojax WCS Current Sensor.
- Open the example named WCS_basic (or similar) to see the basic usage.
We will adapt that basic example here specifically for measuring current with model WCS1800. If you are using another model, you only need to change the model index and possibly some configuration values as described below.
Supported Models in the Example Code
The library supports many models in the WCS family. In the example code, a comment block documents the model list:
0 "WCS38A25"1 "WCS37A50"2 "WCS2801"3 "WCS2702"4 "WCS2705"5 "WCS2810"6 "WCS2720"7 "WCS2750"8 "WCS3740"9 "WCS1500"10 "WCS1600"11 "WCS1700"12 "WCS1800"← used in this project13 "WCS2800"14 "WCS6800"15 "WCS2202"
For this project, the constant MODEL is set to 12, which corresponds to WCS1800. If you use another sensor from the list, simply adjust the #define MODEL line in the code.
#include <Wire.h>
#include <Robojax_WCS.h>
#define MODEL 12 // see list above
#define SENSOR_PIN A0 // pin for reading sensor
#define SENSOR_VCC_PIN 8 // pin for powering up the sensor
#define ZERO_CURRENT_LED_PIN 2 // zero current LED pin
#define ZERO_CURRENT_WAIT_TIME 5000 // wait for 5 seconds to allow zero current measurement (ms)
#define CORRECTION_VLALUE 164 // mA correction value
#define MEASUREMENT_ITERATION 100
#define VOLTAGE_REFERENCE 5000.0 // 5000mV is for 5V
#define BIT_RESOLUTION 10
#define DEBUT_ONCE true
Explaining the Code
Library Includes
The code starts by including two header files:
#include <Wire.h>– enables I²C functionality if needed by the library or your project.#include <Robojax_WCS.h>– the Robojax WCS library that handles calibration and current calculations.
Configuration Constants
Key configuration values are defined with #define:
MODEL– selects which WCS sensor you are using. Here,MODEL 12meansWCS1800.SENSOR_PIN– analog pin where the sensor’s VOUT is connected (A0in this project).SENSOR_VCC_PIN– digital pin used to power the sensor (through the library) or to enable sensor power (8in this project).ZERO_CURRENT_LED_PIN– status LED pin (2) for zero-current indication.ZERO_CURRENT_WAIT_TIME– the time (in milliseconds) during startup when no load must be connected. Within this period, the library measures and records the zero-current voltage offset.CORRECTION_VLALUE– fine-tuning value (in mA) used to correct minor systematic errors in calibration.MEASUREMENT_ITERATION– number of samples averaged per reading (here100). Increasing this gives smoother, more stable readings at the cost of speed.VOLTAGE_REFERENCE– analog reference voltage in millivolts (e.g.,5000.0for a 5 V Arduino).BIT_RESOLUTION– ADC resolution in bits (10for most classic Arduino boards).DEBUT_ONCE– when set totrue, the detailed debug output can be printed only once (ifsensor.printDebug()is used).
Creating the Sensor Object
The line:
Robojax_WCS sensor(...);
Constructs an instance of the WCS sensor class and passes all configuration parameters to it. The library uses these values to:
- Know which model’s sensitivity to use
- Control the power pin of the sensor (if used)
- Drive the zero-current LED
- Measure and store zero-current offset during
ZERO_CURRENT_WAIT_TIME - Convert raw ADC readings to amperes using
VOLTAGE_REFERENCE,BIT_RESOLUTIONand the model’s settings
setup() Function
In setup():
Serial.begin(9600);starts the serial communication at 9600 baud. This value must match the setting in the Serial Monitor.Serial.println("Robojax WCS Library");prints a banner line.sensor.start();initializes the sensor:- Configures pins
- Performs zero-current measurement during the defined wait time
- Turns the zero-current LED on when calibration is complete
Serial.println(sensor.getModel());prints the string name of the selected model (for example,WCS1800).
During startup, make sure no load current is flowing through the WCS sensor. Otherwise, the recorded zero point will be wrong and the readings will be offset.
loop() Function
In loop():
sensor.readCurrent();takes fresh readings from the sensor. This call must remain insideloop()so values are updated continuously.sensor.printCurrent();prints the measured current in amperes to the Serial Monitor.- The
if (sensor.getCurrent() >= 12.3)block shows how to react to the measurement: in this case, when current reaches or exceeds 12.3 A, you can add your own code (for example, controlling a relay, shutting down a load, or triggering an alarm). delay(500);adds a half-second pause between readings, making them easy to read.sensor.printDebug();(when uncommented) prints detailed debug information: ADC readings, calculated offsets, voltage values and configuration. This is very helpful while tuning the system and checking that all parameters are correct.
Zero-Current Calibration and the LED Indicator
The built-in zero-current calibration is a key part of getting accurate readings:
- On power-up or reset, keep the load disconnected or switched off.
- The code waits for
ZERO_CURRENT_WAIT_TIMEmilliseconds (5 seconds in this example). - During this period, the library reads the sensor output with no current and computes the zero-current offset.
- Once the calibration is successfully completed, the LED connected to
ZERO_CURRENT_LED_PINis turned on to indicate that the zero point has been saved. - After that, you can safely enable or connect your load.
If the Arduino resets while a large current is flowing, the sensor will “think” that value is the new zero, and all subsequent readings will be incorrect. In the demonstration, resetting the board while 25 A is flowing leads to a large negative reading when the load is later turned off. This shows why the load must be off during calibration.
Demonstration and Accuracy
In the demonstration, an electronic load is used to draw different current levels while the WCS1800 sensor measures the current and the Arduino prints it to the Serial Monitor. A heavy-gauge cable passes through the sensor’s core or terminals to safely carry high current.
Some example observations:
- Around 5 A, the readings are very close to the reference value.
- From about 10–20 A, deviations are typically in the range of a few hundred milliamps.
- At around 25 A, readings are still quite accurate and within a small error margin.
- Approaching the sensor’s top limit (around 30–35 A), the error increases and the response becomes less linear.
The practical conclusion is that for the WCS1800, a working region up to about 25 A provides good accuracy and repeatability. This is sufficient for many DC projects such as battery testing, DC motor monitoring, power supply measurements and more. For higher currents, consider a sensor with a higher range (but remember that higher range usually means lower sensitivity).
Using the Measured Current in Your Own Projects
The example if condition:
if (sensor.getCurrent() >= 12.3) { ... }
is a placeholder where you can insert your own logic. For example:
- Trigger a relay to disconnect the load when current exceeds a safe level.
- Turn on a cooling fan when current is above a threshold.
- Log values to an SD card for power consumption analysis.
- Send current data over serial, WiFi or Bluetooth for remote monitoring.
Because sensor.getCurrent() returns a floating-point value in amperes, you can use it in any kind of calculation: averaging, integration (to estimate Ah), percentage load indicators and more.
Wrapping Up
In this article you learned how to:
- Wire a Winson WCS current sensor to an Arduino
- Install and configure the
Robojax_WCSlibrary - Calibrate the sensor’s zero-current offset automatically
- Display current readings on the Serial Monitor
- Use a current threshold to trigger an action in your code
You can adapt the same structure to other WCS models by changing the MODEL constant and verifying the settings against the sensor’s datasheet. Please refer to the component purchase links and the WCS datasheet link below this article to obtain the appropriate sensor modules and documentation for your next project.
图像
|||您可能需要的东西
-
亚马逊从亚马逊购买 WCS1800 霍尔电流传感器amzn.to
-
易趣
-
全球速卖通Purchase WCS1800 Hall Current Sensor from AliExpresss.click.aliexpress.com
资源与参考
-
外部Datasheet for WCS1500winson.com.tw
-
外部Datasheet for WCS1600winson.com.tw
-
外部Datasheet for WCS1700winson.com.tw
-
外部Datasheet for WCS1800winson.com.tw
-
外部Datasheet for WCS2702winson.com.tw
-
外部Datasheet for WCS2705winson.com.tw
-
外部Datasheet for WCS2720winson.com.tw
-
外部Datasheet for WCS2800winson.com.tw
-
外部Datasheet for WCS2801winson.com.tw
-
外部Datasheet for WCS2810winson.com.tw
-
外部Datasheet for WCS3740winson.com.tw
-
外部Datasheet for WCS37A50winson.com.tw
-
外部Datasheet for WCS38A25winson.com.tw
-
外部Datasheet for WCS6800winson.com.tw
-
内部
文件📁
其他文件
-
Download RoboJax WCS Library
robojax_Winson_WCS_library.zip0.04 MB