Setting up a current sensor with d1_mini

I’ve been working on computers for 30 years and I have to say that HA/esphome are um… less than ideal software. To get anything to work you have to reboot often or the values don’t display etc etc. Entities seem impossible to get rid of. Not at all sure i want to build a network in building with not-great wifi, plenty of radio interference, and then have to be fixing things by rebooting HA every time.

Anyway, I can read current change in the logs for the device, so that’s a big step forward.
Still haven’t gotten esphome to display the values anywhere though - maybe if i turn HA off tonight it will decide to behave in the morning.

Thanks for the help. I think the only real problem was the yaml code, and updating that at least lets me know that the sensor is working properly even if I can only tell by looking at the log files.

esphome is fine. I use it with MQTT and have no issues.

HA started out with the model you have to restart it (early and often) which is the reason I stayed away for over a decade. I suspect it is better now, but it tries to make things easy. Sometimes making things easy actually makes them harder in some cases. Changing a device’s sensors is likely one of those cases that makes it hard for HA to keep up. Delete the device and add it back again and things will probably work.

OK, everything is working now.

The main issue is that for a while the only documentation I found talked about adc sensors, not ct_clamps. I have learned I need both to make this work, and it is working.

Functioning yaml file:

   esphome:
        name: grizzly-bandsaw-current-sensor
      
      esp8266:
        board: d1_mini
      
      # Enable logging
      logger:
      
      # Enable Home Assistant API
      api:
      
      # Enable Over-The-Air updates
      
      
      wifi:
        ssid: !secret wifi_ssid
        password: !secret wifi_password
      
        manual_ip:
          static_ip: 192.168.2.16
          gateway: 192.168.2.1
          subnet: 255.255.255.0
    
      sensor: 
      - platform: ct_clamp
        sensor: adc_sensor
        name: "Grizzly Bandsaw Current Sensor"
        id: grizzly_bandsaw_current_sensor
        update_interval: 2s
        accuracy_decimals: 2
    
      - platform: adc
        pin: GPIO17
        id: adc_sensor
        update_interval: 5s

Once I included TWO sensors, not one, the log files reflected correct measurements.
The only hangup after that was I had accuracy_decimals at 0, which meant that I’d need amps before it would display anything so I changed that to 2 and it now accurately displays output from the current clamp - about 28 ma from a heat gun on full power and 17 from it on a low setting.
I see that I can fine tune this to display approximate actual machine readings but as all I really want to know here is whether the machine is on or off, so I don’t really need that for now.

Thanks for all the good input, glad I was able to get this solved.

1 Like

Glad you got it working.

This is what happens when you purchase things that are poorly documented. The site that documents the board you purchased has not been updated in 4 years and includes no working example for esphome. It does have some firmware files, but they don’t look much better and are not explained well at all. This then leaves it as an exercise for the purchaser to figure out how to use the board. You have the opportunity to learn more this way, but that doesn’t seem to have been your goal. I usually prefer putting the time in up front to pick something that is highly likely to just work or need only minimal work to do what I want, especially if I am doing something reasonably simple/common. I save my efforts for those things that don’t currently have an easy/affordable solution.

Since you are using a current transformer, it reduces the current going through the primary (what your load uses to something much less). The sct13 typically has a 2000:1 ratio. I provided a link to a test report from open energy monitor.

I would first use the multiply filter to bring the numbers to where they are more meaningful

(multiply by 2000, to conert the mA you are currently seeing to amps which are what the sensor is sensing). You can add a calibrate filter if you want to try calibration, but not needed for your use case.

I have a chop saw and and table saw to which I connect a shop vac to suck up the sawdust real time. I employ this AC Current Detection Sensor Module to turn on the shop vac when the saw is running.

You could use the relay dry contacts or take the relay off and use the coil circuit with a resistor divider to a digital input of your ESP.

I learned a great deal from this project - and this is just one of many components I’ve been working on. Why neel-m would think that learning something wasn’t my goal - is beyond me.

One of the difficulties in building a project for any non-profit is that there isn’t a lot of money out there. Which means that you often have to trade well.documented.thoroughly.tested.but expensive products for less expensive but more complicated versions. I could have bought a commercial system for about $300 per unit (blast gate, radio communications, relays, sensors) but I’m doing it for about $15-30 per unit by slowly building the system from inexpensive parts and relying on others to occasionally help me when things aren’t working… which is what i think a lot of people on this forum do, and why people choose freeware software and spend time on forums asking for help…

As far as adding multipliers to sensor output or calibrate, there is zero need.
It doesn’t matter if it tells me there are 0.017 amps load or 17 amps - all I care about is whether the machine is drawing power, or not. I can deal in fractions as easily as in numbers in the hundreds, it’s just prettying it up, no more.

I will write Mottram labs and criticize the lack of support for his products - which, I don’t think would be at all hard for him to do… but then again, he’s almost certainly working on the product lines that earn him more than $3 per unit, which is what this cost me.

I could have gone with even cheaper units of the kind OldSurferDude mentions, but those units require cutting the wire and that means (in the real environment this will work in) circuit boxes, done professionally according to code - $$$ more.

Instead, I can encase these two items (d1_mini, mottram labs pcb) in a plastic box I can clip to the inside of the tool frame and clip the sct-013 over the power wire (also inside the cabinet) without the need for expensive electrical retrofitting.
I’m pretty confident that this solution will be the most durable (hidden inside a tool cabinet, without cutting wires, where it can’t be abused by the many users who abuse these tools) the easiest to install, and the least expensive solution for a client with no money.

Happy you are making progress and enjoying the journey. There is always more to learn. As long as your solution meets your needs, no one else’s opinion really matters.

I said what I said previously because not once until now had you said anything that I understood to mean something like “wow I am having so much fun learning all these things I didn’t even know I wanted to learn.”

I heard, “man this is so hard, why isn’t it easier.” Obviously, now I know that is not what you meant.

As far as the costs go, your comparison did not include the cost of the CT nor the esp. Your total cost per unit is still lower than a commercial product like the Shelly.

But for dust collection, most people/sites don’t have a collection system powerful enough to have all blast gates open, so they just put micro switches on the blast gates and use those to control the collector motor. Or, are you also automating that?

Maybe…
Shelly Em mini gen4 costs 20eur and compatible 3000:1 clamp is few euros on Aliexpress.

I was factoring in ALL costs which include a 3D printed blast gate with servo and d1_mini and current sensor (d1_mini + mottramlabs current sensor + SCT-013) plus relay to control DC plus current sensor to know if DC is already on. I estimate the blast gates at about $11 each and the current sensors at about $15 each and the DC sensor plus relay at about $18 each. As I have 4 different DCs plus different ranges of tools on each (two DCs have only two machines on them, one DC has three, one DC has up to 5) the costs will vary somewhat per group.
But compared to about $300 PER UNIT for a system that has an automatic blast gate and DC controller… it speaks for itself.
Some of the machines I could use a single d1_mini to control the gate, the relay and the current sensor, but the cost saving is pretty small and its probably just easier to fab them one for each function, as the DCs are on the floor below and there is space between machines that would complicate any such ‘costsaving’ measure.

I employ this AC Current Detection Sensor Module to turn on the shop vac when the saw is running.

Does this work without splitting the AC line? When using a clamp current sensor, I typically use an AC line splitter like this one.

(Sorry, I didn’t read the full thread first…)

I’m still curious, though. It isn’t a big deal to either separate the wires or make my own splitter – I could enclose it with the ESP and sensor – but I’d still like to know.

Well, yes and no.

Imagine a box with a power cord input, a normal switch and dual receptacle.

The switch is for turn everything on an off.

The phase output of the switch goes to:

  • the current detector
  • through the current transformer of the current detector and then to the unswitched receptacle of the dual receptacle.
  • the common of the relay; the normally open side of the relay goes to the phase of the switched receptacle of the dual receptacle.

The neutral goes to the current detector, and both sides of the dual receptacle.

I plug my saw into the receptacle I labeled “saw” and my shopvac into the receptacle I labeled “vac”.

So “no”, I don’t split the wire for the saw, I do that in the box. Thus I can use any saw, grinder, sander, or other device that generates a lot of dust.

-OSD