Electronic – LD1117V33C and heat

heatpower supplyresistors

I was looking at this answer:
https://electronics.stackexchange.com/a/18479/76121
and I want to make sure that I understand…

I have a project that will be taking 120VAC current and turning it into 12VDC current using a Hi-Link HLK-PM12, which I need to switch a relay, and it will have a LD1117V33C to turn part of the 12VDC into 3.3VDC to run an ESP-01.

Now my question; the HLK-PM12 says that it's output is 12VDC, 3W.
According to the datasheet the LD1117 runs around 50C per Watt. I've been testing my circuit with a 9V battery, and the LD1117 gets a little warm, but not too bad. How exactly would I figure out how hot this thing might get with 12V 3W? If it's going to get up to 150C that's going to be a problem. Another problem is that this project is going to be outdoors, and so will be in a sealed project case, meaning while I can put a heat sink on, there won't be any air flow to help dissipate heat.

So how to I minimize heating with this?
Would a series of resisters between the HLK-PM12 and LD1117 drop the current enough to avoid a problem? If so, is this math correct?

I = P / C = 3W / 12V = .25A

And if so, what's the best way to figure out what resistors I'll need?

Another option would be to use a HLK-PM03 to turn 120VAC directly into 3.3VDC, and then I could avoid the whole LD1117 problem, but I don't know if that's necessary?

Please forgive me if I am misusing any terms. I'm something of a novice.

Edit: Plan B

Decided that the ESP8266-01 needs to have it's own power source, as there won't be enough current left over once the relay has been started.

So I came up with this schematic:

schematic

simulate this circuit – Schematic created using CircuitLab

I'm hoping this will put me more on the right track.

Maybe this should be a new question at this point, as I've basically found out that my original plan won't work.

Best Answer

ESP-01 peak current draw is over 300mA. Your power supply can only deliver 250mA, and a linear regulator won't change this. Assuming you need 12V to power the relay, I would add a switching pre-regulator to drop the voltage down to 5V, then use the linear regulator to provide a stable 3.3V without getting hot.

This will draw less current from the power supply because the switching regulator 'transforms' high voltage at low current to lower voltage at higher current.

Small buck-mode regulator modules sell on eBay for about $1 each. Here's an example which has solder pads to select the output voltage:-

Mini DC-DC 12-24V To 5V Step Down Power Supply Module 3A Buck Converter

enter image description here

Another option might be to use a 5V 3W power supply and 5V relay.