How to Achieve Analog 5V from a 3.3V Microcontroller Output

I am currently working with a 3.3V microcontroller (e.g., ESP32, ESP8266) and need to create an analog signal of 5V for signaling purposes.

i have a power supply of 5v and 3.3v

It's important to note that the application involves a low load since it is for signaling only and will not involve a significant load,

-Precision is not a critical factor so I am looking for a simple solution where the 3.3V signal can be multiplied to achieve the desired 5V output.
example to multiplay by 1.5

Could you please guide me on how to achieve this?

I want the output to be 5V when the microcontroller outputs 3.3V
and
0V when the microcontroller output is 0V.

Thank you in advance!

How does your system produce a 3.3V signal? DAC?

Will a level shifter work for you?

Esp32 anoalog

   // Use DAC channel 1
  dacWrite(25, 0);    // Set the DAC voltage to 0V
  delay(1000);        // Wait for a second
  dacWrite(25, 255);  // Set the DAC voltage to 3.3V

or another microcontroller
analog

  // Set the PWM duty cycle for minimum voltage (0V)
  analogWrite(pwmPin, 0);
  delay(1000);  // Wait for a second

  analogWrite(pwmPin, 255);

if i want like 1.65v

  analogWrite(pwmPin, 128);  // 128 is half of the 0-255 range
or
  dacWrite(25, 128);  

Then use an opamp. Look up basic opamp as amplifier circuit.

1 Like

Do u have a suggestion what u think i shluld use

From what I read, "analog" isn't necessary (at all ─ unless you need 2.5V out with 1.6V in).

Yes i need around 2.5v when i send around 1.6v

Then it is back to using operation amplifiers then.

do u have any suggestion so i know what opamp to look for

What components do you have there in your "parts box"?

Look for one that has rail to rail operation, or close to it.
The rail to rail criteria is the maximum and minimum you can get from the output when powering it with a 0 to 5V supply. Otherwise it becomes more difficult and you need a power supply outside the range of the voltages you are working with.

i have 3.3v
5v
and 42v in my pcb

i

u can suggest any common used for this purpose so i can find in local stores

So no negative voltages then, you are still looking for a rail to rail op amp.
Do a net search for one.

someone told me i need to use LM 358 but idk where to connect analog signal that commes from microcontroller and where to connect 5v
and what resistors to use

LM358 will not work
Use this circuit

And have you looked up the data sheet to see how close the the rail you can get?

When you do you will find it can only output a signal that is 1.5 V less than the supply voltage. So it is not suitable at all for what you want to do with it.

The "analog output" still has to be filtered.

@jim-p none of the local stores has this mcp6241

also is this a better option if i create a voltage divider from the 5v that i already have but one of resistors to be like variable resistor which resistence i can controll from microcontroller.

i read that i need a digital potentiometer, is this solution better or op-amp is better

Do the local stores have those?

Opamp is bettor
I don't know what your local stores carry, so I can't suggest what opamp to use