Hacker News new | ask | show | jobs
by sowbug 2107 days ago
I built something like this but more special-purpose. It just switches a USB-A power source on/off. I wanted it to control my 5-volt fish-tank lights. I didn't want to use a 120VAC smart switch for each light because I prefer to use a single USB hub to power them all, and a bonus feature was being able to PWM the lights so the fish aren't freaked out when the lights suddenly turn on 100% in the morning.

I ordered PCBs from JLCPCB and components from LCSC. I think each one cost around $5 in parts, and I hand-assemble them as I need more around the house.

https://github.com/sowbug/smart-usb-switch

Picture: https://raw.githubusercontent.com/sowbug/smart-usb-switch/ma...

3 comments

I made lights using ws2812b leds and simulated sunrise, sunset, and a dim blue throughout the night.

I used ws2812b leds, wemos d1, and a level translator since the d1 has 3.3v gpios but ws2812b technically requires a 5v signal.

I’ve been looking at something like this myself, did you use RGB, RGBW, RGBWW, RGBCCT or what to dynamically set the warmth of the light? I got really confused when I started looking into all these different types
I used rgb but would like to try RGBW in the future because to get bright white on the current strip it consumes about 60 mA (@5v) per led. That's 20 mA for R, G, and B.

I have two rows of 32 lights, so a beefy supply was needed along with a few places where VIN was fed to the strip.

That sounds awesome, can you do a write-up about it please?
For the software part, WLED [0] really does just about anything you’d want to do with those led strips.

I drive the wemos d1 and led’s from a 12V battery with a 12-5V stepdown converter. I attach the 5V to the esp and the led’s. The 3.3V logic level works on the first led and is repeated at 5V to all subsequent led’s.

[0] https://github.com/Aircoookie/WLED

Apparently 3.3v doesn't always work with the strips, and newer ones are less likely to work, especially if you're working with a lot of lights.
My assumption was the each individual led chip will re-transmit the signal to the next led, which in effect will turn the 3.3v signal into a 5v signal between the 1st and subsequent leds.

The power lines do sustain voltage drop over longer sections, so you'll want to add extra power every few meters.

Right, that is exactly how it works. If your signal to the first IC isn't perfect, and it isn't with a 3.3v signal, you can end up with incorrect colors or shifted patterns.

As you add more LEDs you have a greater chance of one at the end not lighting up or having incorrect colors throughout the string.

0.7 * 5v == 3.5v, and 3.3 < 3.5. You're out of spec for the part and can't expect it to work reliably.

I'll see what I can do.
>PWM the lights so the fish aren't freaked out

How certain are you the fish can't see the PWM?

Haha, good point. I believe the ESP8266 default PWM frequency (via the Arduino library) is 1KHz, which is well above the ranges cited in the Wikipedia article for flicker fusion threshold across animal species. In my very limited testing, my fish didn't flee under plants as readily when the lights turned on more gently.

https://en.wikipedia.org/wiki/Flicker_fusion_threshold

I am sure this is something will be able to answer:

I need to build a custom board for an ESP32 which should support low-power deep sleep and which should contain some additional circuitry (is that what you call it?) to drive an Eink display.

Basically this[1] board, but a different shape and better low-power sleep properties.

If I wanted to design this board myself, how long would it take to learn this? Are there good resources?

If I were to pay somebody to do design this, what order of magnitude would the cost be in?

> https://eckstein-shop.de/Waveshare-Universal-e-Paper-Raw-Pan...

Have you already made the circuit on a breadboard? If so, learning KiCAD and building the board from scratch would take around a week of afternoons.

I really recommend it, designing PCBs is very enjoyable (at least to me).

If you are comfortable prototyping on a breadboard it shouldn't take long to produce the layout in KiCAD or a similar EDA tool.

Then you can order your PCB at a local shop, manufacture it yourself (with toner transfer, a CNC at a hackerspace, etc) provided the traces aren't too thin and there are not too many layers (1 is easy, 2 is standard and cheap, more layers are expensive), or order it from china at a relatively low price (jlpcb or seedstudio will average something like $1/apiece).

Thank you for mentioning KiCAD, these are the kind of keywords that will help me get started :D

PS: And yes, while I really suck at soldering, working with physical products feels like a nice counter weight to the software world.

KiCAD is amazing, and it's all you'll need (apart from the prototype on the breadboard).

The trick to soldering is really to get a good iron, I underestimated it at the start but you really need something that keeps heat. Get a TS100 and set it to 320, soldering is going to be a breeze afterwards.

Remember, solder should flow easily and stick to the pads/wires, if it doesn't, it means you need to heat the thing up a bit more.

I my iron shoes 400 degrees in the display but somehow the pads/wires don’t heat enough to melt the solder.

It’s really weird. Maybe I messed up the tip somehow? But I just got it a few days ago!

Which iron is it? Maybe it's miscalibrated? Does the solder melt if you touch it to the tip?
How would I work with SMD components on a breadboard?
Either breakout boards or you use the through-hole versions.
If you're confident in your design, you can send it off for assembly at a manufacturer that does PCBA. They'll handle the SMD soldering for you.
Breakout boards, I assume.
>If I wanted to design this board myself, how long would it take to learn this? Are there good resources?

To learn it yourself, assuming no prior experience or knowledge, would take years of full-time study.

We’re talking low speed data lines and run of the mill digital circuits, not 10GHz range RF amplifier design. A month is probably enough.
Okay, so now I know it’ll take between 5 years and one month :D

On the one hand, I have a bit of prior knowledge. On the other hand, I want a circuit with minimal power draw in ESP32 sleep mode and i’m afraid that does require some experience.

Does it have to be an ESP?

There are other microcontrollers capable of driving an eink display that consume a lot less power out-of-the-box. Eg: atmega328 (~5 μA deep sleep, ~10mA running)

If you want wifi, then ESP is probably a good and cheap fit. A wemos d1 in deep sleep doesn't consume _that_ much power (~80 μA), unfortunately it does draw a lot when booting (~200mA).

Yes, I need wifi. And there are esp32 boards that draw 20uA in deep sleep.
I assumed zero prior knowledge. I'm a pretty smart guy but I don't think I could go from zero to "designing an esp8266-compatible board that includes an e-ink display" in a month.
A good place to start would be reference schematics from Espressif for their dev boards, and schematics from open ESP32-based boards from other vendors. Check out esp32.com for a list of boards.

With those schematics and KiCAD, you should be pretty much set. Take an hour or so watching KiCAD tutorials, it'll be worth it.

Also, spring for an ESP32-WROVER-KIT and use it to prototype with a dev board. That kit also supports JTAG debugging, which can be quite handy.

Thank you, this is really helpful.
Sure thing. By the way, I should have said esp32.net, not esp32.com. The latter is the official discussion board, but the former is an unofficial reference site that's incredibly useful.
I have used TTGO ESP32 2.9" e-Paper. For my projects it contains all what I need.

I recommend you to check that out.

Paying someone to do it is probably 200$ to 300$ on Fiverr.
I just got an Inkplate 6 and it seems pretty cool: inkplate.io.