So I made myself a cable like this, with a section of the outer insulation cut away so that I could separate the insulated conductors inside and put the clamp around just one of them.
When I tested it with the plain, unmodified coffee machine and found that it was quite easy to tell when the heater was running and when the PTC hotplates were on. Because of that I’m not going to bother with any internal interventions inside the machine at all.
I used emonlib (https://github.com/openenergymonitor/EmonLib) and the plain current_only.ino example. Worked great, and I noticed a few interesting things. The clamp can be calibrated to give actual representative current values but I don’t care about that, I just need any old numbers so I went with the standard calibration numbers that were in the code.
Bottom PTC – peaked at 20,000 for less than a second when it turns on, then settles down to 2,500.
Top PTC – peaked at 19,000 and settled at 4,000.
Heater – immediate goes to about 52,000
So I think I can simply set a threshold around 40,000 and expect that breaking this threshold means that the heater is on. There’s no ambiguity about the hotplates and the heater. I’m going to make a cable with separate conductors that won’t terrify the electricians at work, and just use that.
I’ve just committed https://github.com/euphy/coffee_boss/blob/master/coffee_boss/coffee_boss.ino which is the code to read all these things:
DS3231 Realtime clock on the i2c buss (SDA is 21, SCL is 22)
load cells with the HX711 ADC on pins 4 and 15
VCNL4010 proximity sensor on the i2c buss
current sensor on pin 14
And the breadboard looks like this:
Next up is to make a little mount for the proximity sensor that holds it near the carafe.
Doing a bit more digging about the current clamp tells me something I realised was obvious in retrospect – the clamp needs to be around a live wire on it’s own. Clamping it over the multi-core mains cable won’t work because the EM field from the live wire and the return path through the neutral wire cancels each other out.
That’s why the clamp last night (and today, with the proper value components around it) shows no change whether the heater is on or not. OK. There’s some high-end sensors that can sense current in multi-conductor cables but the only accessible one I can see is this Modern Device one (https://moderndevice.com/product/current-sensor/). It looks like it’ll work great and isn’t expensive ($14), but it’s not a nice tidy clamp.
Build a device that can be placed inline with the power cable that will allow the sensor access to only one of the wires in the cable. This could just be a customised power cable, quite easy to make but liable to raise an eyebrow from the estates people at work. This means having to understand the difference between the heater running and the hotplates.
Mount the current clamp inside the coffee machine, over the wire that goes to the heater. This is non-invasive-ish, but I’m a little nervous about proximity to the heater and also having trailing wires hanging out of the coffee machine. This would give a nice unambiguous and accurate signal of when the heater is running though.
Tap or sense the wire that the float switch is on. The float switch is in the water reservoir and is what triggers the heater to run. This may well be low voltage, and DC so I think a current sense clamp won’t make anything of it. The cable is terminated with plain plugs and sockets that look fairly standard so I could just make a special cable that has a sensor on it to pull a pin high or low when it’s closed or opened. I still don’t like the idea of having cables trailing out of the coffee machine. Perhaps I can make something discrete in the base – there is plenty of space, and routing for a cable out the bottom (the cable for the hotplate uses it). Maybe even some pogo pins on the bottom that would integrate with a little board mounted on the scales that the whole machine sits on.
I think option 3 is my favourite. It’s likely to avoid working with high voltage or current and that cable assemble looks easy to do something with in a reversible way. I need to see how to use a pin to sense the open or closedness of that switch. I feel like that should be easy.
I can’t find any description of the connector on the float switch. It looks like a KK-396 housing https://uk.rs-online.com/web/p/pcb-connector-housings/6795066/ except measuring the pins looks like the pitch is 3.6 or 3.7mm rather than 3.96mm.
Those last graphs were nice but I don’t think they tell me enough. The graphs and the analyses make intuitive sense to the eye but they’re still disconnected enough from concrete reality to make it hard to put the numbers into context. I’ve run up against the limit for what my simple-minded analytics can do for me. I could learn more analytic skills, you know like nunchuck skills, bowhunting skills, computer hacking skills. But I won’t, I’m just going to brute force it with more sensors.
I’ve got an AC current sensor (SCT-013-000 Non-invasive AC Current Sensor Clamp Sensor 100A High QUALITY!!!) and an Adafruit VCNL4010 proximity sensor.
Inside the coffee machine
The coffee machine has a float switch in the water reservoir that it triggered as long as there’s water left in. I don’t really know how the heater/pump works or even if there is a pump there or if it’s some kind of expansion thing powered by the heater on it’s own. I looked inside:
And I’m not sure what to make of that, doesn’t look like a mechanical pump but water goes in the bottom that is discoloured from heat, and comes out the top tube going up to the sprinkler-head.
There’s two wires running from the controller mechanism on the left to the heater capsule, and they look the same as the ones leading from the main 240v input connector (bottom left) as well as sharing the same connector, so I’m going to surmise that this is a 240V AC heater.
Searching more, I find this: https://www.gastroparts.com/en/part-113792 which is a “flow heater”, 2160W, 240V. Power divided by voltage gives current so 2160W / 240V = 9A.
Ideally I’ll put the current clamp on those two wires so it only senses when the heater is running. I’d prefer not to have something mounted inside the machine since I’ll get the blame if the office burns down.
So I’ll test this system with the clamp fitted on the main power cable instead, and see how hard it is to recognise the “heater running” signal from the “hotplate” on signal. If it’s obvious, then that’s ideal. If it is indistinguishable then I’ll try it inside.
Looking at the link above, I should do some sums to figure out how to wire up the current sensor. I don’t really understand this so will be Just Doing As I’m Told.
I picked 13A as I wanted to leave a little headroom over the current that the heater would draw in case the hotplate is on too. I can’t find any spares for that bit yet so don’t know what that’ll draw.
I need a 180ish ohm burden resistor and a 10uF capacitor. I’ll get those from the workshop tomorrow.
I wired this up and found that there was a constant stream of numbers coming out, between 200 and 400, but turning the load on or off didn’t make any difference. In fact it’s the same whether it’s clamped over a cable or not, so I think this is just electrical noise. Boo.
Update! With the cap and burden resistor… Exact same response as last night ie fairly stable number coming out of this sensor, but no relation to whether the device is on or not. So… I was testing it with the clamp on the mains lead of a heater. It needs to be on just one wire because both wires cancel each other out. I’m going to have to build an intercept box for the power cable to go mount externally, or mount the clamp inside the coffee machine, on one of the cables near the heater. OK – that’s some more useful information. I wonder if there’s a way to get the signal out of the machine without trailing wires out of it? I don’t want it to fail it’s PAT test and inspection.
VCNL4010 Proximity sensor
This is a short-range IR-based proximity sensor chip mounted on a neat little breakout board. It uses i2c but there’s also an adafruit library for it so I don’t need to cry about the bus.
I’m planning to mount this on a little plate directly on the coffee machine behind the collar of the carafe so that it can be used to sense the presence or absence of the coffee jug.
Adafruit have info about this module here https://learn.adafruit.com/using-vcnl4010-proximity-sensor/overview and docs for the arduino library here: https://adafruit.github.io/Adafruit_VCNL4010/class_adafruit___v_c_n_l4010.html. I tried the standard vcnl4010test.ino example that came with the Adafruit_VCNL4010 library and found that the measurement maximum distance was about 45mm which is _just_ too short for my application. It is sensitive up close (5-20mm) but tails off the further away you get.
I noticed from the docs though that I could turn up the power on the LEDs in the proximity sensors (it uses a time-of-flight thing!) so I turned that up to maximum (indicating 200mA). Made no difference.
I could still mount this sensor on a little tower so it is closer to the carafe ring. It would be fairly well protected from bumps but I did want to keep this quite compact and unobstrusive. Is one of those ultrasonic detectors the answer? I think I have one in that kit that Euan gave me that time. I’ll check tomorrow.