Thank you for the help, guys!
schmitt trigger, I agree with you. I´d rather not to work with such a high voltage, and a transformer would make my work much easier.
The problem is that I cannot find a transformer with a primary rated for 380VAC. There are only models for 220V input.
My plan is to use a capacitive power supply to run a microcontroller with an ADC. The voltage to be measured will be rectified by a 1N4007 and filtered by a 200 nF capacitor. The DC output will be reduced by a voltage divider, so that the ADC can see around 1.5V DC when the input voltage is 240 volts, and 3.5 volts when the input is at 380V (just examples).
I know the precautions we must take when dealing with such circuit, but if my idea is totally trash, please let me know.