Search Code

Using Winston WCS Current Sensors with LCD1602/LCD2004 I2C Arduino

Using Winston WCS Current Sensors with LCD1602/LCD2004 I2C Arduino

343 – Using Winson WCS Current Sensors with LCD1602/LCD2004 I2C and Arduino

This project builds on the previous WCS current-sensor tutorials, but now we display the measured current directly on an LCD1602 or LCD2004 I2C display. The Winson WCS sensor family works the same way, but instead of printing values to the Serial Monitor, we show real-time current and zero-current readings on the LCD screen. This is especially useful for portable systems, battery testers, power analyzers, and stand-alone monitoring tools without a computer.

Understanding the WCS Hall-Effect Current Sensor

Winson WCS current sensors measure both AC and DC current using a Hall-effect IC. The sensor output is centered around half of the supply voltage (about 2.5V at 5V input). The Robojax_WCS library automatically handles offset detection, calibration, sensitivity, and conversion to amperes.

The same sensors covered previously (for example, WCS1800, WCS1500, WCS2800, and more) can be used with this LCD project. Only the display logic changes — not the sensor wiring.

Wiring the WCS Sensor

All WCS models use three low-voltage interface pins:

  • VDD → Arduino 5V
  • GND → Arduino GND
  • VOUT → Arduino analog input (for example, A0)

The high-current load still passes through the sensor (either through the hole or the screw terminals depending on the model). As always, the load must be disconnected during startup so the library can store the correct zero-current offset.

S23-09-WCS1888-LCDr_wiring

LCD1602 or LCD2004 I2C Display

LCD1602 (16×2) and LCD2004 (20×4) displays with I2C backpacks require only four wires:

  • SDA → Arduino SDA
  • SCL → Arduino SCL
  • VCC → Arduino 5V
  • GND → Arduino GND

The I2C address may vary (common addresses are 0x27 and 0x3F), so adjust it based on your display module. The library uses this address along with LCD column and row count to configure the screen.

LCD Settings Used in This Project

These are the LCD configuration variables used in the code. They define the I2C address, display size, and the text labels for showing current and zero-current values.


//LCD settings
const uint8_t I2C_ADDRESS = 0x3f; //watch video for details
const uint8_t LCD_CHAR = 16;
const uint8_t LCD_ROW = 2;

char *TITLE_CURRENT = "Current: ";
char *TITLE_ZERO_CURRENT = "Zero Current: ";

#define SHOW_ZERO_CURRENT true
//const int LCD_VCC_PIN = 9; //define a VCC pin for LCD, see video

Explanation:

  • I2C_ADDRESS – The I2C address of the display. On some boards it may be 0x27.
  • LCD_CHAR – Number of columns (16 for LCD1602, 20 for LCD2004).
  • LCD_ROW – Number of rows (2 for LCD1602, 4 for LCD2004).
  • TITLE_CURRENT – Label printed before the measured current.
  • TITLE_ZERO_CURRENT – Label displayed when showing the stored zero-current value.
  • SHOW_ZERO_CURRENT – When set to true, the LCD shows the zero-current offset after calibration.
  • LCD_VCC_PIN – Optional digital pin to power the LCD; used in some projects to control LCD power from software.

Defining the WCS Sensor Object With LCD Support

The Robojax_WCS library has a special constructor that accepts LCD parameters. This allows the sensor library to update the LCD display automatically with current and zero-current information.

Here is the object definition used in this project (shown as a separate block):


Robojax_WCS sensor(
    I2C_ADDRESS, LCD_CHAR, LCD_ROW,
    MODEL, SENSOR_PIN, SENSOR_VCC_PIN,
    ZERO_CURRENT_WAIT_TIME, SHOW_ZERO_CURRENT,
    CORRECTION_VLALUE, MEASUREMENT_ITERATION, VOLTAGE_REFERENCE,
    BIT_RESOLUTION, DEBUG_ONCE,
    TITLE_CURRENT, TITLE_ZERO_CURRENT
);

Explanation of each parameter:

  • I2C_ADDRESS – Where the LCD module is located on the I2C bus.
  • LCD_CHAR & LCD_ROW – LCD screen size.
  • MODEL – WCS sensor model number (for example, 12 for WCS1800).
  • SENSOR_PIN – Arduino analog input reading VOUT from the sensor.
  • SENSOR_VCC_PIN – Digital pin controlling sensor power.
  • ZERO_CURRENT_WAIT_TIME – Calibration time during which no load should be connected.
  • SHOW_ZERO_CURRENT – Whether to display the saved zero-current voltage on the LCD.
  • CORRECTION_VLALUE – Small offset correction in mA to improve accuracy.
  • MEASUREMENT_ITERATION – Number of samples averaged per reading.
  • VOLTAGE_REFERENCE – Arduino analog reference voltage in millivolts.
  • BIT_RESOLUTION – ADC resolution (10 for most Arduino boards).
  • DEBUG_ONCE – Controls whether debug information is shown once or continuously.
  • TITLE_CURRENT – LCD label for live current reading.
  • TITLE_ZERO_CURRENT – LCD label for zero-current reading.

How the LCD Version Works

At startup:

  1. The sensor library waits for the zero-current period (e.g., 5 seconds).
  2. The LCD displays “Zero Current:” and the measured offset.
  3. Once calibration is complete, the LCD switches to “Current:” mode.
  4. The current value is refreshed continuously without using the Serial Monitor.

If SHOW_ZERO_CURRENT is set to false, the LCD will skip the zero-current display and show only the live reading.

Using the Current Reading in Your Project

Although the LCD shows the value automatically, you can still use the sensor output in your logic:


if(sensor.getCurrent() >= 10.0) {
    // trigger relay, alarm, fan, etc.
}

The library calculates the value in amperes, so it can be used directly in mathematical formulas and safety routines.

Conclusion

This project demonstrated how to integrate Winson WCS current sensors with an LCD1602 or LCD2004 I2C display using the Robojax_WCS library. The LCD lets you build a fully stand-alone current meter without Serial Monitor. Zero-current calibration, current reading, and labeling are all handled automatically. This same setup works with all WCS models supported by the library, making it ideal for portable current-measurement projects, battery analyzers, solar systems, and power-monitoring tools.

Images

Wiring WCS: DC load
Wiring WCS: DC load
Wiring WCS: DC load
Wiring WCS: DC load
Wiring WCS: DC load
Wiring WCS: DC load
Winson current sensor with LCD
Winson Current Sensor with LCD
Winson Current Sensor
Winson Current Sensor
Winson Current Sensor with LCD 2004 Initial Boot
Winson Current Sensor with LCD2004 Initial Boot
Winson Current Sensor with LCD 2004
Winson Current Sensor with LCD2004
Winson Current Sensor with LCD2004
Winson Current Sensor with LCD2004 2
Winson Current Sensor with LCD1602 Initial Boot
Winson Current Sensor with LCD1602 Initial Boot
Winson current sensor with LCD1602 and Arduino UNO
Winson Current Sensor with LCD1602 with Arduino UNO
Winson Current Sensor with LCD1602
Winson Current Sensor with LCD1602 O
S23-09-WCS1888-LCDr_wiring
S23-09-WCS1888-LCDr_wiring
179-Arduino code for an I2C scanner
Language: C++
// --------------------------------------
//http://playground.arduino.cc/Main/I2cScanner
// i2c_scanner
//
// Version 1
//    This program (or code that looks like it)
//    can be found in many places.
//    For example on the Arduino.cc forum.
//    The original author is not known.
// Version 2, June 2012, Using Arduino 1.0.1
//     Adapted to be as simple as possible by Arduino.cc user Krodal
// Version 3, Feb 26, 2013
//    V3 by louarnold
// Version 4, March 3, 2013, Using Arduino 1.0.3
//    by Arduino.cc user Krodal.
//    Changes by louarnold removed.
//    Scanning addresses changed from 0...127 to 1...119,
//    according to the i2c scanner by Nick Gammon
//    http://www.gammon.com.au/forum/?id=10896
// Version 5, March 28, 2013
//    As version 4, but address scans now to 127.
//    A sensor seems to use address 120.
// Version 6, November 27, 2015.
//    Added waiting for the Leonardo serial communication.
//
//
// This sketch tests the standard 7-bit addresses
// Devices with higher bit addresses might not be seen properly.
// Watch Video explaining I2C address: https://www.youtube.com/watch?v=bqMMIbmYJS0
//
 
#include <Wire.h>
 
 
void setup()
{
  Wire.begin();
 
  Serial.begin(9600);
  while (!Serial);             // Leonardo: wait for serial monitor
  Serial.println("
I2C Scanner");
}
 
 
void loop()
{
  byte error, address;
  int nDevices;
 
  Serial.println("Scanning...");
 
  nDevices = 0;
  for(address = 1; address < 127; address++ )
  {
    // The i2c_scanner uses the return value of
    // the Write.endTransmisstion to see if
    // a device did acknowledge to the address.
    Wire.beginTransmission(address);
    error = Wire.endTransmission();
 
    if (error == 0)
    {
      Serial.print("I2C device found at address 0x");
      if (address<16)
        Serial.print("0");
      Serial.print(address,HEX);
      Serial.println("  !");
 
      nDevices++;
    }
    else if (error==4)
    {
      Serial.print("Unknown error at address 0x");
      if (address<16)
        Serial.print("0");
      Serial.println(address,HEX);
    }    
  }
  if (nDevices == 0)
    Serial.println("No I2C devices found
");
  else
    Serial.println("done
");
 
  delay(5000);           // wait 5 seconds for next scan
}
347-Arduino code for Winsen WCS Current Sensor with LCD
Language: C++
/*
 * Read the current Winson WCS Current sensor and display it on LCD1602 or LCD2004 with I2C
 * This is Arduino code based on the Robojax WCS library 
 * for Winson WCS Current Sensor to measure current

  Get the Robojax WCS Arduino library: http://robojax.com/L/?id=230
  
 * Watch video instructions for this code with LCD: https://youtu.be/-pg7jbkaB6A
 * 
 * Related Videos:
 * Introduction to Winson WCS Sensors: https://youtu.be/z-s8UvCWGxY
 * Using Relay to disconnect load at certain current:
 * Using Modules without Arduino to control relay at certain current:
 * Measure Current using ESP8266 NodeMCU, D1 Mini over Wifi
 * Measure current using ESP32 Bluetooth on mobile devices
 * 

 * Written on July 26, 2020 by Ahmad Shamshiri in Ajax, Ontario, Canada
 * www.Robojax.com
  Model of the sensor to select 
     //direct wiring series
    0  "WCS38A25",//0
    1  "WCS37A50",//1
    2  "WCS2801",//2
    3  "WCS2702",//3
    4  "WCS2705",//4
    5  "WCS2810",//5
    6  "WCS2720",//6
    7  "WCS2750",//7
    8  "WCS3740",//8
      
      //through hole sensor
    9  "WCS1500",//9
    10  "WCS1600",//10
    11  "WCS1700",//11
    12  "WCS1800",//12
    13  "WCS2800",//13
    14  "WCS6800",//14
      
      //AC to DC Current sensor
    15  "WCS2202",//15


 * Get this code and other Arduino codes from Robojax.com
Learn Arduino step by step in a structured course with all material, wiring diagrams, and libraries
all in one place. Purchase My course on Udemy.com http://robojax.com/L/?id=62

If you found this tutorial helpful, please support me so I can continue creating 
content like this. 

or make a donation using PayPal http://robojax.com/L/?id=64

 *  * This code is "AS IS" without warranty or liability. Free to be used as long as you keep this note intact.* 
 * This code has been downloaded from Robojax.com
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <https://www.gnu.org/licenses/>.

*/
#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 powring up the sensor

//LCD settings
const uint8_t I2C_ADDRESS =0x3f;//watch video for details
const uint8_t LCD_CHAR= 16;
const uint8_t LCD_ROW = 2;
char *TITLE_CURRENT ="Current: ";
char *TITLE_ZERO_CURRENT ="Zero Current: ";
#define SHOW_ZERO_CURRENT true
//const int LCD_VCC_PIN =9;//define a VCC pin vor LCD see video for details

#define ZERO_CURRENT_WAIT_TIME 5000 //wait for 5 seconds to allow zero current measurement
#define CORRECTION_VLALUE 164 //mA
#define MEASUREMENT_ITERATION 300
#define VOLTAGE_REFERENCE  5000.0 //5000mv is for 5V
#define BIT_RESOLUTION 10 //Due or MKR, 12 bits
#define DEBUG_ONCE true

// creating object from Robojax_WCS Current sensor
Robojax_WCS sensor(I2C_ADDRESS, LCD_CHAR, LCD_ROW, 
           MODEL, SENSOR_PIN, SENSOR_VCC_PIN,
          ZERO_CURRENT_WAIT_TIME, SHOW_ZERO_CURRENT,
          CORRECTION_VLALUE, MEASUREMENT_ITERATION, VOLTAGE_REFERENCE,         
          BIT_RESOLUTION, DEBUG_ONCE, TITLE_CURRENT,  TITLE_ZERO_CURRENT        
          );  

// creating object from Robojax_WCS Current sensor
// this is used if you want to use a digital pin to supply 5V to LCD
// and leave the 5V pin free for other purpose	
/// uncomment the 7 lines bellow by removing the // from the begining of lines	  
//Robojax_WCS sensor(I2C_ADDRESS, LCD_CHAR, LCD_ROW, 
//           MODEL, SENSOR_PIN, SENSOR_VCC_PIN,
//          ZERO_CURRENT_WAIT_TIME, SHOW_ZERO_CURRENT,
//          CORRECTION_VLALUE, MEASUREMENT_ITERATION, VOLTAGE_REFERENCE,         
//          BIT_RESOLUTION, DEBUG_ONCE, TITLE_CURRENT,  TITLE_ZERO_CURRENT,
//          LCD_VCC_PIN		  
//          );  
		  
void setup()
{
  Serial.begin(9600);
  Serial.println("Robojax WCS Library");
  sensor.begin();
  Serial.print("Sensor: "); Serial.println(sensor.getModel());
  Serial.print("Library Version:");Serial.println(sensor.version());
  //sensor.printModels();//prints all supported WCS models

}

void loop()
{ 
  //Robojax.com WCS Arduino Library
  sensor.readCurrent();
  delay(1000);
  //sensor.printDebug();
  //sensor.printCurrent();//prints the current on serial monitor
}

Resources & references

Files📁

Other files