I'm working on a small pet project with my RaspberryPi and I'm looking hook it up to some sensors. The output from the sensors is normally at 0v but when the sensor is triggered, goes high to 20v. The RaspberryPi's gpio ports will only accept a maximum voltage of 3.3v, so I've been researching how best to drop the input voltage from 20v to 3.3v, so it won't fry my Pi's gpio ports. The Pi doesn't need to send anything back, it's strictly one-way into the Pi, and the line will only go to 20v when the sensor is triggered.
In my research, I read about a circuit comprising of an LM317 Variable Regulator, and 2 resistors, which could give me the 20v to 3.3v that I need. However, I'm worried about the kind of heat that could be given off with such a large difference in voltage.
I've tried to be as clear as possible, and have also included a handy dandy schematic of what I mean.
To add to things, I'm likely to be adding more 20v connections to other io ports on the Pi, probably up to 15, so I'm also considering what the combined heat could be like...
Am I on the right track, and is the heat just something that I'm going to have to work with? Or is there a better solution out there?