For you maybe! Some online examples would be welcome. I've never played with a mosfet yet but I've recently ordered some more electronics testing tools so I'm looking for interesting but simple projects that I might pick up over the winter.
Oh, sure. I have seen various ways to control a simple PC remotely that are software based of course, but true servers have 'power' control integrated, so I wanted the same feature as I have used 1000s of times on servers. Many examples are complex and required circuit isolation elements in the design, because they have shared elements of the design, but a simple switch, especially a mechanical switch avoids the issues that require isolation. This design avoids the isolation issue the same way, in that the control logic side of design has no dependency on the control implementation side of the design. Now electrical gurus will raise an objection at this point, but that is a question of how the specific 'switch' component is designed, if you don't want to use MOFSETs, use isolated mechanical relays of course.
Here is what I did for my PC controller. ESP module, wrote my own firmware, but there are templates that you could use. All you need to 2 GPIO pins that can be set to 0 and 1 as needed.
2 MOFSET breakout boards, like say this one...
You will need a 3.3v or 5v source for the breakout board control interface, but that can come from the ESP module as need. Example of ESP modules, I like the NodeMCU based ones, common, supported by many canned firmware images.
The wiring is simple, MOFSET is just a switch, so I just added wiring to my PC to put the MOFSETs in parallel to the PC power button power/GND, and reset button power/GND. Thus each MOFSET switch, is in parallel to the existing PC case power and reset button respectively. This way my PC case buttons work, and the ESP controlled switches work independently.
Power off/on of PC is just closing the MOFSET switch for about 1.5 seconds, then open it. Reset toggle of PC is just closing it and then.opening it, for 1/2 second. You may have to tweak this for the given motherboard model/maker.
This solution was just getting the components and a bit of wiring, and then creating the ESP module firmware. I happen to use HTTP REST API, but MQTT based would be just as easy to do, say if using canned firmware image.
Here is a picture of my first version of the project....
From ESP Side...
MOSET VCC, from ESP VCC out pin
MOSET GND to ESP GND pin of our choice
ESP GPIO logical pin '1', to SIG/INT pin, this is the logic pin for first MOFSET board
ESP GPIO logical pin '2', to SIG/INT pin, this is the logic pin for first MOFSET board
Of course these can by any availabe GPIO pins on the ESP module you want to use.
From the PC case. side...
Red wire went to PC power button source power (+)
Black wire went to PC power button source GND (-)
Yellow wire went to PC reset button source power (+)
Green wire went to PC reset button source GND (-)
The thing to remember is that a PC case power switch source is just (on most boards) just a 5v high state, and the case button draws this state to GND, the PC case power supply handles the 'logic' of what this means, and acts accordingly. The same is true of the PC case reset switch.
I also added RGB diode module so I can see from the 'project' what function is engaged. This basic design works for any situation where you just want to close and open a switch, so garage door, sprinkler valve, HVAC control.
Because this design is just opening and closing switches, you don't need to isolate anything, the switch hardware and using the existing source power and GND of the device in question are separate from the ESP module side of the design.
If you think Smart WIFI plugs are much different, THEY ARE NOT THAT MUCH DIFFERENT. Just use various different 'switch' components, say electro-mechanical relays versus MOFSETs for example.
Other than the live side constantly handling 120/240v up to 10a of course! And that is AC rather than DC - do mosfets work with AC?
For the high current application your MOSFET will heat up like crazy, thus you need to add heatsink to provide cooling to the MOSFET. Looking at how to work out how much heatsink you need is a bit of an exercise in its own right.
- MOSFET: how to determine if a heatsink is required? - Electrical Engineering Stack Exchange
- Heatsink Calculations ā Renewable Energy Innovation
- Heat sink calculator | MustCalculate
So, if I've read things right, this Sparkfun Mosfet kit would be suitable for remote control of a short run of low power 5v LED's (max 3.5a). However, from this it is pretty clear that anything over 1a of load is going to need a decent heatsink and probably a fan at higher amps.
This one actually mentions using it with 24v LED strips but again it needs a heatsink above 1a.
I guess this is why mechanical relays remain the staple for power switching.
Some fun research though and my LCR-TC1 Color Transistor Tester NPN PNP Diode Resistance Capacitance Detect B5O7 arrived today so I can actually recover some mosfets from some old electronics that I've been hanging onto and can actually test if they are OK (and what they are)
I've built a lot of similar devices to switch pumps, lights, water heaters, ect. and yes, they do get hot, so a good heatsink is essential, otherwise they do go bang (and I do mean Bang!).
The big advantage in using something like a Shelly, is that they have safety mechanisms built in, where they shut the device down if they reach a certain temperature, or exceeds a preset power threshold.
No they don't. I believe the "equivalent" component for AC is a triac (and perhaps a thyristor). I would not suggest playing with AC circuits as a hobbyist.
Or SSR of course.
SSR's to my understanding contain a triac + extra circuitry underneath.
Interesting, I didn't know that. Looks like they can use optodiodes too.
From that guide, they too suffer from the same problems as a mosfet along with some others. So they may still need cooling, may be less suited to low-voltage use and can have an off leakage so may not be suitable in some uses.
Looks like the prices may have come down since last time I looked though
https://www.amazon.co.uk/Solid-State-Relay/s?k=Solid+State+Relay
Actually, I have a number of failed 433MHz and WiFi mains switches and my first project really should be to see whether it is the relay that has failed in them. If so, that should probably be a fairly straight-forward job to fix as long as I can get to the components.
Hey guys,
Switching back to led strips:
- When I have look at the warm white led strips (e.g. this one) are available only with 60 or 120 leds per meter. Not sue which one I should choose. 120 means more light but also more electricity cost. The leds will be used in the living room so they will be most of the time 'on' during the evenings. Anybody knows some other facts to help me choosing?
- And I'm thinking of buying the 24V version (instead of 12v), to keep the current through my wires lower. Is that a good choice, of are there disadvantages?
- I need to connect led strips at an angles of 0, 90, 180 degrees. What is the best way to connect those strips?
Bart
You could also just run them dimmer? 120 sounds a lot though.
I believe more is better, not aware of any disadvantages (there might be some or course)
There's angled connectors for that purpose. At least I've seen such in AliExpress but I don't know how standard the connectors are between LED strips from different brands.
I'm new to this too, but the strips I bought have marks where you can cut if you need to make them shorter, so I doubt bending them 90 degrees at one of those marks would matter.
Unless you need more than 60W I'd stay with 12V, larger selection of power supply and strip options.
My controller (that wouldn't flash with Tuya-convert), dims and sets colors fine, its "animation" displays are lame and repetitive which is why I want to do my own.
My controller and strips came with a 12V 5A supply and the MOSFETS inside (presumably N-channel as the strips are common anode) do not have any heat sink other than the circuit board, they are smaller than the ones you can buy and expect to solder to. A typical nMOSFET has an "on resistance" of less that 0.1 ohm when the gate to source voltage is 5V. If your mosfets are getting hot, maybe its the 3.3V drive from your ESP32 is not enough, the on resistance goes up asymptotically below 4V G-S drive. Maybe I'll stick with old school NPM transistors for this simple PWM application, if the new controller (that should be here today) is also "immune" to Tuya-convert.
Here is simple flow I used with a PiZeroW and some RGB LEDs and a few NPN transistors to boost the PI current sinking capability.
The animation is just for grins when all is secure, its main purpose is to flash red if the garage door is open, my wife forgets a lot, but audio alerting is not good as I have the door open a lot when I'm working out there. If the garage door is closed and the house unlocked it flashes green. If all secure it does a simple color changing animation. Its been set and forget, been running 24/7 for more than 2 years.
[{"id":"d78627f.e3224d8","type":"rpi-gpio out","z":"b3610d6f.9372","name":"Red LED 40","pin":"40","set":"","level":"0","freq":"100","out":"pwm","x":685,"y":245,"wires":[]},{"id":"711bf7d6.884dd8","type":"rpi-gpio out","z":"b3610d6f.9372","name":"Green LED 38","pin":"38","set":"","level":"0","freq":"100","out":"pwm","x":685,"y":320,"wires":[]},{"id":"42c62c42.d66bc4","type":"rpi-gpio out","z":"b3610d6f.9372","name":"Blue LED 36","pin":"36","set":"","level":"0","freq":"100","out":"pwm","x":680,"y":390,"wires":[]},{"id":"250f496b.672aa6","type":"function","z":"b3610d6f.9372","name":"Red Ramp","func":"var redCount = context.get('redCount')||0;\nvar countDown = context.get('countDown')||0;\nvar armed = context.get('armed')||0;\nvar garageDoor = context.get('garageDoor')||0;\nvar tick = context.get('tick')||0;\nvar flash = context.get('flash')||0;\nvar newMsg={ payload : \"\", topic : \"\", };\n\nif(msg.topic === 'Tick'){\n tick = tick+1;\n context.set('tick',tick);\n if (tick%2 === 0){\n if(flash === 0)\n context.set('flash',1);\n else\n context.set('flash',0);\n }\n\n if(armed === 0 && garageDoor === 0){\n newMsg.payload=0; // green will be flashing\n return [ msg, newMsg ];\n }\n if(garageDoor === 1){\n if(flash)\n newMsg.payload=100;\n else\n newMsg.payload=10;\n return [ msg, newMsg ];\n }else if(tick%3 === 0){ // was 7\n if (countDown === 0){\n context.set('redCount', redCount+1);\n redCount=context.get('redCount');\n if(redCount>=70){\n context.set('countDown',1);\n }\n }else{\n context.set('redCount', redCount-1);\n redCount=context.get('redCount');\n if(redCount<=20){\n context.set('countDown',0);\n }\n }\n newMsg.payload=redCount;\n return [ msg, newMsg ];\n }\n //return [msg, null ]\n}\n\nif(msg.topic === 'Alarm/LOREX_MODE'){\n if(msg.payload.indexOf(\"Idle\") === 0){\n context.set('armed',0); \n }else{\n context.set('armed',1);\n }\n return [ msg, null ];\n}\nif(msg.topic === 'Alarm/GarageDoor'){\n if(msg.payload.indexOf(\"Open\") === 0){\n context.set('garageDoor',1); \n }else{\n context.set('garageDoor',0);\n }\n return [ msg, null ];\n}\nreturn [ msg, null ];","outputs":2,"noerr":0,"x":500,"y":245,"wires":[[],["d78627f.e3224d8"]]},{"id":"47785acf.4e5034","type":"debug","z":"b3610d6f.9372","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","x":335,"y":160,"wires":[]},{"id":"eeaedf65.c07cc","type":"inject","z":"b3610d6f.9372","name":"Tick","topic":"Tick","payload":"1","payloadType":"num","repeat":"0.5","crontab":"","once":false,"onceDelay":0.1,"x":105,"y":245,"wires":[["250f496b.672aa6","872b75c3.4e2718","17902703.3c2779"]]},{"id":"872b75c3.4e2718","type":"function","z":"b3610d6f.9372","name":"Green Ramp","func":"var greenCount = context.get('greenCount')||0;\nvar gcountDown = context.get('gcountDown')||0;\nvar armed = context.get('armed')||0;\nvar garageDoor = context.get('garageDoor')||0;\nvar tick = context.get('tick')||0;\nvar flash = context.get('flash')||0;\nvar newMsg={ payload : \"\", topic : \"\", };\n\nif(msg.topic === 'Tick'){\n tick = tick+1;\n context.set('tick',tick);\n if (tick%2 === 0){\n if(flash === 0)\n context.set('flash',1);\n else\n context.set('flash',0);\n }\n if(garageDoor === 1){\n newMsg.payload=0; // red will be flashing\n return [ msg, newMsg ];\n }\n if(armed === 0){\n if(flash)\n newMsg.payload=100;\n else\n newMsg.payload=10;\n return [ msg, newMsg ];\n }else{\n if (tick%5 === 0){ // was 13\n if (gcountDown === 0){\n context.set('greenCount', greenCount+1);\n greenCount=context.get('greenCount');\n if(greenCount>=70){\n context.set('gcountDown',1);\n }\n }else{\n context.set('greenCount', greenCount-1);\n greenCount=context.get('greenCount');\n if(greenCount<=20){\n context.set('gcountDown',0);\n }\n }\n newMsg.payload=greenCount;\n return [ msg, newMsg ];\n }\n }\n}\n\nif(msg.topic === 'Alarm/LOREX_MODE'){\n if(msg.payload.indexOf(\"Idle\") === 0){\n context.set('armed',0); \n }else{\n context.set('armed',1);\n }\n return [ msg, null ];\n}\nif(msg.topic === 'Alarm/GarageDoor'){\n if(msg.payload.indexOf(\"Open\") === 0){\n context.set('garageDoor',1); \n }else{\n context.set('garageDoor',0);\n }\n return [ msg, null ];\n}\nreturn [ msg, null ];\n","outputs":2,"noerr":0,"x":495,"y":320,"wires":[[],["711bf7d6.884dd8"]]},{"id":"17902703.3c2779","type":"function","z":"b3610d6f.9372","name":"Blue Ramp","func":"var blueCount = context.get('blueCount')||0;\nvar bcountDown = context.get('bcountDown')||0;\nvar armed = context.get('armed')||0;\nvar garageDoor = context.get('garageDoor')||0;\nvar tick = context.get('tick')||0;\nvar flash = context.get('flash')||0;\nvar newMsg={ payload : \"\", topic : \"\", };\n\nif(msg.topic === 'Tick'){\n tick = tick+1;\n context.set('tick',tick);\n if(armed === 0 || garageDoor === 1){\n newMsg.payload=0; // either red or green will be flashin\n return [ msg, newMsg ];\n }\n if (tick%11 === 0){ // was 19\n if (bcountDown === 0){\n context.set('blueCount', blueCount+1);\n blueCount=context.get('blueCount');\n if(blueCount>=100){\n context.set('bcountDown',1);\n }\n }else{\n context.set('blueCount', blueCount-1);\n blueCount=context.get('blueCount');\n if(blueCount<=50){\n context.set('bcountDown',0);\n }\n }\n newMsg.payload=blueCount;\n return [ msg, newMsg ];\n }\n}\n\nif(msg.topic === 'Alarm/LOREX_MODE'){\n if(msg.payload.indexOf(\"Idle\") === 0){\n context.set('armed',0); \n }else{\n context.set('armed',1);\n }\n return [ msg, null ];\n}\n\nif(msg.topic === 'Alarm/GarageDoor'){\n if(msg.payload.indexOf(\"Open\") === 0){\n context.set('garageDoor',1); \n }else{\n context.set('garageDoor',0);\n }\n return [ msg, null ];\n}\nreturn [ msg, null ];","outputs":2,"noerr":0,"x":500,"y":390,"wires":[[],["42c62c42.d66bc4"]]},{"id":"d7df9a54.b68518","type":"mqtt in","z":"b3610d6f.9372","name":"GarageDoor","topic":"Alarm/GarageDoor","qos":"2","broker":"af9fc849.e97758","x":110,"y":160,"wires":[["250f496b.672aa6","47785acf.4e5034","872b75c3.4e2718","17902703.3c2779"]]},{"id":"317b08a5.07f6c8","type":"mqtt in","z":"b3610d6f.9372","name":"Armed","topic":"Alarm/LOREX_MODE","qos":"2","broker":"af9fc849.e97758","x":90,"y":300,"wires":[["47785acf.4e5034","250f496b.672aa6","872b75c3.4e2718","17902703.3c2779"]]},{"id":"ce7eb913.4fd8e8","type":"ping","z":"b3610d6f.9372","name":"WiFi Alive?","host":"192.168.2.1","timer":"45","x":100,"y":490,"wires":[["4fe025da.e9197c"]]},{"id":"4fe025da.e9197c","type":"switch","z":"b3610d6f.9372","name":"","property":"payload","propertyType":"msg","rules":[{"t":"gt","v":"0.0","vt":"num"},{"t":"false"}],"checkall":"false","outputs":2,"x":285,"y":491,"wires":[["fb38dd53.9557d"],["61407273.ad712c","d44a3ca0.8566b"]],"inputLabels":["ping"],"outputLabels":["mS","dead"]},{"id":"fb38dd53.9557d","type":"debug","z":"b3610d6f.9372","name":"","active":false,"console":"false","complete":"false","x":511,"y":485,"wires":[]},{"id":"61407273.ad712c","type":"exec","z":"b3610d6f.9372","command":"sleep 2 ; sudo /sbin/reboot","addpay":false,"append":"","useSpawn":"false","timer":"","oldrc":false,"name":"Reboot, WiFi died.","x":531,"y":577.5,"wires":[[],[],[]]},{"id":"d44a3ca0.8566b","type":"debug","z":"b3610d6f.9372","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","x":492,"y":533,"wires":[]},{"id":"d9eac6d5.5836c8","type":"inject","z":"b3610d6f.9372","name":"Shutdown","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":120,"y":650,"wires":[["e6ca11c4.426e5","d44a3ca0.8566b"]]},{"id":"e6ca11c4.426e5","type":"exec","z":"b3610d6f.9372","command":"sudo /sbin/shutdown -h now","addpay":false,"append":"","useSpawn":"false","timer":"","oldrc":false,"name":"","x":420,"y":650,"wires":[[],[],[]]},{"id":"bd8ec024.4f012","type":"catch","z":"b3610d6f.9372","name":"","scope":null,"x":100,"y":100,"wires":[["47785acf.4e5034"]]},{"id":"af9fc849.e97758","type":"mqtt-broker","z":"","name":"Alarmbone","broker":"192.168.2.140","port":"1883","clientid":"","usetls":false,"compatmode":true,"keepalive":"60","cleansession":true,"birthTopic":"Alarm/Indicator","birthQos":"2","birthRetain":"true","birthPayload":"Running.","closeTopic":"Alarm/Indicator","closeQos":"2","closeRetain":"false","closePayload":"Stopped.","willTopic":"Alarm/Indicator","willQos":"2","willRetain":"true","willPayload":"Died!"}]
type or paste code here
I think a PiZeroW running Linux attached to a keyboard, mouse and monitor have many advantages when setting things up compared to the "crash, fix, and flash again" development of the basic Arduino IDE.
I did some RGB led animations with an Arduino "Trinket", I'd much rather use a PiZero for anything more complicated. YMMV.
I stocked up on PiZeroW when Microcenter had them on sale for $5, but even at their normal $10, its cost competitive unless you go nuts with the required SD card, my Trinkets were like $9 each then, but they fit the space available a PiZeroW wouldn't and the WiFi added nothing here.
There are a lot of web resources, here is one very close to the topic:
https://efcomputer.net.au/blog/4-steps-to-create-wifi-controlled-rgb-led-strip-using-esp8266/
For instance the Fotek branded ones on the list are fake. I suspect the other similar looking are not up to spec either. Here's how to spot a fake: Inferior Counterfeit FOTEK SSR-25 Solid State Relays on the Market - ProtoSupplies
A thing to note when comparing SSRs and MOSFETs - MOSFETs are fast switching transistors and can be used for PWM. SSR relays to my understanding aren't capable of switching fast enough for that.
(Another interesting tip for detecting fake products on AliExpress (in general) came from YouTuber VoltLog. He said the products that claim "original" in the name usually are and that when asked the Chinese sellers don't say they're original if they are not. It would make sense as it's quite easy to get a refund on AE if a product does not match the information provided (incl. tiny prints).)
I would say bending them to a hard 90Ā° might break the copper pads. And they for sure could not be bent sideways if the goal is to have the leds pointing downwards under a cupboard.
Not thought about that to be honest. Seems there are some bending techniques available...
Nice find! It looks like they can take surprising amount of manhandling.
Without wishing to go down yet another off-topic rabbit hole. The last thing I need or want on my desk is yet another keyboard, mouse and monitor All my devices except my dev PC are headless. And certainly I would never bother to run a Linux desktop on a limited device unless I wasn't using it for anything else.
The crash/fix cycle on a Linux device is, to me anyway, much the same though it is rare to actually crash Linux, we've certainly seen far too many people having problems with Pi GPIO on this forum. At least on an ESP/Arduino you are close to the hardware and there is nothing to get in the way. Also, the level of library support is so good for sensors, controllers, etc. In the end it is just a slightly different approach.
You've undoubtedly touched on a valid point here. Of course, I'd probably argue that it would be better to set up an ESP device that could take remote commands for the LED patterns - getting the best of both worlds. And indeed, being able to use Node-RED where useful.
An ESP8266 dev board is often under $3. Also an electronics numpty like me is much less likely to blow the board than they are with the unprotected GPIO pins on the Pi's.
At the end of the day, I'm sure that most people will go with what they are most familiar with and what fits their knowledge and available tools. Each approach has different merits and that is the important point for people to take away.
Must admit that I would simply cut the strip and use a corner joint - I ordered a "variety" pack of joints and corners when I started messing with LED strips. You really do want to have a set of different connectors, joiners and clips.
Not sure that I would subject cheap Chinese LED strips to that kind of bending. Also, you couldn't do that anyway if you are using waterproofed LED's like I do in the kitchen. The silicon they come in wouldn't let you.
Yes, AC and DC, are completely different applications... My example is strictly DC, I guess I thought that was obvious, if not, my bad.
The problem with flash & test... is you age the entire unit while testing. That is why I prefer PiZero when I know I am going to be abusing the IO writes to some degree. I love the ESPs, but once their memory goes... they are useless.