![]() |
Forum Index : Microcontroller and PC projects : Coffee time
Author | Message | ||||
TassyJim![]() Guru ![]() Joined: 07/08/2011 Location: AustraliaPosts: 6223 |
Since our local favorite coffee shop closed, we have been having a lot more coffee at home. The problem was, the coffee machine needs 20-30 minutes to warm up to give the best coffee and we really want the coffee fix as soon as we get home. What I needed was a means of turning the machine on 30 minutes before we get home. Easily done with a maximite. I decided to use the phone to call home. My first thought was a microphone attached to the answering machine and this would be my preferred method if I only had one phone line. Fortunately, I have 2 VOIP phone lines and one never got any use. I decided to 'butcher' a spare phone. The phone is old enough to use large (not SMD) components so attacking it was easy. The output from the ring IC is a 30V square wave driving a piezo transducer. This was connected to an opto-isolator to trigger the micromite. The audio is sent to a 8870 DTMF decoder module. This outputs 4 bits of data and a 'data available' signal. The micromite drives a few relays, one to 'pick up' the phone when a ring is detected and 2 to drive the power point remote control. The coffee machine power point is controlled by a Kambrook' controller but any brand that has separate buttons for ON and OFF will do. ![]() The photo shows The phone Breadboard with the opto-isolator and capacitors to isolate the phone from the ground of the micromite. DTMF module Micromite Relay module for controlling the Kambrook controller and phone 'off hook' Lastly, the transmitter for the Kambrook controller. After a couple of successful 'warm coffee machine waiting when we get home' trips I discovered two things. 1. The wife finally thinks I am not wasting ALL of my time. 2. I need to add some audio feedback to indicate when a command has been received. The next job is to reduce the size so it can all fit into the phone body. The Basic code is very rough and will get a full rewrite as well. Warning. Doing this on the normal Australian fixed phone system would be illegal. Using a microphone taped to the speaker of an answering machine is OK but connecting home brew gear directly to the phone system is a big no-no. ' coffee time
' TassyJim timeout = 20000 ' hangup after 20S with no DTMF detected badkey = 9 ' keying this number in causes an immediate hangup startkey = 11 ' 11 = "*" 12 = "#" - clears code ready for new entry mykey = 1234 ' master key code - not a good choice! initialcode = 22 ' initial value for mycode (forces use of startkey) mycode = initialcode ' stores the current code being entered coffeeON = 1 coffeeOFF = 0 pin_con=18 pin_coff=17 pin_hook=16 ' relay module requires 0V to operate, 5V for off SETPIN 18, OOUT ' coffee ON PIN(18)=1 SETPIN 17, OOUT ' coffee OFF PIN(17)=1 SETPIN 16, OOUT ' off hook relay PIN(16)=1 SETPIN 2, INTL, ringIN ' Ring detected SETPIN 3, INTH, toneIN ' DTMF code available SETPIN 4, DIN 'DTMF code Q4 SETPIN 5, DIN 'DTMF code Q3 SETPIN 6, DIN 'DTMF code Q2 SETPIN 7, DIN 'DTMF code Q1 IF MM.WATCHDOG THEN PRINT "Unexpected restart "+ TIME$ ELSE PRINT "Program started "+ TIME$ ENDIF DO ' IF online = 1 AND TIMER > timeout THEN online = hook(0) PAUSE 200 WATCHDOG 5000 LOOP END FUNCTION coffee(k) ' 0 for turn off, 1 for turn on IF k<>0 THEN k=1 PIN(pin_coff)=k ' make sure the other button is off PIN(pin_con)=1-k ' before setting the desired button PAUSE 500 PIN(pin_con)=1 ' set both buttons off PIN(pin_coff)=1 IF k = 0 THEN PRINT "Coffee OFF "+ TIME$ ELSE PRINT "Coffee ON "+ TIME$ ENDIF END FUNCTION FUNCTION hook(k) ' 0 for hangup, 1 for answer IF k<>0 THEN k=1 PRINT "Call answered "+ TIME$ ELSE PRINT "Hanging up "+ TIME$ ENDIF PIN(pin_hook)=1-k hook = k END FUNCTION SUB toneIN codeIN = PORT(4,4) IF readyToEnd = 1 THEN ' delay ending by one digit to fool hacker online = hook(0) mycode = initialcode access = 0 readyToEnd = 0 ENDIF IF codeIN = 10 THEN codeIN = 0 IF codeIN = startkey THEN PRINT "Code entry reset "+ TIME$ mycode = 0 access = 0 ELSE IF codeIN < 11 THEN ' digits 0 to 9 mycode = mycode*10 + codeIN ENDIF PRINT mycode IF access = 1 THEN IF mycode = coffeeON THEN x = coffee(1) IF mycode = coffeeOFF THEN x = coffee(0) IF mycode = coffeeON OR mycode = coffeeOFF THEN access = 0 : mycode = 0 ENDIF IF mycode = mykey THEN access = 1 mycode = 0 PRINT "Access granted "+ TIME$ ENDIF ENDIF IF mycode > 100000000 OR codeIN = badkey THEN readyToEnd = 1 ' too many digits or bad key entered. Delay exit until after next digit TIMER = 0 END SUB SUB ringIN PRINT "Call "+ TIME$ PAUSE 5 ' debounce delay IF PIN(2) = 0 THEN online = hook(1) TIMER = 0 mycode = initialcode ENDIF END SUB As the code stands, sending *12341 will turn the coffee machine on and sending *12340 will turn it off. Jim VK7JH MMedit |
||||
Geoffg![]() Guru ![]() Joined: 06/06/2011 Location: AustraliaPosts: 3272 |
Amazing (and brilliant) !!! Geoff Graham - http://geoffg.net |
||||
viscomjim Guru ![]() Joined: 08/01/2014 Location: United StatesPosts: 925 |
NICE!!! |
||||
memberx Newbie ![]() Joined: 20/04/2012 Location: AustraliaPosts: 24 |
Nice practical project Jim. Good to see a warning RE: Connecting to telephone line. You are using a wireless remote control to control coffee machine which is perfectly safe. But, some people may want to adapt this to control other Mains operated appliances on 230v, 220v and 110V AC. Therefore, similar warning may be useful to warn people that it is VERY DANGEROUS and ILLEGAL (in some countries) to play with Mains Electricity. |
||||
robert.rozee Guru ![]() Joined: 31/12/2012 Location: New ZealandPosts: 2405 |
when connecting to the phone lines these days, in new zealand at least, there seems to be a degree of ambivalence by all concerned - perhaps largely due to the vast array of phones being imported from overseas and sold locally without the items being in any way checked for safety or certified as being compliant. being compliant aside, there is one big NO-NO to be observed: bringing the AC mains anywhere near the phone lines. the most important thing to continued life and good phone service is keeping the two well apart. this can not be stressed enough. for the hobbyist, the safest approach is to make use of two easily and cheaply obtained items: 1. an external serial dialup modem that supports a headset - that is, has a microphone and earphone socket on the front. these can often be had very cheap second hand. via the serial port the modem: provides ring indicator (RI) and an ability to pickup the line, can generate DTMF tones, and hangup. via the earphone socket: isolated audio can be fed into a DTMF decoder, and recorded messages played to the calling person/device. one modem popular in new zealand 15 years ago was this one: ![]() ![]() 2. a solid-state relay, such as this one: http://www.ebay.com/itm/221522739619 solid-state relays are quite magic, able to be driven directly by an output pin from a processor, while keeping mains wiring safely isolated and out of the way. i've used them in a number of places to provide a simple solution. they do drop 0.6v on the AC side, so with a 10A load will dissipate 6w. your SSR can fit into a small-sized jiffy box with a mains lead passing in and out at one end, and a socket for the 3-30v control input at the other end. once the cover of the box is in place, it is all totally isolated and quite safe. using these two device (SSR and serial modem) you can knock yourself out in the knowledge that no matter what, you will continue to be able to make and receive phone calls, unhindered by the inconvenience of either burnt phone wiring or death. rob :-) |
||||
TassyJim![]() Guru ![]() Joined: 07/08/2011 Location: AustraliaPosts: 6223 |
I spent many years fixing computers that had been damaged/destroyed by lightning strikes which entered via the phone line. This is with approved modems, so I would not go as far as saying there is a 100% safety. I was very glad to be rid of the physical phone line to my house and rely on VOIP phones over a Fixed Wireless Internet connection. No phone once the UPS has run out of battery but a lot cheaper. Now, I play safe to protect my expensive modem/VOIP device. I did consider using an old modem but that required yet another plug pack power supply. Jim VK7JH MMedit |
||||
halldave![]() Senior Member ![]() Joined: 04/05/2014 Location: AustraliaPosts: 121 |
Any chance of posting a schematic |
||||
robert.rozee Guru ![]() Joined: 31/12/2012 Location: New ZealandPosts: 2405 |
|
||||
WhiteWizzard Guru ![]() Joined: 05/04/2013 Location: United KingdomPosts: 2927 |
Very creative Jim ![]() An alternative to using a landline (where there are potential legal issues) is to use an old mobile phone and a pay-as-you-go-sim. In the UK you can pick up an 'old' mobile phone for under £10. Use a pay-as-you-go sim card (available everywhere these days) and stick £5 credit on it. Then use a similar principle as you have done and it doesn't matter what you attach to it ![]() Also - if you get an Android phone then you can even write an app to interface with the MicroMite. This may sound daunting to some but is easily achievable with Basic4Android's excellent software. I have that on my ever expanding to-do list . . . Once again, nice application Jim! WW PS: Black with two sugars please! |
||||
TassyJim![]() Guru ![]() Joined: 07/08/2011 Location: AustraliaPosts: 6223 |
@WW For Android I use RFO Basic. I even wrote a version of MMEdit for it but I haven't done much with it. Too much fun with Maximites. I do have an old mobile phone which I might play with eventually but I will get the microphone attached to the answering machine working first as this is the best alternative for most users with a landline that can be shared with 'normal' use. I will publish some circuits once that is done. Sugar in your coffee? - one way to ruin a good roast. Jim VK7JH MMedit |
||||
halldave![]() Senior Member ![]() Joined: 04/05/2014 Location: AustraliaPosts: 121 |
@Tassyjim. Any chance of a OSX version of mmedit as that is the only program I use a windows box for? I'm pretty sure I know the answer already Regards David |
||||
TassyJim![]() Guru ![]() Joined: 07/08/2011 Location: AustraliaPosts: 6223 |
If you will supply a suitable OSX PC for me to develop on...... I assume that MMEdit runs OK under the OSX equivalent to Wine on Linux. I will be adding the option to specify an IP address instead of a serial port shortly. This, coupled with a serial to TCPIP (I use ser2net in Linux), will make talking to maximites a lot easier under Windows emulators. I found serial ports a pain under Wine. As part of this, I am also adding the ability to remember the last 10 connections which makes swapping between devices easier. I still intend to release MMEdit2 which has a native Linux version but, without a Mac box, no OSX version. Jim VK7JH MMedit |
||||
halldave![]() Senior Member ![]() Joined: 04/05/2014 Location: AustraliaPosts: 121 |
mmm... very tempting Objective C on XCode, I may have a MacBook that you can play with/have doesn't run latest Yosemite or Mavericks but does run xCode let me check the specs tonight regards David |
||||
![]() |
![]() |
The Back Shed's forum code is written, and hosted, in Australia. | © JAQ Software 2025 |