Awesome Coffee Server - ESP8266 based webserver IoT - Page 1
Forum section: electronics / general

author: frozenfrogz
author_rank: Frequent Contributor
timestamp: August 04, 2017, 11:02:53 am
content: Dear forum,I am working on an open source / open hardware project that started out as a remote switch for my coffee machine - hence the name. The initial build was put together on vero board but since this prototype has been running stable without issues for a couple of months now, I want to move on to making a PCB layout and pushing the project to my github for everyone else to fiddle with it. Of course all schematics, KiCAD files, BOM, and firmware will be released under a suitable license. I am thinking MIT license but suggestions are welcome - this is my first contribution to the OSHW world.The initial design consists of a Wemos D1 mini, one relay, MAX6675 + K-Type TC and a MeanWell IRM board mounted AC/DC 5V converter (Class II) enclosed in an industrial style plastic case.Now here is my question: With only one Class II isolated power supply on-board, is it of any use to control the relay via an isolated optocoupler?Mainly, I want to make the design as reliable and safe as possible, but I am not an electrician. What kind of safety features should I look into? Of course mains and low voltage circuits will be separated on the PCB and isolation slots incorporated to work against surface creepage.Also: This started out as a one-off build for my own purpose, but I thought others might be interested as well. I want to keep the platform as adaptable as possible so I am thankful for any suggestions / wishes of features to build in. All unused pins will be broken out to the edge of the PCB. I also thought about possible solutions for plug-in modules via industrial connectors but have yet to sort out some design decisions.At the moment, the webserver has the Wifi credentials hard coded into the firmware on upload. However I am working on a new version using a wifi manager and a physical switch to put the ESP into AP mode for configuration. Also firmware update OTA is on the list, but I did not implement it properly as of today.Here are some logo ideas/sketches you might or might not like, feedback is welcome tooPlease let me know what you think and fire away your suggestions.Thank you!FrederikEdit: Fixed broken links.

author: madires
author_rank: Super Contributor
timestamp: August 04, 2017, 12:46:17 pm
content: The opto coupler doesn't make sense when you power the relay and the MCU by the same PSU. And the relay driver needs some changes anyway. Connect the relay to 5V and use the NPN transistor to switch it to ground (for high side switching you'd need a PNP). Add a resistor in series with the LED to limit the LED's current.

author: frozenfrogz
author_rank: Frequent Contributor
timestamp: August 04, 2017, 01:03:12 pm
content: Oops, you are correct about the NPN. I slapped the initial drawing together last night a little to careless...Would opting for two separate power supplies be beneficial, or is that just unnecessarily adding to the overall parts cost?

author: madires
author_rank: Super Contributor
timestamp: August 04, 2017, 01:39:07 pm
content: The relay provides isolation already, no need for an opto coupler. BTW, what is the purpose of connecting L to the relay and the screw terminal? How do you intend to switch the coffee machine?

author: ebastler
author_rank: Super Contributor
timestamp: August 04, 2017, 01:53:39 pm
content: Apologies if this is obvious to everyone else -- but you have not described yet what your gadget actually does, have you? WiFi-controlled power adapters are already widely available. What's the function of the thermocouple? Does it interact with the switching functionality, or provide remote reading of the coffee temperature via a companion app?

author: frozenfrogz
author_rank: Frequent Contributor
timestamp: August 04, 2017, 02:09:08 pm
content: Quote from: madires on August 04, 2017, 01:39:07 pmRight now this is a "relic" (not fully diagrammed) from the current implementation. Inside my Gaggia Classic coffee machine the ESP board is supplied via the machines mains inlet, so the server is always running. The relay is wired in series with the power switch. That way the machine will not power on if the switch is set to of. This allows for keeping the original state of usage if the relay is switched on.Regarding the functionality, it started of as a simple project to satisfy my need to be a lazy arse. I wanted to be able to preheat my coffee machine remotely and read back the current temperature. I planned for sending an alarm when preheating is done but have yet to implement it.The device sits on my local network behind a firewall because I do not want to have it working "that" remote.Currently I am thinking about some possible directions to push this project out of the very niche of switching on a coffee machine. However, implementation of RFID access control for a shared-office machine might be one possible use case quite easy to do.I looked at a couple of cheap wireless relays but was not very pleased with what I could do with them. Usually there is no option to implement additional functionality, because the unused ESPs pins are not broken out and getting supply voltage for a display or whatever you want to drive needs to come from a separate power source etc.

author: frozenfrogz
author_rank: Frequent Contributor
timestamp: August 04, 2017, 03:42:59 pm
content: Damn. I just saw, that this post had failed to be removed by me. I opened this thread and then remembered the OSHW section. So I pushed delete here and reopened the thread in the OSHW board. However, the thread here had not been removed... Looks like I need to contact a mod - oh well.Here is what I came up with so far...

author: madires
author_rank: Super Contributor
timestamp: August 04, 2017, 06:25:45 pm
content: Presumably you have to lower the NPN's base resistor to drive the NPN into saturation.

author: frozenfrogz
author_rank: Frequent Contributor
timestamp: August 04, 2017, 09:29:27 pm
content: Quote from: madires on August 04, 2017, 06:25:45 pmThe relay coil is rated for 72mA current at 5V nominal (datasheet).H_fe_sat @I_CE 72mA of the NXP BC817-40 is around 350, taken fromthis datasheet.My calculations for the base resistor are:I_B = I_CE / H_feI_B = 72mA / 350I_B = 0.2mAR_B = (U_B - U_BE) / I_BR_B = (3.3V - 1.2V) / 0.2mAR_B = 2.1V / 0.0002AR_B = 10,500OhmWhat did I do wrong?

author: NiHaoMike
author_rank: Super Contributor
timestamp: August 05, 2017, 02:38:42 am
content: Try reducing the resistor to 1k or even 470 ohms.For the software side, a standard protocol already exists.https://tools.ietf.org/html/rfc2324

author: frozenfrogz
author_rank: Frequent Contributor
timestamp: August 05, 2017, 09:30:42 am
content: Haha yes, the coffee protocol. I think I read through it some years back, but totally forgot. Espresso machines need different implementation though...Can you please enlighten me why the calculations for the base resistor are wrong / off by an order of magnitude? I am doing these things to learn stuffThank you!I am thinking about just doing the PCB layout for the current version, pushing it to github together with the bits of firmware I have finished and then work on variants e.g. a minified version with just an ESP8266 instead of a NodeMCU. Also a version with MAX31865 for PT100 / PT1000, solid state relay and implementation of PID might be interesting.

author: madires
author_rank: Super Contributor
timestamp: August 05, 2017, 09:40:04 am
content: You've calculated the base current for an Ic of 72mA, but that won't drive the NPN into saturation reliably. A rule of thumb for small signal transistors is to double or tripple the base current. BTW, BC817-40's minimum hFE is 250.

author: frozenfrogz
author_rank: Frequent Contributor
timestamp: August 05, 2017, 10:30:57 am
content: Thank you madires. Seems like I should read more about bipolar transistors to fully understand how they work.I took the gain factor from Fig. 3 @25°C of the NXP datasheet.So with hFE 250 and double the base current this would mean more like a 3K resistor.Do I need to use an additional voltage divider then?

author: madires
author_rank: Super Contributor
timestamp: August 05, 2017, 10:58:17 am
content: Just the base resistor. It's a simple switching application. And yes, 2k7 sounds more reasonable.

author: perieanuo
author_rank: Frequent Contributor
timestamp: August 05, 2017, 01:45:34 pm
content: Quote from: madires on August 05, 2017, 10:58:17 amYes madires offer good advice. You made your beta/I base calculation but you have to bet a little more, like a safety coefficient because you have noise on the lines, Vcc fluctuations and so on so good practice means to drive to saturation heavily. Me I usually double I base for example or more on order to fall on same values for the items. Like production preparation...Regards pierreEnvoyé de mon HUAWEI NXT-L29 en utilisant Tapatalk

author: frozenfrogz
author_rank: Frequent Contributor
timestamp: August 05, 2017, 06:09:28 pm
content: Good to keep in mind as future knowledgeBy the way, the current firmware is written in Arduino. When the first ESP8266 development boards showed up I looked into the NodeMCU / Lua script package but did not really like it - maybe, because I was already more familiar with the Arduino environment. Integration into the Arduino IDE is pretty straight forward and works out of the box. So I did not feel the need to switch the dev. environment.