0
\$\begingroup\$

I am a complete beginner and my electrical knowledge back from school is basically non-existent anymore.

I have discovered the ESPHome project and am amazed by its simplicity, so I wanted to turn a dumb IKEA USB powered lamp (cheap + USB powered should be a good start) into an IoT lamp, after I had quick success with different sensors.

Fast forward, while everything is working out nicely when powered by 3.3 V via my serial adapter, the lamp is rather dim in comparison to the unmodified circuit and I would assume that this is because of two things:

  1. The GPIO I am using is intended for logic, not load
  2. The lamp expects 5 V from the USB, while my ESP is running off of 3.3 V

So as the next step is to hook everything up to USB, this is creating issues for me now. I am planning to use these "AMS1117"-based step down converters to regulate the power down from the USB to avoid frying the chip (I hope the choice was OK; Again, I am basically doing this without any knowledge here), but how am I going to control the 5 V lamp now? I have one of the chip's GPIO's set up to control the lamp, either as active high or low, depending on my choice.

My "circuit" looks like this (aka: the bare minimum to power it), the "open" wire is my GPIO for the lamp:

ESP lamp circuit

I wanted to:

  • Connect the step down converters' - and + to the pins on the ESP/resistors
  • Connect the lamp's + or - (depending on whether I'll go with a active high or low GPIO setup, if I understood that right) to the USB plug's pin
  • Connect the other pin to the GPIO (or relay/etc.) <-- This is where I have to do something.

Is this a job for a relay, another step-up/down converter, something as simple as diodes or resistors or what? I understand where the issue comes from, but my knowledge is too limited to know the appropriate answer to it.

All feedback is highly appreciated, I have tons of things to learn.

PS: And yes, I went with the bare ESP8266 after playing around with a Wemos D1 mini, as I am a purist and eager to learn the basics (and I like the smaller form factor).

PPS: I couldn't find questions that looked as basic as this one or they were about the other way around or only about logic signals.

EDIT: OK, so the part i am looking for seems to be a MOSFET. I have found e.g. this one; It supports voltages for drain+source of up to 60v (that would be used for my lamp's 5v line I assume) and up to 20v for the gate (for my GPIO's 3.3v I guess) with a continuous output current of up to ~22A (I assume the maximum the lamp can draw; It came with a 1A power supply), which should be far below my circuit's limits. The Gate Threshold Voltage/VGS(th) is 1-2.5V (as pointed out by vir); That means that as long as I'm above those values, it will recognize the input as logical "on"? And how much current does the gate pin survive? Is it the "Avalance current" value?

If i understood it right, I would:

  • Define the lamp's GPIO as active low
  • Connect the lamp's GND to the ESP's GND shouldn't be necessary, i can just leave that wire as is (but would it be OK if they shared a common GND even though they're operating at different voltages?)
  • Connect the GPIO to the MOSFET's gate
  • Connect the USB plug's + to the MOSFET's source
  • Connect the lamp's + to the MOSFET's drain
\$\endgroup\$

1 Answer 1

0
\$\begingroup\$

You don't need to have everything powered off of 3.3 V. With the appropriate components, the ESP32 is capable of controlling devices powered by a 5 V rail, just don't mix the two up. The regulator boards you linked are fine, but you can get bare regulators that will plug directly into your breadboard and only need a capacitor or two. Plus, they'll nudge you towards designing around components instead of being constrained by what modules are available. Either linear or switching regulators will work provided you're just powering the ESP32 at ~80 mA.

For switching, a logic-level N-channel MOSFET for low side switching would likely work here (generally a good idea to avoid low side switching on devices that have other control or data lines, but if it's just power then you shouldn't have any problems). Just be sure to find one that is designed to run properly at 3.3 V. That means a threshold voltage (Vgs(th)) of 2 to maybe 2.5 V. Save yourself the headache and start sourcing your parts from reputable suppliers (Digikey, Mouser, Arrow, Newark, et. al.) instead of Amazon.

\$\endgroup\$
4
  • \$\begingroup\$ Yes, I would love to get to a point where i am confidently putting together components to achieve my goals instead of relying on these parts, but that is the far future for me (I'd know about using the regulators, but e.g. your mentioned capacitors wouldn't come to my mind/i wouldn't know how to calculate and connect it). So if i understood the N-channel MOSFET's right, I'd have to use my GPIO as the gate and the lamp's wire for the source and drain? EDIT: And if that is the case, what is the (functional) difference to a relay? I mean both are closing another circuit when toggled, right? \$\endgroup\$
    – klaasbob
    Feb 8 at 18:27
  • \$\begingroup\$ Regulators are a great intro to reading datasheets and selecting parts. Look at the datasheet for a LM2930: ti.com/lit/ds/symlink/lm2930.pdf (I am intentionally picking a component that is inappropriate for your application). Page 3 shows you a "typical application", the input and output capacitors, and their recommended values. As for the MOSFETs, you'd connect the gate to the ESP32 through a low value resistor (~100 ohms), the source to ground (same as the ESP32), and drain to the lamp's ground wire. The effect is the same as a relay but the MOSFET consumes far less power. \$\endgroup\$
    – vir
    Feb 8 at 18:48
  • \$\begingroup\$ So if i wanted to replace my step down converter circuit board with components, could i use something like sparkfun.com/products/526 (the LD1117#33C)? it supports inputs up to 15v and outputs ~3.3v at up to 1300mA. The ESP appraently uses up to 400mA, so it should be enough (and this is not going to fry the chip?). Are the capacitors added to the output to "smoothen" it to avoid the ESP locking up? And the input capacitor reduces "source impedance", does that mean it reduces heat due to lower resistance? How would i determine their size in terms of (pico-)farad? \$\endgroup\$
    – klaasbob
    Feb 8 at 20:50
  • \$\begingroup\$ Yep, the datasheet should tell you all you need to know. In this case, "only a 10 uF minimum capacitor is needed for stability" (linear regulators need a certain amount of capacitance at the output or their performance suffers). The 0.1 uF input capacitor is there to filter any high frequency noise that might be at the input. Ceramic capacitors should be fine since they don't mention anything special about what type of capacitors to use. You generally don't want to run components at full current so the 1300mA rating is fine; your ESP32 will only take what it needs. Might get a bit warm. \$\endgroup\$
    – vir
    Feb 8 at 21:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.