My First Project - Resistor Help

Hello,

I’m designing my first ever circuit (design attached) after tinkering with esp8266 and WS8212b LED’s. The project is for a strip of WS8212b LED’s that will be mounted on the rear of a bicycle and controlled via some switches on the handlebars for:

  • SPST On/Off switch
  • LED indicator so I know lights are on
  • SPDT switch for “mode” switching (Safety, Christmas, ?)
  • SPDT switch for “activity” switching (e.g. Turn signals while in safety mode)
  • above switches are mounted on handlebars in a custom 3D printed case

Inputs on NodeMCU:

  • D4 - used for LED light strip data
  • D1, D2, D6, D7 - used by SPDT switches to control lights via code

The bread board will be a perma-proto from adafruit and located at rear of bike near LED strip in the “side bags”.

QUESTIONS:

  • I’m pushing 3.3V out to the handlebar switches - should I be pushing 5V instead - might simplify the wiring a little but any other reason to do that? I’m also assuming that the nodemcu is grounded internally for 5V and 3.3V?
  • The On/Off LED indicator on the handlebars has a forward voltate of 2.2V - I understand I need a resistor of 220-1000ohm - is the resistor location in the circuit correct? Could I move it to the breadboard (where I have more room) and it will still work? If so, would it just go to the left of the existing resistors on the breadboard on row 29?
  • I’ve read about the built in resistors on arduino but couldnt get them to work via INPUT_PULLUP on any of my SPDT inputs (D1, D2, D6, D7) without the 10k resistors in place on row 30-33 in the diagram which I thought was the point - can I not use the built in resistors in this setup and I need the 10k resistors as per the diagram?

Thanks in advance for the help - have made it this far without having to post and just by reading a ton :slight_smile:

Your 10K resistors are installed as PULL DOWN (connected to GND) and would be fighting the INPUT_PULLUP resistors. When you use INPUT_PULLUP the switches should connect to GND. When you use PULL DOWN resistors the switches connect to +V (5 or 3.3 whatever you're using). And the code needs to be different.

From that Fritzy thing it's impossible to tell how your switches are actually wired.They just go to a terminal block that doesn't go anywhere else. It looks like they may possibly connect to +V and if so that's why INPUT_PULLUP won't work.

And since you haven't provided any code I can't tell how you're trying to use the switches.

Steve

Hand-drawn schematics are superior to pretty Fritzing pictures.

It appears that your red thing in the pretty picture (is that a button?) connects ground to ground. In other words, it does nothing.

SteveMann:
Hand-drawn schematics are superior to pretty Fritzing pictures.

It appears that your red thing in the pretty picture (is that a button?) connects ground to ground. In other words, it does nothing.

Yes it is a SPST button and does connect Ground to Ground, however one of those grounds is coming from the power supply and the other ground for the button runs to the ground pin of the NodeMCU. This was my solution for creating a button that turned the NodeMCU entirely on/off by supplying/cutting power. Is that not correct?

Can anyone think of a more useless circuit?

ground-ground.jpg

OP- Except for very rare circumstances, all grounds should be connected together.

ground-ground.jpg

slipstick:
When you use INPUT_PULLUP the switches should connect to GND. When you use PULL DOWN resistors the switches connect to +V (5 or 3.3 whatever you're using). And the code needs to be different.

Thanks - this put me on the right track and I have it working. The key info is that the switches need to open/close the Ground connection when used with INPUT_PULLUP - mine were "connecting" V and Ground together when the circuit closed.

slipstick:
From that Fritzy thing it's impossible to tell how your switches are actually wired.They just go to a terminal block that doesn't go anywhere else. It looks like they may possibly connect to +V and if so that's why INPUT_PULLUP won't work.

Correct - they were connected to +V. In the diagram the 8 gray wires represent a cat6 cable that runs between the two terminal blocks - I added a note in the diagram hoping to make that clear but obviously failed :slight_smile:

slipstick:
And since you haven't provided any code I can't tell how you're trying to use the switches.

All good - I modified the code by using INPUT_PULLUP in the setup and then modified the true/false statements to be the opposite of what they were previously.[/quote]

SteveMann:
Can anyone think of a more useless circuit?

ground-ground.jpg

OP- Except for very rare circumstances, all grounds should be connected together.

so a simple SPST switch to turn the NodeMCU on/off should be wired with +V to one terminal and GND to the other? Sorry, I'm not an Electrical Engineer, nor a pilot, but I do try and be polite and patient with people when I try to teach them new things.

You are correct in the sense that to switch power to something you can place the switch in either the positive or negative connection from the power source and I think that's what you're doing. If the complete circuit isn't made the power doesn't flow. So power supply negative to one side of the switch and all the normal GND connections on the other side?

Your odd way of drawing things does tend to confuse matters and most people tend to switch the positive side of the power supply. Even though switching negative works, positive just seems more logical to most of us.

Steve

AussieInSeattle:
so a simple SPST switch to turn the NodeMCU on/off should be wired with +V to one terminal and GND to the other? Sorry, I'm not an Electrical Engineer, nor a pilot, but I do try and be polite and patient with people when I try to teach them new things.

If you do this, you will turn the NodeMCU off when the switch is closed. Probably permanently.

This is what your pretty picture is showing. It's a strange way to detect switch positions, not that it can't be done, but there is an easier way using the INPUT_PULLUP in the processor board:

The "normal" way to detect switches using the internal pullup resistors on the processor board:

As drawn, your LED will always be on. And VERY bright. Perhaps a series resistor of 1K or even 2K would be a better light level.

I didn't redraw the LED strip section because it is correct. I would, however recommend a 47uF to 100uF electrolytic capacitor (or anything in-between) on the power leads of the LED strip. Watch the polarity or you may smoke the capacitor. (There is likely no one here who hasn't done this at some time).

If the unidentified red thingie in the Fritzing picture is a switch and you want to turn the NodeMCU on or off, then it should be wired thus:

Which brings up a new question. How are you going to power a USB Power Bank on a bicycle? Do you have a mile-long extension cord?

Also, the breadboard is fine for benchtop experiments, but I would never use it in a final project- there's just too many connections that can or likely will come loose.

Thanks @slipstick - very helpful. You are correct - I am switching the negative side from the power supply with ground and not ground to ground - I did some more reading after your last post and came to the conclusion it was fine in this case and that the requirement to switch the positive side is the case when wiring 12volt circuits on a car (due to a lot of things being ground to the body of the car) and likewise for residential wiring (at least in the US).

I’ve updated and attached my wiring diagram that hopefully makes things clearer and also eliminates the resistors for the switches as I now use GND and INPUT_PULLUP - sorry about the “pretty” approach - will teach myself the line drawing/traditional approach as I progress. I went with the pretty/fritzing approach as a newbie as to me it is very close to 1:1 “visually” with what I will actually build - I assume that is why other newbies use it too. I now understand that it can introduce confusion though.

Thanks again for your help.

Thanks @SteveMann - very helpful - appreciate your response. I think I have everything the same as what you just showed (updated diagram in my last post). Only difference is my red switch is switching the negative side of the power supply instead of the positive - I may swap it to switch the 5V as I have an extra wire (which I think I'll need) available in the cat6 cable I am using between the two components.

For the "USB Power Bank on a bicycle/long extension cord" question - the 5V/2A powerbank is a portable 5V powerbank used to charge cellphones (Anker 10,000mAh).

Current Setup:
I am already using the above approach with the lights and NodeMcu but without the 3 switches and single led on the handlebars - so no on/off switch or other control via switches. I currently run WLED (www.wled.me) on the NodeMcu for control instead. The current circuit uses the 5V powerbank to power the NodeMcu and 90 LED light strip with no switches at all and just the D4 pin in play. The new version will still use WLED but I'll modify the code so I can use my switches to run certain custom animations depending on their position (turn signals for example). In testing so far, the 10,000mAh battery seems to be enough to last a week of our short 1 mile commute to and from school. I also limit the power draw of the 90 LED's in the WLED software to 1000ma.

Here's a video of the current setup mentioned above that we used for christmas lights - the new version with switches on the handlebars will allow me to use the lights as turn signals etc:

SteveMann:
Also, the breadboard is fine for benchtop experiments, but I would never use it in a final project- there's just too many connections that can or likely will come loose.

Understood - I'll be using a perma-proto board from adafruit with all soldered connections and terminal blocks for easy disconnect of the power supply, led strip and connection to the component on the handlebars. The top/upper terminal block will likely be eliminated and I'll just solder the cat6 directly into those switches/etc that are in a custom 3d printed enclosure on the handlebars. I'll also add two female headers to the perma-proto for the NodeMcu to plug into for easy removal/re-programming.