Can I Use a Transformer to feed a Mains current to a RPI GPIO pin
Hi-Link HLK-PM03 as mains voltage detector into R'Pi


This will be a very effective solution and much cheaper than a 230/240VAC relay.

One small point, the Hi-Link HLK-PM03 is a small SMPS power supply  ….not a transformer (and even though it will contain a small ferrite transformer). 

I'd suggest that you do need to provide a resistive and clamp network on the output of the power supply:  


To provide a minimum load on the power supply when active 
To provide a quicker drop in the output voltage when turned off
To ensure that the R'Pi input is protected 


A Circuit such as this would be effective:







simulate this circuit &ndash; Schematic created using CircuitLab

This provides a minimum load on the power supply of about 55mA, and sets the input voltage to the GPIO pin to about 2.75V.