Author Topic: A timer hack  (Read 2427 times)

A timer hack
« on: 20 August, 2021, 11:36:53 am »
Anyone fancy contributing thought to a little project?

A couple of years ago, I bought some semi-decent espresso making machinery, including a manual grinder. At the time I baulked at spending the extra for any dosing options, the on demand timer version of the grinder I bought was over £100 more. I figured at the time that I would be able to judge the amount ground reasonably (or at least, sufficiently for my purposes), which proves to be largely the case. However, the option of a timed grind still seems attractive, so I've been considering how it might be achieved.

I thought Arudino or Raspberry Pi (as generic types) might be the way to go, and bearing in mind  I know little about them and have never used them, started to consider the options

Features needed:
  • Ability to switch on grinder for n seconds
  • Ability to configure the number of seconds

Features desired
  • Ability to cancel process
  • Ability to override process (existing switch in parallel?)
  • Fit inside ginder case

Comparison:

ArudinoRaspberry Pi
=====================================
Is a dedicated control devicegeneric compute
Can be very smallrelatively large
Low power higher power draw
Directly control solid state relaymay need interface
no inbuilt comms *excellent comms

*IoT stuff may fix that


That all leads me to think that the Arudino style microcontroller is the way to go, without have the faintest idea of how it will happen. This appears to be a suitable starting point, directly controlling something like this.

Does anyone have any better ideas, or knowledge of how that might be controlled ? An app on the phone would work as it would be changed only infrequently. It should be possible to drop those bits with a PSU into the grinder case, leaving the relay switch in parallel with the existing manual switch to give the override. PSU would be 5v I assume, so a hacked USB charge should work.

Oddly, nobody appears to have done anything like this and published the results.

Re: A timer hack
« Reply #1 on: 20 August, 2021, 11:57:06 am »
There are lots of timer modules on eBay that could almost certainly do all that, though you'll likely need to decode a lot of Chinglish and watch some awkward YouTube demo videos to work out exactly which one you want.

Re: A timer hack
« Reply #2 on: 20 August, 2021, 12:11:05 pm »
There are lots of timer modules on eBay that could almost certainly do all that, though you'll likely need to decode a lot of Chinglish and watch some awkward YouTube demo videos to work out exactly which one you want.

I had looked at them, but my impression after my initial scan of those was that it appeared unlikely to be able to fit into the case, and would therefore have to be a separate box, which is sub-optimal. The normal timing device operates in the hours scale, darkroom timers being the obvious exception, and stuff like this which is bulky or this which is bulky and inflexible. The more you look into it the more you realise that actually, the use case I'm trying to fill is relatively esoteric. And making something up sounds like it might be fun.

Re: A timer hack
« Reply #3 on: 20 August, 2021, 04:08:55 pm »
An Arduino can be programmed over USB from a PC. You need to install the (free) Arduino software on the computer, and find a mini USB lead.

You need a 5 V power supply to run the Arduino. That can be connected using the mini USB connector.

The Arduino will remember it's programming indefinitely without power.

A simple pushbutton as a start/stop button and a solid state relay might be all you need. It just depends on how easily you want to be able to check and adjust the time, and if you need a countdown display. If you don't mind getting out the computer and changing the number on there, you don't need any more hardware. If you want a screen with the number, up and down buttons, pretty graphics, WiFi and a web interface, those will all take loads more work than a functional timer.

I suggest and Arduino MKR, on the basis that they are smaller and do what you want.

Alternatively, there is an IC designed to run toasters, that you can probably repurpose:- https://www.mouser.co.uk/ProductDetail/Diodes-Incorporated/PT8A2514APE?qs=iC14BvcgY%2F2jW3uqlZRovg%3D%3D
Quote from: Kim
Paging Diver300.  Diver300 to the GSM Trimphone, please...

Re: A timer hack
« Reply #4 on: 20 August, 2021, 05:09:52 pm »


Alternatively, there is an IC designed to run toasters, that you can probably repurpose:- https://www.mouser.co.uk/ProductDetail/Diodes-Incorporated/PT8A2514APE?qs=iC14BvcgY%2F2jW3uqlZRovg%3D%3D

From the datasheet "Adjustable timer: 30s~10mins" sounds like it would not be useful. Typical grind time is about 10 - 20 seconds.

The control system I'm thinking of is that there are three micro buttons, Increment up (in 0.5/1 sec), increment down and reset (maybe a fourth, clear and reset?) which doesn't sound like a programming headache. It would be handy if the setting goes into non volatile, too, do you know if that's possible? Once set it wouldn't need to be changed often.

Anyone know if the inductive load of the motor presents a problem to the SSR? I suspect it is a dc motor. (ETA, the 8mf capacitor across would seem to confirm that)

Kim

  • Timelord
    • Fediverse
Re: A timer hack
« Reply #5 on: 20 August, 2021, 06:45:11 pm »
Consider something like the ESP-8266 or ESP-32 if you decide to go down the microcontroller route.  They're small, have integrated WiFi, and a *lot* more computational grunt than the traditional ATMega Arduino boards.  You can get easy to work with dev boards like the Wemos D1 mini and treat them as an Arduino (just install the relevant board definitions in the IDE).

And if you're doing that, it's probably worth checking whether Tasmota will do everything you need without you having to roll your own software.

I'm not clear about how your grinder works, but if you could do it all by switching the mains supply, you could run Tasmota (or your own Arduino/whatever code) on a Shelly or ESP-based smart plug.

Re: A timer hack
« Reply #6 on: 20 August, 2021, 06:45:54 pm »
You could probably squeeze the toast timer to 10 seconds, or slightly more. The maximum oscillation frequency is stated to be 20 kHz, but you might be able to go a bit faster. The time is 245720/[freq] so it is specified to go down to 12 seconds, and might well go to 10 seconds.

The Arduino can remember settings, and there is code available for that. The memory is only rated to 10,000 re-writes, so the code should never write to the memory unless the user has actually changed the settings.

The increment up and down is fine, but you might want something to show how long the timer is set for. Simplest would be a couple of 7 segment displays.

An SSR shouldn't have a problem with the motor if a snubber is added. Something like this https://uk.farnell.com/roxburgh/re1201/cap-0-1-f-275vac-20/dp/2336109 will help to reduce spikes.

The motor is AC. The capacitor is a typical "run capacitor" for a single phase AC induction motor.
Quote from: Kim
Paging Diver300.  Diver300 to the GSM Trimphone, please...

Re: A timer hack
« Reply #7 on: 20 August, 2021, 08:51:06 pm »
Confused? I soon will be.
Consider something like the ESP-8266 or ESP-32 if you decide to go down the microcontroller route.  They're small, have integrated WiFi, and a *lot* more computational grunt than the traditional ATMega Arduino boards.  You can get easy to work with dev boards like the Wemos D1 mini and treat them as an Arduino (just install the relevant board definitions in the IDE).

And if you're doing that, it's probably worth checking whether Tasmota will do everything you need without you having to roll your own software.

I'm not clear about how your grinder works, but if you could do it all by switching the mains supply, you could run Tasmota (or your own Arduino/whatever code) on a Shelly or ESP-based smart plug.

Computational power doesn't seem relevant, the core program is three, possibly four functions and I'm sufficiently pig headed to think I can manage that. What starts to give me the heebie jeebies is the comms to and from the unit, and where and how I write that, but I'm consoled by the idea that it such a fundamental part of using these bitsakit that it can't be beyond the grasp of man. Hopefully, not beyond this one either.

How to talk is interesting. I've not yet stripped it down at all, but I think it has a solid metal casting case, but there are apertures. I was thinking BLE might be the way to go, but that also is one of the reasons those three switches sound attractive.

The grindr has an on off non-latching switch activated by pushing the portafilter holder in. I did consider smart plugs, but that would be clunky. I'd either need to bypass the existing switch to always on, or combine the actions. Having the control on the grinder body itself is the most elegant solution.



The motor is AC. The capacitor is a typical "run capacitor" for a single phase AC induction motor.

Good point, it also goes to substantiate the overall weight.

Re: A timer hack
« Reply #8 on: 20 August, 2021, 09:28:02 pm »
What starts to give me the heebie jeebies is the comms to and from the unit, and where and how I write that, but I'm consoled by the idea that it such a fundamental part of using these bitsakit that it can't be beyond the grasp of man.

The standard bodge is to use a relay to activate to bridge the switch contacts on the device's original UI.  That keeps your circuitry completely isolated from whatever's on the device and means you don't have to do any reverse engineering.

It also sounds like you'll inevitably interfacing with mains. I'd be looking to keep it completely separate from your bodging boards.

Kim

  • Timelord
    • Fediverse
Re: A timer hack
« Reply #9 on: 21 August, 2021, 12:22:39 pm »
Computational power doesn't seem relevant, the core program is three, possibly four functions and I'm sufficiently pig headed to think I can manage that. What starts to give me the heebie jeebies is the comms to and from the unit, and where and how I write that, but I'm consoled by the idea that it such a fundamental part of using these bitsakit that it can't be beyond the grasp of man. Hopefully, not beyond this one either.

It's the comms that need a heftier computer, unless you're doing a simple binary protocol over a serial port.  You can speak TCP/IP over Ethernet with an ATMega 328p (and suitable hardware), but try to implement more than a very rudimentary web server or MQTT client with only 1k of RAM, along with whatever else it's doing (which probably includes network utility things like DHCP and MDNS), and things soon get tight.  I've got an Arduino Uno clone that counts the flashes of the blinkenlight on our electricity meter and reports the running total on a single web page, and that's pretty much maxed out the program memory.

The ESPs have a reasonable amount of both RAM and program memory for internet-of-things type applications.  It means you can do things like embed HTML or nice verbose command-line prompts in your program without having to resort to devious tactics, which greatly reduces the headache factor of simple automation projects.

(I don't know anything about Bluetooth programming, as I try to use as little of the Devil's Other Radio as possible.  Presumably you jump through the relevant hoops to set up the communicaiton and then you can exchange serial data with your app[1] or whatever.  I'd suggest a web server would be a good way to control this sort of application, as you can just use a web browser as a client.)


[1] Now you have two problems.

Re: A timer hack
« Reply #10 on: 21 August, 2021, 01:40:11 pm »
y'see, that's where I end up whimpering in a corner, and I find myself severely limited by my ignorance.

I don't really need to talk to it at all.

I need to have a way to start the grind - that was a button in my book, possibly
I need to be able to increment up and down the time, again buttons might be possible
I need to be able to reset

But if the buttons can't do it, then I need to be able to talk to it, serial comms passing a command line with parameters. But whadda I know?  nuffink.

SoreTween

  • Most of me survived the Pennine Bridleway.
Re: A timer hack
« Reply #11 on: 21 August, 2021, 04:19:49 pm »
How about a Rasberry pi pico?  Add a relay hat, a 4 digit 7 segment display hat and a couple of buttons & you should have a prototype running fairly easily. 
Or there's a natty looking teeny oled display with 2 buttons on pi hut, smaller than the 7 seg.   Buttons could be stop & start or hold to access other functions.
Is there space to fit that and a usb supply in the base of the grinder?  You'd likely need some shielding between it & the ac motor.

Kim's smart plug suggestion eliminates the supply and avoids electrical noise issues.
2023 targets: Survive. Maybe.
There is only one infinite resource in this universe; human stupidity.

Kim

  • Timelord
    • Fediverse
Re: A timer hack
« Reply #12 on: 22 August, 2021, 05:41:12 pm »
How about a Rasberry pi pico?  Add a relay hat, a 4 digit 7 segment display hat and a couple of buttons & you should have a prototype running fairly easily.

I'd suggest that this sort of thing is better served by a microcontroller (Arduino, PIC, that sort of thing) rather than an embedded Linux computer.  You *really* don't need an operating system (with filesystems, booting, and all that jazz) to implement a simple timer, or even a complicated timer with network comms (though being able to use things like python and ntpd might make the development process simpler, and if you're already familiar with doing things the Raspberry Pi way, that might be reason enough to use one).

[Has nobody suggested doing the whole thing with a 555 timer chip yet?  You're slacking...]

Personally, I'd avoid networking entirely, because that brings the sort of complexity that impacts reliability for little obvious benefit.  As Ham says, all it needs for a user interface is a rudimentary display and a few buttons.

Gattopardo

  • Lord of the sith
  • Overseaing the building of the death star
Re: A timer hack
« Reply #13 on: 22 August, 2021, 06:04:41 pm »
There are lots of timer modules on eBay that could almost certainly do all that, though you'll likely need to decode a lot of Chinglish and watch some awkward YouTube demo videos to work out exactly which one you want.

I had looked at them, but my impression after my initial scan of those was that it appeared unlikely to be able to fit into the case, and would therefore have to be a separate box, which is sub-optimal. The normal timing device operates in the hours scale, darkroom timers being the obvious exception, and stuff like this which is bulky or this which is bulky and inflexible. The more you look into it the more you realise that actually, the use case I'm trying to fill is relatively esoteric. And making something up sounds like it might be fun.

Look at the older galileo boards as they should be cheaper than a pi.

Re: A timer hack
« Reply #14 on: 22 August, 2021, 06:07:10 pm »
If you hack the device in a wireless way then you don't have to find space and drill holes to provide a user interface and you can do all of your hackery away from the mains.

It doesn't have to WiFi or IoS though. 433 Mhz gubbins like this would allow you to put your Arduino and whatever UI you create in a separate box.
https://www.ebay.co.uk/itm/282713792696

Re: A timer hack
« Reply #15 on: 22 August, 2021, 06:22:46 pm »
The grindr has an on off non-latching switch activated by pushing the portafilter holder in. I did consider smart plugs, but that would be clunky. I'd either need to bypass the existing switch to always on, or combine the actions. Having the control on the grinder body itself is the most elegant solution.
What about a Switchbot? https://www.switch-bot.com/products/switchbot-bot

Re: A timer hack
« Reply #16 on: 22 August, 2021, 07:57:09 pm »

[Has nobody suggested doing the whole thing with a 555 timer chip yet?  You're slacking...]


I did think of that, tbh but where's the fun in doing it easy? Also, I rather fancy getting to grips with this stuff, with an eye to moving on to other projects

If you hack the device in a wireless way then you don't have to find space and drill holes to provide a user interface and you can do all of your hackery away from the mains.

It doesn't have to WiFi or IoS though. 433 Mhz gubbins like this would allow you to put your Arduino and whatever UI you create in a separate box.
https://www.ebay.co.uk/itm/282713792696

don't think it works for me in this instance, but would be perfect for outside light control, thanks.


What about a Switchbot? https://www.switch-bot.com/products/switchbot-bot

It's one of those!

Wouldn't work as the existing on off switch is inaccessible with the portafilter in place to grind.

Kim

  • Timelord
    • Fediverse
Re: A timer hack
« Reply #17 on: 22 August, 2021, 08:14:46 pm »
The grindr has an on off non-latching switch activated by pushing the portafilter holder in. I did consider smart plugs, but that would be clunky. I'd either need to bypass the existing switch to always on, or combine the actions. Having the control on the grinder body itself is the most elegant solution.
What about a Switchbot? https://www.switch-bot.com/products/switchbot-bot

If that switch is mains-voltage, a Shelly 1 (which I already mentioned upthread).  It's a cute little mains-voltage device with an ESP-8266, a relay and single digital input.  The usual application is that you'd wire it into a lighting circuit at the ceiling rose (or equivalent junction) in order to smart-ify a light fitting, with the existing switch becoming a logical input to the Shelly, whose effect can be determined programmatically.

The Shelly software is quite home automation system oriented, but Tasmota[1] (which has a friendly interface on a local web server) could certainly be programmed to do things like "run for n seconds when switched on, switch off immediately when switched off".  I've got one in my bathroom light programmed to turn it off if there's nobody in the room for n minutes (it gets room occupancy over MQTT from other hardware), with the lightswitch behaving as you'd expect a multply-switched light circuit to do (none of this needing an app to turn the lights on rubbish).

It does tie you into the network for configuration (ie. changing that value of n seconds) though.  I think for this application I'd prefer buttons and a small display.


[1] Replacing the stock firmware on a Shelly with Tasmota is trivial.  You just need a USB to TTL serial dongle.  Or you could write your own application for it using the Arduino IDE.

Re: A timer hack
« Reply #18 on: 22 August, 2021, 09:49:39 pm »
tbh, function-wise if I was after a plug based solution a darkroom timer would be the obvious way to go.

Kim

  • Timelord
    • Fediverse
Re: A timer hack
« Reply #19 on: 22 August, 2021, 09:56:23 pm »
The Shelly isn't plug-based.  It's eminently suited to being fitted *inside* the case of an appliance; neatness is the point.

Re: A timer hack
« Reply #20 on: 22 August, 2021, 10:05:59 pm »
Ah.... I hadn't followed through that link. My bad. Hmmmmm

frankly frankie

  • I kid you not
    • Fuchsiaphile
Re: A timer hack
« Reply #21 on: 23 August, 2021, 11:56:51 am »
I think I'd just use a smart switch.  "Alexa, switch grinder on for 40 seconds".  (oo-er)
when you're dead you're done, so let the good times roll

SoreTween

  • Most of me survived the Pennine Bridleway.
Re: A timer hack
« Reply #22 on: 23 August, 2021, 04:24:39 pm »
I'd suggest that this sort of thing is better served by a microcontroller (Arduino, PIC, that sort of thing) rather than an embedded Linux computer.  You *really* don't need an operating system (with filesystems, booting, and all that jazz) to implement a simple timer, or even a complicated timer with network comms (though being able to use things like python and ntpd might make the development process simpler, and if you're already familiar with doing things the Raspberry Pi way, that might be reason enough to use one).
With respect Kim, you need to lookup what an RPi Pico is. I have not typo'd Pi Zero.
2023 targets: Survive. Maybe.
There is only one infinite resource in this universe; human stupidity.

Kim

  • Timelord
    • Fediverse
Re: A timer hack
« Reply #23 on: 23 August, 2021, 05:37:36 pm »
I'd suggest that this sort of thing is better served by a microcontroller (Arduino, PIC, that sort of thing) rather than an embedded Linux computer.  You *really* don't need an operating system (with filesystems, booting, and all that jazz) to implement a simple timer, or even a complicated timer with network comms (though being able to use things like python and ntpd might make the development process simpler, and if you're already familiar with doing things the Raspberry Pi way, that might be reason enough to use one).
With respect Kim, you need to lookup what an RPi Pico is. I have not typo'd Pi Zero.

Oh, they've launched a new thing while I wasn't looking.  Yes, that's much more appropriate, if somewhat confusingly named.   :thumbsup:

Re: A timer hack
« Reply #24 on: 23 August, 2021, 05:40:56 pm »

[Has nobody suggested doing the whole thing with a 555 timer chip yet?  You're slacking...]


Didn’t want to give away my age ..
What's this bottom line for anyway?