How to measure current with esphome?

Hello all,
I have been trying to measure current for a while now, I tried WCS1700 and it doesn’t seem to work or I haven’t used it correctly, I am looking for a tested solution or a working way on how to do it with WCS1700, or alternatively a way to read a 7 segment screen from a cheap/dumb current sensor

Thank you so much as this have been bothering me for a while now…

Edit:
I am now trying to read from a cheap current sensor with a screen that you can buy at any electrical shop at 1$ or so, as I found that it’s external current part has a varying resistance proportional to the current passing through so I’m going to test reading it’s resistance on my ESP8266 next…

The word “current” is used 19 times on this page esphome.io

2 Likes

I know but my local supplier has none of those and I need to wait for a long time if I was going to order online, right now I have WCS1700 only

You might be able to read the 7 segment with this Seven Segments OCR - Home Assistant

What makes you believe the WCS1700 will work with esphome? Have you seen someone who uses it, or are you just guessing?

Looking at the published notes on the wcs1700 you can just plug it into the ADC of an esp device.

1 Like

How have you wired it to your ESP? As Nick suggested, it just needs to have the analogue out wired to the ADC pin of your ESP. You will then need to code the ESP with the correct calibration lambda.

1 Like

I have connected it over ADC on A0 to an ESP8266 and with this code:

sensor:
  - platform: adc
    pin: A0
    name: "current"
    id: "current"
    icon: "mdi:flash"
    update_interval: 5ms
    unit_of_measurement: "A"
    raw: True
    filters:
      # - offset: 0
      # - multiply: 3.3   # calculate mains voltage (calibration)
      # - offset: -2.50   # compensate the offset (calibration)
      - max:
          window_size: 1000
          send_every: 1000
      # - multiply: 3.3
      # - multiply: 830.188

As you can see I tried many ways of reading and the result is always the same:
I only see a slight change in the readings and not exactly corresponding to the changing current.
I might be trying too fast so if you have a method of finding out the correct way I will be happy to try it.

Continuing the discussion from How to measure current with esphome?:

Thank you for the OCR docs I didn’t know it was already done as I have thought about how a camera could be better/cheaper after all the time wasted on this, I might give it a shot with a spare rtsp camera I have but I would like more of an electrical solution as in read from the pins on the screen.

I only bought the WCS1700 because I found no other AC current measuring module available.

I have tried getting readings from the wcs1700 but the readings dont seem very logical to me so I couldn’t calibrate it.

Please provide your wiring diagram. Write it on a piece of paper and scan/photograph it if necessary, it doesn’t have to be fancy.

1 Like

My wiring Diagram is as follows:
ESP8266-------------------------------WCS1700
A0 ----------------------------------------- Aout
Vin ---------------------------------------- VCC
GND -------------------------------------- GND
not connected -------------------------- Dout




Just checking, you need to separate the active and neutral wires and only pass one through the sensor core. If that picture is a power lead passing through the middle it will read zero as the fields cancel each other.

1 Like

Yes I only pass the live wire (red), neutral is blue in the picture…

It might be helpful if you tell us what product you have actually bought, and reference us a datasheet or something. I have only seen docs for the bare device like this http://www.winson.com.tw/uploads/images/WCS1700.pdf

You clearly have it attached to a board. Dunno what the board is.

1 Like

@nickrout @andy135 @sparkydave I also have the same datasheet and am unable to find a sheet for the whole board…
It says tho on the piece that it is a WCS1700
this one is the closest datasheet I can find as it looks similar (no board) and same number (WCS1700)
https://pdf1.alldatasheet.com/datasheet-pdf/view/714468/WINSON/WCS1700.html

UPDATE:
found it on a board here but datasheet link returns 404 :

These guys also have it without a datasheet:
https://www.electronicscomp.com/wcs1700-hall-current-sensor-module-with-over-current-protection

found this post in arduino forums about having the same board measuring DC but it is not solved:

UPDATE:
MORE INFO HERE:

The pixelelectric page seems most useful.

You obviously have a meter. What is the A0 voltage at various input currents?

1 Like

@nickrout 190-230 vAC
it’s the government grid power so it’s voltage won’t be affected by my direct usage but by the sum of everyone’s usage

EDIT:
I misread and thought you meant the AC voltage
I read about 2.5vDC on A0 last time but I also think it would change faster than the meter can read, I will go measure it right now… Ok I measured it and it’s stuck at 0 !!! so no wonder no sensible readings found.

Breakthrough 1:
After reading the pixelelectric page I tried adjusting the potentialometer and the red LED can be adjusted to turn on at specific currents such as 20A+ so it probably could be used as an over-current alarm sensor (I think the LED is the same as the DOUT) but I want actual readings more

@nickrout @andy135 @sparkydave
New Sensor: AD26B-22VAHM Beat Elnoor voltage & current sensor with screen
I have a dumb/cheap voltage & current sensor with a small screen that costs about 1$,
I have tested the external current part measuring resistance and it looks like it gives readings based on current.
Results on this cheap sensor:
As this is an AC current it changes between 90 ~ 194 Ohm when current is 19A on my multi-meter adjusted at 200Ohm measurement…
So do you think I can just measure the resistance with an ESP8266 and calibrate the output?
these are some pictures: (please ignore “unsafe” relay and wemos board near AC lines)


Focus on the circular component as it is attached to the main sensor and it looks like it has a varying resistance that changes proportionally to the current passing in the large wire through it, as I measured the two wires coming out of it and found logical sine wave changing resistance readings from 90~194 Ohm when current draw was about 19.0A

EDIT:
When I measured with a multi-meter the resistance was negative!
I didn’t think much of it at first but now I realize that a “resistance” should read the same both ways unless it is some kind that I don’t understand called “negative resistance”
So what could go wrong if I’m trying to measure a negative resistance with an ESP8266?
I’m basically going to try to supply 3.3v to it on one end then read the voltage out the other end and extend the circuit with another 100 Ohm resistance to ground to close the circuit with…

First new sensor test results:

I have connected a wemos d1 board to the said sensor component

diagram:
wemos d1 ------------------------- AD26B-22VAHM
V3.3 -------------------------------- red wire
A0 ---------------------------------- black wire
GND ----------R100-------------- black wire

code:

sensor:
  - platform: adc
    pin: A0
    name: "voltage"
    id: "voltage"
    icon: "mdi:flash"
    update_interval: 7ms
    unit_of_measurement: "V"
    raw: True
    filters:
      - multiply: 3.3 
      - max:
          window_size: 1000
          send_every: 100

readings when load dropping:

-22A = 3370
-12A = 2748
-10A = 2673
-9.7A = 2666
-9.6A = 2659
-4.8A = 2643
-4.7A = 2636
-4.6A = 2630
-3.9A = 2593
-3.8A = 2583
-3.7A = 2574
-3.5A = 2560

Readings when load increasing:
-stuck at 2500s except when motor load turns on it momentarily displays 3370

At first it was promising as I was testing by dropping the load,
But as I started increasing the load the voltage wasn’t going up in the same proportion (stuck in the 2500s) but momentarily if there was a motor load turning on it would increase the voltage to the maximum 3370 then drop again to 2500s

As best as I can tell the AD26B-22VAHM is a display, and the circular ring around the red wire is a current transformer. It will produce a current in proportion to the current in the red wire. They normally have a burden resistor to keep them safe. As you need to measure a voltage with the wemos you need a cct like this.
image
R2 and R3 bias the output to 1/2 the 3.3 Volts as the input is AC
R1 is adjusted so the current through it produces a voltage no more than 1.15 volts as the maximum Vin on the A0 pin is 3.3 .
Measure the Voltage out of the current transformer when it is connected to the AD26B-22VAHM.
The are lots of projects on this so use google.

1 Like

@andy135 Thank you so much for your help I will look it up on google and try to reduce the voltage to increase my reading range.
In the meantime can I keep it temporarily like this and linearly calibrate the output for now?
I’m really slow at soldering and wiring and only ok in programming haha.

Yes if you are happy,
But you could add a filter to your code to calibrate it.
This is from my power meter
image
I don’t really understand how it works but I copied it from

1 Like

@andy135
Right now I can only read up to about 19A then I hit max voltage so I will definitely try to reduce voltage and re calibrate my input but temporarily this is ok.

This is the code so far : ( still needs more refinement where there are big gaps for better accuracy )


sensor:
  - platform: adc
    pin: A0
    name: "current"
    id: "current"
    icon: "mdi:flash"
    update_interval: 7ms
    unit_of_measurement: "A"
    raw: True
    filters:
      - max:
          window_size: 1000
          send_every: 1000
          send_first_at: 1000
      - multiply: 3.3
      - calibrate_linear:
          # Map 0.0 (from sensor) to 0.0 (true value)
          - 2560 -> 3.5
          - 2574 -> 3.7
          - 2583 -> 3.8
          - 2593 -> 3.9
          - 2630 -> 4.6
          - 2636 -> 4.7
          - 2643 -> 4.8
          - 2659 -> 9.6
          - 2666 -> 9.7
          - 2673 -> 10
          - 2748 -> 12
          - 2857 -> 14.9
          - 2973 -> 15.5
          - 3009 -> 16.0
          - 3029 -> 16.6
          - 3095 -> 16.8
          - 3098.7 -> 17.0
          - 3105 -> 17.1
          - 3144 -> 17.5
          - 3200 -> 17.9
          - 3370 -> 22