Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Optocoupler to step 5v logic down to 3.3v for the raspberry pi is madness. Just use a voltage divider!

Still, very cool project though!



First and foremost, voltage divider outputs voltage proportional to input: prior circuitry fails, outputs 18V instead of 5V and you fry at least GPIO port with ~12V. That is expected behaviour. Furthermore, you cannot add resistive load to a voltage divider without affecting division ratio. Optocouplers, Linear regulators (including commonly known LDOs) do not have this property. You can call it paranoia, but that's just sensible design


Paranoia? Wouldn't things get rather ugly if you accidentally fed a voltage divider the 18V in that circuit?


Yes, but the attitude just rubs me the wrong way. If they suggested the voltage divider, it would have been a good opportunity to instill careful engineering and testing practices. They could have said something like "this will fry your GPIO if you accidentally send 18v, so make sure to test the circuit with a multimeter or scope!" Instead, they suggest throwing an expensive part at the problem, supporting the attitude that you can't trust your own engineering. At least they mention that there are other ways to do it.

I dunno, maybe it's two different, equally valid attitudes. I guess I dislike it for the same reason I prefer C++ over Java.


Speaking as a developer, I think the attitude that you can't trust your own engineering can be a healthy one :-) Defensive coding and all that.


Why is it madness? It works and like the author said, it's an extremely safe way to do it.

Also, if we're going to be pedantic, I'd recommend a FET over a voltage divider.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: