ok. the parts in the pic all need to go together with the exception of option 1. parts 1 nd 2 are connected via the usb a and c respectively. what i am aiming for is part 3 to display the power level as a specific color. so here is the question. how do i connect part 1 to part 2 to read power level and how do i connect the led to everything to display the level? finally do i need the optional part or could it make my circuit easier to program?
the led is common anode according to adafruits product page. also, dont worry about resistors on the led, it comes with a resistor built in
#annies projects
1 messages · Page 1 of 1 (latest)
I notice the battery charge circuit has a low battery indicator - that'd be easier to read: https://learn.adafruit.com/adafruit-powerboost-500-plus-charger/pinouts
LBO - not a leveraged buy out! this is the Low Battery Output. By default it is pulled high to BAT but when the charger detects a low voltage (under 3.2V) the pin will drop down to 0V. You can use this to signal when its time to shut down or alert the user that the battery is low. There is also a red LED connected to this pin.
seems easier than measuring an analog voltage, if you're concerned about that
@keen nacelleyou said you may be able to help with programming right?
Yes; I’m off work in ~2 hours
kk. i can wait 🙂
@nova ingot I’m available for the next few hours. What’s your timing? And what have you done so far?
nothing. i cant figure out how to access the qt py
What happens when you plug it into your computer?
If you double-click the reset button on the board while it’s plugged in to your computer, it should show up as a storage device
@nova ingot ping in case you didn’t see this
thanks for pinging. im simplifying my board and dont have general notifications on
nothing happens
No lights on the board? No connection chime on the computer?
How quickly are you double clicking the button?
lights yes, no computer reaction
Ooh lights that’s not nothing
might be a power only cable
should soon
Alright. Well, that’s going to be necessary. Feel free to let me know when you have one then.
How quickly are you double-clicking the button though? Similar to a mouse double-click?
yeah, not working at all
Okay. Well once you get a USB C cable that can handle data we can try this again.
im trying to rewrite your code a bit and dont know how to do something
Can you be more specific?
What are you trying to do?
im trying to expand the if thens but dont know how to alter it to make it work
i need it to read the percentage of juice left and display it as a color. you have it as its either full or its not currently
I don't know how to define percentage
oops, didn't see this
I guess looking at https://learn.adafruit.com/li-ion-and-lipoly-batteries/voltages
@nova ingot I guess without getting those discharge curves involved, an estimate of percentage would be something like
(current voltage - minimum voltage) / (nominal voltage - minimum voltage) ?
@nova ingot You might need https://www.adafruit.com/product/4712 to get a better number? How accurate do you want this to be?
do i need the board? cant i just use the programing on the qt?
@nova ingot You don't need it, no, but it would reduce the number of problems you need to solve yourself. Do you need more detail on the linear percentage estimate?
i dont know. i was thinking of just using the program code from the fuel guage board
im not 100 % sure. coding isnt in my wheelhouse yet
You need the board to be able to use the code for it
but if we can figure out what it's doing, we may be able to avoid it
I just... the curve seems tricky
Can you remind me what the current code you're using is?
Does it work as you'd expect, even though it doesn't have the color codes like you wanted?
i dont yet
im currently working on the code you supplied.
i just dont know how to figure out how to alter it as i understand percentages but not voltages
I'm looking at what that board does, and it seems nontrivial to measure battery voltage with precision. If you just need rough numbers hopefully we can get close enough.
ah, okay
so what you'll want here is elif
if you've seen other languages, it's like else if
so the if/else becomes if/elif/else and we can build the colors out that way
the closest i have to programing is using rpg maker to make games
unlike else, elif needs a condition
i cal them if then else statement chains
i can write those. its the numbers that excape me
so the discharge capacity is kinda reversed.100% is 100% dead
and with orange after that as < 3.5, the else leaves higher than 3.5 volts
yep, 100% discharged is dead
I think it means how much of its capacity it has discharged
it's neat to see how when it's cold the voltages are lower and it hits 3.0v where it's useless while still technically having charge
do you want me to give you the syntax for adding an orange band?
or whichever colors it was you wanted
hold on, let me try first
if voltage < 3:
led.fill(RED)
else:
if voltage < 3.5:
led.fill(orange)
else:
if voltage < 3.7:
led.fill(yellow)
else:
led.fill(GREEN)
those less thans may do better as a range
close, and I see what you're going for
3.7v is the nominal voltage of the cell, isn't it?
what voltage is printed on it?
it says 3.7 on the batery
alright
so uh there's a YELLOW, but there's no orange
are you familiar with color pickers?
oh
oh. in the program you sent
I guess you added on then, yeah
ok, i read that wrong
okay so I was vague about the syntax
try this - I just deleted thingsif voltage < 3: led.fill(RED) elif voltage < 3.5: led.fill(orange) elif voltage < 3.7: led.fill(yellow) else: led.fill(GREEN)
oh my whitespace is wrong
I'm assuming you can fix that though
whitespace?
oh, yeah i can
I'm pretty sure 3.0v is the outright minimum, so your board would likely be dead before it displays red with these thresholds
ok, so 3.7 is full and 3 is dead
I believe so, yes
ok, that means for 4 colors, i nees a .2 step each
if voltage < 3.1:
led.fill(RED)
elif voltage < 3.5:
led.fill(orange)
elif voltage < 3.7:
led.fill(yellow)
else:
led.fill(GREEN)
crap
what
where's orange defined?
also things are case-sensitive so yellow should be YELLOW
import time
import board
import neopixel
from analogio import AnalogIn
def main():
analog_in = AnalogIn(board.A1)
led = neopixel.NeoPixel(board.NEOPIXEL, 1, brightness=0.3, auto_write=True)
while True:
voltage = get_voltage(analog_in)
print(voltage)
if voltage < 3.1:
led.fill(RED)
elif voltage 3.2-3.3:
led.fill(ORANGE)
elif voltage 3.4-3.5:
led.fill(YELLOW)
else:
led.fill(GREEN) *voltage is 3.6-3.7*
time.sleep(0.1)
def get_voltage(pin):
return (pin.value * 3.3) / 65536
RED = (255, 0, 0)
YELLOW = (255, 150, 0)
GREEN = (0, 255, 0)
CYAN = (0, 255, 255)
BLUE = (0, 0, 255)
PURPLE = (180, 0, 255)
ORANGE = (255, 165, 0)
main()
that won't work - voltage 3.2-3.3 isn't a testable condition
do you know where to get to the serial console?
that can help you test things
are you using Mu Editor?
NOTEPAD++
it'll make it easier to test things
there's a "serial" button where you can run code directly on the microcontroller
i dont have the microcontroller hooked up
still waiting on a cable?
waiting on a pc. mine dont have 3.0 usbs
you don't need USB 3.0
ill try again then
sorry, I shouldn't have distracted you
let's get the core of it down first
if I may make a suggestion: let's break this up a little to make it easier to test
ok
one moment working on a change
you can run code in this https://www.python.org/shell/
to help make sure your syntax and logic are what you wanted
I moved the if chain into a function
now what you can do is paste the voltage_to_color() function in the shell, then run voltage_to_color() with different voltages to see if you get the color you wanted
for instance, here's what I get (I didn't paste in the colors but the error messages are clearer than the values would be about which color it's returning)
... if voltage < 3.1:
... return RED
... elif voltage < 3.3:
... return YELLOW
... else:
... return GREEN
...
>>> voltage_to_color(3.4)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "<stdin>", line 7, in voltage_to_color
NameError: name 'GREEN' is not defined
>>> voltage_to_color(3.2)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "<stdin>", line 5, in voltage_to_color
NameError: name 'YELLOW' is not defined
>>>```
I'm not typing >>> - that's how the shell indicates it's ready for new input
... is how it indicates it's waiting for another line, so after I pasted the function I had to press enter twice to complete the function and get back to >>>
does that make sense?
im not sure. i am having issues with the shell
unexpected indent
ill be back. im going to take a shower and clear my head
once you get back, if you can give me a screenshot of the shell I bet I can tell you where the unexpected indent is
ah, you're pasting from your code, not the one I gave you
I mean the first code I gave you
yeah. im doing yours in a sec
try pasting lines 19 through 25, inclusive
for the first error, add a space
python cares about whitespace, but there are other syntax errors we'll need to fix
elif voltage 3.2-3.3 is not valid Python
all the elifs and the else need to be indented at the same level if they're part of the same decision
you should be able to use shift-tab to remove indents
if you want to write a comment use #
so after led.fill(GREEN) you can put # and it'll ignore the comment
ok, except for the comment issue, it says it understands it
replace the first * in that line with #
you might be thinking of C++, where comments /* look like this? */ or maybe it's a game maker thing, I dunno
i already fixed it on my end
cool!
seeems that was the last problem
yay
I've got to go pick up my car; hopefully we can make more progress another day :)
bye for now
i finally got the qt to resister in my pc
Now i just need to figure out how to upload the code. Tomorrow i think
I hope you don't mind my jumping in with a comment. In my experience LiPo batteries will charge to approximately 4.1 - 4.2V and will then drop to approximately 3.3 - 3.2V before they cut out. You may find that you will want to adjust your limits. Good luck with your project.
Ah, so it’s dead before it gets disconnected? The article does say that, now that you mention it. Thanks!
@nova ingot Do you know what you changed to get it to work? It should show up as a “CIRCUITPY” flash drive. If not, try following https://learn.adafruit.com/adafruit-qt-py/circuitpython
Note that the QT PY has very little memory, so for instance I’ve been unable to connect a rotary encoder and control the NeoPixel at the same time when using CircuitPython.
Yes. I held boot while plugging it in.
Ill probably have to upgrade the memory on my custom board then
Oh! I didn't realize that did anything.
I thought only double-clicking reset did anything.
The RP2040 bootloader is a bit different than other boards since it is "built in". You hold BOOT while plugging in or pressing RESET then release BOOT and it will enter the Bootloader.
The QT PY only exposes the reset button, though.
Oh -- that is a QTPY M0 -- I thought you had a QTPY RP2040 -- sorry.. this picture had an RP2040 in it (note the two buttons) <#912821112528834562 message>
Oh! I… it sure did. You’re right! I was wrong about which board is in use here.
Sorry to have jumped in with irrelevant information....
@nova ingot I’m wrong - if you’re using a QT PY RP2040, you have plenty of RAM.
It wasn’t irrelevant at all! You helped me finally realize I’ve been making an incorrect assumption this entire time. I didn’t look at the diagram closely enough.
OK -- In that case -- glad I could help 😉 It's dangerous to jump into an ongoing thread. I got confused by who was posting. I think I see now and it is the QTPY RP2040 in use... good luck.
It is the rp2040
btw does the leds blink with this code or shine solid
and how do i get it to effect off board leds?
so i want the range between 3.3 and 4.2? or do i want 3.0 to 4.2
This guide may help https://learn.adafruit.com/li-ion-and-lipoly-batteries/voltages. I’d go with 3.4 -4.2
@keen nacelle is there a but statement? ie if voltage is < 3.9 but > 3.7 then return orange
red would be anything lower than 3.4 then
AND might work <3.9 and > 3.7
Sounds good to me.
@nova ingot Answering your question directly, and will work. However, the statements are already such that it won't be necessary.
because for each value it'll choose one color, and not do the others
it starts with the first statement, and if it's below that threshold, it does that, and the values strictly increase with each following statement
this means each statement already has an implied >= the previous value checked for
ok. so how do i make this work on an off board led
the only reason it's doing this is because the if, elif, and else statements are all together
that depends on how it's connected
what one did you have in mind? can you link its documentation here please?
By popular demand, we now have latching rugged metal push buttons with a full color RGB LED ring light! These chrome-plated metal buttons are rugged, but certainly not lacking in flair. ...
i was going to have it go out through a1, 2, and 3 but dont quite now how to do it
i got the rgb one
not yet
do you need help figuring out how to do that?
Maybe, unless its just soldering the led wires to a0-a3
it's not
it's close to that, but one needs to go to power - can you see which one is marked C or C+?
the 3 pins specific to each color can go to a0-a2 or whichever pins you like, provided they're capable of PWM output. I'll check the QT PY RP2040 docs; one moment
Not currently. Not able to get to my desk, though i beleve c is the common on it
yep - it's a common anode, so that connects to the USB pin
I didnt read your followups before answering
you could technically use the 3v pin, but that would be drawing power from the voltage regulator also used for the processor on the board, which can cause problems
So a0-a3 are technivally the same thing, kinda like the tines on a fork are still part of the fork, but each tine can hold something different
And i may need to get some diy female header parts as i cant perminately wire it up.
I mean the pins on the board
you can read the documentation about that here https://learn.adafruit.com/adafruit-qt-py-2040/pinouts#pwm-on-rp2040-3091653-11
I still don't understand what you mean. Have you modified your board from how it looks in the picture on the store?
You can use a breadboard to avoid soldering LED lines to it
Since i can wite the leds up to any pin so long as common is on usb, that means that the pin order technically doesnt matter until its programed. Ie, pin a0 can be red or blue, but is green because the program says it is
A better example may be a usb/hdmi splitter
Sorry if i am hard to understand. I understand things by equating. I learned how to play magic by drawing paralells to yugioh
gotcha. you're good! I'm happy to follow along, but it may take me a bit to find what I'm missing.
the board you're using can't do PWM on pins that share a PWM slice - its pins are paired
so you can do, say, A0 and A2, but doing so ties up A1 and A3 for PWM purposes at the same time
you can tell because
A0/D0 - This pin is ADC3. It is also SPI1 CS, I2C0 SCL and PWM6 B. A1/D1 - This pin is ADC2. It is also SPI1 MISO, I2C1 SDA and PWM6 A. A2/D2 - This pin is ADC1. It is also SPI1 MOSI, I2C1 SCL and PWM5 B. A3/D3 - This pin is ADC0. It is also SPI1 SCK, I2C1 SDA and PWM5 A.
So if i wire red and green to 1 and 3, then blue has to go to either 0 or 2
no - wiring to 1 and 3 means 0 and 2 cannot be used to control other LEDs at the same time
see how A0 and A1, and A2 and A3 have the same PWM number?
(this is not typical; this is the first board I've worked with that's done this)
Ah. So its kinda like a trafic light, left cant go if you are driving forward
sure
So, how do i getthe third color in there?
picking one that is on the same side and labelled clearly - I'd recommend using TX for whichever color is left
TX/D6 - The main UART1 TX pin. It is also I2C0 SDA and PWM2 A.
as it's PWM2, it doesn't conflict with the PWM6 and PWM5 you're already using
that leaves SDA/SCL open to do ~SCL I2C things if you need them to later
So, if i pic a0, id have to go with any pwn6 pin, so miso may work? Or did i get that wrong somewhere
Once you pick a PWM6 pin, you cannot use the other PWM6 pin for PWM.
MISO would work too, yes
because it is PWM2
OH! SO I CAN DO A PMW2, 5, AND 6
yes!
but i cant do 2 pmw5 and a 6
correct
Ok. Slight rework to my custom board design but nothing to extranuous
aw crap I'm wrong
sigh. I've taught you incorrectly
how about we both read this documentation carefully?
Ok, so i need to look at the data sheet or the schematic and find out whish pins are which pmws
I misunderstood the documentation - there are multiple pins with exactly the same slice assigned
and that's where the problem comes from
TX/D6 - The main UART1 TX pin. It is also I2C0 SDA and PWM2 A.
MI/D9 - The main SPI0 MISO and digital I/O pin 9. It is also UART1 TX, I2C0 SDA and PWM2 A.
in any case, the pins we picked earlier don't conflict in that way either and will still work
however, this does open up the more attractive option of just using a0-a2 like you wanted to in the first place
my bad!
I have no idea why they presented it like this - that each slice has two outputs complicates understanding that a single PWM output is shared between pins.
Which is the whole point, whereas I misunderstood and ran off into the weeds reading something into it that wasn't there.
So, each pwm has 2 outputs? If using one shuts down the other then why
Ok, so the a0 through a3 pins. I misunderstood
you only have 3 PWM outputs here - red, green, and blue. C+ goes to a power source like the USB pin.
a0-a3 is 4
am I missing something?
I know, i mean to say i can use any of the 4
ah, gotcha
Any 3 of the 4
yes
alright so programming these
where you pass board.A0 or whatever instead - one for each color
then, because a NeoPixel isn't doing it for you, you'll have to individually control each color
which isn't too hard because the colors are already defined that way
does that make sense so far?
yes, just not in use
i understand the meaning but lack the language
btw, where is it reading the power level from?
i think through various helpers we came up with bat to a0
the thing we're doing here is to read the voltage of the battery itself as an analog value
so, yes, if the battery is connected to a0, it'll use that to read battery voltage
so analog_in = AnalogIn(board.A0)
provided the appropriate imports before that line, yes
import time
import board
import neopixel
from analogio import AnalogIn
yep that'll do it
except om not using the neopixel, at least not primarily as its hidden inside a casing
no, these aren't analog outputs
for these you're using PWM
I'd recommend leaving the neopixel in
because it'll make it easier to diagnose problems because it's harder to get the built-in neopixel wrong than for something to be wrong with an external RGB LED
ok, so the neopixel will show what is supposed to happen in case the rgb switch isnt working
yep! I think that'd be helpful
so leave the code we established for the neo
yep
would you be interested in typing into the same document?
I could paste things in and help with syntax
if not, could you show me what you currently have?
it seems like you've been tweaking things
https://pad.riseup.net/p/RGB_battery_voltage will let us type in the same place
import time
import board
import neopixel
from analogio import AnalogIn
def main():
analog_in = AnalogIn(board.A1)
led = AnalogOut(board.neopixel, 1, brightness=0.3, auto_write=True)
while True:
voltage = get_voltage(analog_in)
print(voltage)
if voltage < 3.4: # voltage is less than 3.4. recharge
led.fill(RED)
elif voltage < 3.6:
led.fill(ORANGE) # voltage is 3.4-3.6
elif voltage < 3.9:
led.fill(YELLOW) # voltage is 3.7-3.9
else:
led.fill(GREEN) # voltage is 4-4.2
time.sleep(0.1)
def get_voltage(pin):
return (pin.value * 3.3) / 65536
RED = (255, 0, 0)
YELLOW = (255, 150, 0)
GREEN = (0, 255, 0)
CYAN = (0, 255, 255)
BLUE = (0, 0, 255)
PURPLE = (180, 0, 255)
ORANGE = (255, 165, 0)
main()
so the link I've posted breaks out the color determination, which I think will be helpful in avoiding duplication if we're setting both the NeoPixel and the RGB LED
using voltage_to_color?
yeah
so all i need is to update the rgb values and the if thens
yep
ok. updated the if thens
i plugged it into python shell and its saying undefined name led
ah, the function needs to return the value, it doesn't have the - yeah
the function doesn't have the led - only main does
fixing now
now what'd be good is a function that'll set both the neopixel and the button LED
I've moved the led out so functions can access it now - you're right that it's weird to keep it in main() for a very small purpose-built program like this
we could pass it around from main, but why bother
ooh, we had the wrong pin specified for battery voltage
your diagram has it in A0, but the code was using A1
any idea which pins are which colors?
no
give me one second. i gave to fish out my switch
green is c
from there each wire is: d, ground, +, b, a
hm, I don't understand what those letters mean. I know there's a button, so that's one of them and ground, but which color is which
i need to test them real quick
okay
unfortunately I have discovered something that will require more changes: the board can't take the battery voltage as an input. it's too high. https://datasheets.raspberrypi.com/rp2040/rp2040-datasheet.pdf contains
Because I/O supply is 3.3v, we can't feed it more than that as an analog input
er, ADC supply
the way I'd know how to deal with this is to have resistors to split the voltage from the battery to something that the board can safely read, but that'll mean putting power from the battery out as heat just to tell how much is left in the battery
thoughts?
yes, but bat is essentially direct power from the battery, not the board, so isnt that like 3.7?
usually, yes, and up to 4.2. either way, it's more than 3.3v, so it can't be put as an input
so vlipo wont work either as its both 5v and vbat
what's vlipo?
im using the power boost 1000c. it has vbat and vlipo. vbat is direct batery where as vlipo is direct battery or direct charge source
aha, I got thrown off again by the diagram using 500c
I forgot you were using one not in the diagram
and yes, you're correct
yeah, fritzing dont have 1000c
is it worth another look at https://www.adafruit.com/product/4712 ?
it is built to solve precisely this problem
we could get around it, but it'd take more battery to do it, and add complexity
and heat
is there something else that can safely read the voltage and tell the qt what the number is? something small, like a component?
ah, you have size constraints on this project?
that... makes a lot of sense for something battery powered
I guess a voltage divider is the way to go, then
do you have at least 2 resistors around 10k ohms?
I'm looking at https://neatcircuits.com/l-shift.htm
it describes voltage dividers
if i do they are unlabeled, lost and cheap
ok, so d is blue,b b is green, and a is red
can we get it to read from the usb somehow
if we use that, you can see that even 4.2v from the battery will be a safe 2.1v
we just have to multiply the voltages we get by 2
so when the qt reads 2 its actually 4
so if i get a resistor set that divides by 4, 1 would be as 4 and 2 would be as 8
yes
however, you'll need resistors of different resistances to cut to 1/4 instead of 1/2
if you haven't already found it, you can double-click on things to change voltages / resistances and see what happens
My new iron cleaner 😜
haha wow that'll do it
maybe you can poke the evil out of vader
how's it feel to be a star wars neurosurgeon
its just a printed salt shaker that my mind went "needs brains"
aah. it really does
next steps really depend on what resistors you can scare up
do you want to see if we can get the PWM RGB LED code to a good place?
I'm going to sign off for tonight soon
yeah. we can do it tomorrow
okay!
i need to get my boards ready on the breadboard
it looks like you're using a permaproto board
are you aware that prototyping breadboards exist?
they don't require soldering
yes
I used the protoboard to make an energency light using the 1000cs onboard blue light
alrighty
and to stablize my battery. the stock wires broke
i wasnt exatly carefull and it was stranded wire
Aah, I see why you didn't want to deal with another board taking up space.
in all fairness, this wasnt the final project
do you know if that battery has protection circuitry? It looks like it might be a raw cell
it has a board on it if thats what you mean
i used to be the same way. i can link you the project that helped me understand
please do! :)
as for the project, its a pacekeeper blaster altered for use with the oculus quest 2
it's an addon to oculus quest 2 controllers?
yes. allows quick change between pistols and rifle
there is a stock for it too that makes it work. the electro magnet allows you to couple them and a power interup switch allows quick disconnect for a quick reload or to go back to pistols
for games like resident evil 4
no, just eachother. rifles are hard to use in re4 so i designed this
all other options seem to be rifle or pistol.
and yeah, they just released a vr version last month for 30-40
sweet
I already don't like horror so I will stay FAR AWAY
but it's very cool that it exists for those who like it
I couldn't bear leaving it incomplete so I did the PWM stuff https://pad.riseup.net/p/RGB_battery_voltage
I haven't gotten into much other than Beat Saber
I tried Into The Radius but there was too much going on for me to learn it easily
i kinda can play horror, when im able to mentally handle it
have you tried RE5?
I've seen playthroughs and it looks horrific, which for horror folks I think is good?
i have all of them
Your journey awaits in this new Blender Beginner tutorial series. Dive into Blender 2.9 with CG professional Robby Branham!
CG Fast Track Course Library: https://www.cgfasttrack.com/library?utm_source=youtube&utm_medium=link&utm_campaign=BFT2
Download files: http://cgfasttrack.com/blender-fast-track2?utm_source=youtube&utm_medium=link&utm_camp...
they all are good but the pov ones are more triggering
I secured the battery better. Dont worry, i dremeled the last 2 holes off of from the rest of the traces so i dont create a short
and im putting in a switch to kill power when no board is being used
works
its all good, thats why im not going right into wiring everything then programing
especially not when you're soldering it all, yeah
besides, your mistakes teach me too
yeah. I'm glad you're in a headspace that allows that perspective.
it'd be easy to be in a mindset where this is all just Very Frustrating
on the voltage divider a 9 ohm and a 3 ohm should yield about 1.05 v yes?
For what input voltage? I think those resistances may be too low. Wiki has an article on voltage dividers that goes over the math. If you mean 4.2v input, yes: 3 / (9+3) = 3/12 = 1/4
yes, 4.2
You have 9 and 3 ohm resistors? Those values seem really low. Or are those just example values?
examles i suppose. i figure that a 1:3 ratio should divide by 4
how about 10 and 30
You're correct about 10:30 having a voltage output of 1/4 of the input
I'm concerned about low resistance values because that'll let a lot of power through. That will mean more heat and more battery drain.
sorry, original number was 3k to9k
i did find some resistors but i dont know what they are yet
oh neat I can paste math formulas from wikipedia
note that this means the smaller resistor goes second
its either a 330 ohm or 100k
330...k? or 330?
330
330 / (330 + 100000) = hmmm
i have a few loose that i have to identify
oh good
a 5k, a few 1 ohn and 10 ohm, a 100 ohm, a 10k(or a 2.2k) and a 130 ohm (or a 100k
and no way to measure then
the markings are ambiguous?
hmm... maybe we can use the QT PY RP2040 to measure the resistance
yeah, i don know which way they are supposed to be read unless they are silver or gold
well, we need to know one resistor's value
I'm still trying to understand the articles I'm finding
the parts I have so far is that the current through resistors in series will be the same, and we have a known input voltage, and can measure the output voltage from a voltage divider
it sounds like the 5k was unambiguous
no. that was the only one i had labeled
un ambiguous? like, not ambiguous.
oh sorry
there's a papercraft contraption but it seems pretty elaborate https://learn.adafruit.com/papercraft-resistor-helper/overview
no worries
I'm currently looking at this article https://mechatrofice.com/arduino/ohmmeter
my cat is mad that I'm focusing
okay I think I understand how to do this now
want me to try to explain it?
@nova ingot
Sure
okay I'm writing up things here https://pad.riseup.net/p/measure_resistance
and considering this example circuit
we know the resistance of one of the resistors, and can measure the voltage drop from the known input to the divider after going through the unknown resistor
because we know the value of the second resistor, and because the rest of the voltage drop is over it, we can compute the current, which is the same for both resistors
(this last part I don't know why, but the simulator agrees at least)
you're familiar with ohm's law? v=IR?
Yes and no, i know of it but keep forgetting it
We know resistor 1 drops voltage by x but voltage y is cirrently unknown. By measuring y and plugging it into ohms law we can figgure out resistor 2
both voltages are known
because it must get to 0 when it gets to ground
so we have voltage input known, measured voltage after the first resistor, so also known, and then the voltage drop after the second resistor is the input minus the first drop
where ohm's law comes in is computing the current in the circuit
because we know the voltage and resistance of the second resistor, I=v/r
is now computable
does that make sense?
1I think so
alright. so now we know all 3 for the second resistor
and for some reason I don't understand, the current is the same for the entire circuit, so we now have both V and I for the first resistor
v=ir now becomes r=v/i and we have the resistance of the first resistor
Ok. Ill look it all over. Right now i think i need a nap
alrighty. I'll finish up this circuitpython for measuring
Here's the code - I tested it and it was wrong compared to my multimeter, but I hope close enough to resolve the 10k/2.2k and 130/100k ambiguities
incorrect code deleted
I used this with a 215 ohm and 214 ohm resistor. It measured the 214 ohm resistor as 184 ohms. Wrong, but not incredibly so.
aha another mistake - the measured voltage isn't the drop over the first resistor, it's the drop over the second one. Because the value after the first resistor is just what's left to drop to 0 over the second one.
here's the fixed code
import board
from analogio import AnalogIn
from digitalio import DigitalInOut
# Set up a voltage divider with an unknown resistor you want
# to measure as the first resistor, a known second resistance,
# and a pin as power input to the divider.
# Configure these appropriately:
power_out = DigitalInOut(board.A4)
analog_in = AnalogIn(board.A3)
second_ohms = 215
# Immediately known values in this voltage divider:
# - The resistance of the resistor after the measurement point
# - The input voltage to the divider (reference voltage)
# - The voltage drop over the second, known resistor
# We compute:
# - The current through the circuit, given we know V and R for the second resistor
# - The voltage drop across the first resistor (input - voltage drop across second)
# - The resistance of the first resistor, now that we know its V and I.
def main():
# Turn on the output pin to provide the reference voltage
# as input to the divider.
power_out.switch_to_output()
power_out.value = True
while True:
second_voltage = get_voltage(analog_in)
first_voltage = analog_in.reference_voltage - second_voltage
current = second_voltage / second_ohms
if current == 0:
print("overload")
else:
first_ohms = first_voltage / current
print(first_ohms)
time.sleep(0.2)
def get_voltage(pin):
return (pin.value * pin.reference_voltage) / (2 ** 16 - 1)
main()
the only issue is i have no way of reading it. i mean, we could assign colors to each possible result and have it print to neopixel
import board
import neopixel
from analogio import AnalogIn
from digitalio import DigitalInOut
power_out = DigitalInOut(board.A4)
analog_in = AnalogIn(board.A3)
led = neopixel.NeoPixel(board.NEOPIXEL, 1, brightness=0.3, auto_write=True)
second_ohms = 215
def main():
# Turn on the output pin to provide the reference voltage
# as input to the divider.
power_out.switch_to_output()
power_out.value = True
while True:
second_voltage = get_voltage(analog_in)
first_voltage = analog_in.reference_voltage - second_voltage
current = second_voltage / second_ohms
if current == 0:
print("overload")
else:
first_ohms = first_voltage / current
print(first_ohms)
def main():
analog_in = AnalogIn(board.A3)
led = neopixel.NeoPixel(board.NEOPIXEL, 1, brightness=0.3, auto_write=True)
while True:
print(first_ohms)
if first_ohms = 10k:
return PURPLE
elif first_ohms = 2.2K:
return YELLOW
elif first_ohms = 330:
return BLUE
elif first_ohms = 100K:
return ORANGE
else:
return RED
time.sleep(0.2)
RED = (255, 0, 0)
YELLOW = (255, 150, 0)
GREEN = (0, 255, 0)
CYAN = (0, 255, 255)
BLUE = (0, 0, 255)
PURPLE = (180, 0, 255)
ORANGE = (255, 165, 0)
def get_voltage(pin):
return (pin.value * pin.reference_voltage) / (2 ** 16 - 1)
main()```
unfortunatly its saying syntax is wrong in the led section
No way of reading… the resistance?
That’s not something we need to integrate with the RGB button stuff
you have some duplicated code.
If you click monitor in Mu Editor it’ll show you the things it’s printing @nova ingot
def main led = .... analog_in gets redefined ???
Also use == for equality checks; single = is for assignment
These can be separate projects - we need only measure a resistor for setting up the voltage divider. No need to try to integrate them.
there are also 2 while True: loops -- you will never exit the first one
I don’t think it’s worth getting that one working as I don’t see a reason for a resistor measurement to have a battery level estimate
i dont have a way of seeing the values
You do - you just don’t know it yet
While the board is plugged into your computer, click the Monitor button in Mu Editor
so i just use jump wires to connect the resistors and use my computer in place of a dedicated screen
Yes
We only need to use the resistor measuring code long enough to figure out the ones that have unclear codes
I’d suggest using the one that’s definitely 5k and the one that’s either 10k or 2.2k
true, i just dont really know if i have a cable thats long enough. need to look
Long enough to connect what? Are you not able to use your breadboard temporarily?
You could use only one wire if you can get the resistors themselves to reach for the other connections
import board
import neopixel
from analogio import AnalogIn
from digitalio import DigitalInOut
power_out = DigitalInOut(board.A4)
analog_in = AnalogIn(board.A3)
led = neopixel.NeoPixel(board.NEOPIXEL, 1, brightness=0.3, auto_write=True)
second_ohms = 215
def main():
# Turn on the output pin to provide the reference voltage
# as input to the divider.
power_out.switch_to_output()
power_out.value = True
while True:
second_voltage = get_voltage(analog_in)
first_voltage = analog_in.reference_voltage - second_voltage
current = second_voltage / second_ohms
if current == 0:
print("overload")
else:
first_ohms = first_voltage / current
print(first_ohms)
if first_ohms == 100000:
return PURPLE
elif first_ohms == 2.2000:
return YELLOW
elif first_ohms == 330:
return BLUE
elif first_ohms == 100000:
return ORANGE
else:
return RED
time.sleep(0.2)
RED = (255, 0, 0)
YELLOW = (255, 150, 0)
GREEN = (0, 255, 0)
CYAN = (0, 255, 255)
BLUE = (0, 0, 255)
PURPLE = (180, 0, 255)
ORANGE = (255, 165, 0)
def get_voltage(pin):
return (pin.value * pin.reference_voltage) / (2 ** 16 - 1)
main()```
i fixed it though
the qt to the computer while using the breadboard
my hope is that with this code, specific colors will flash based on what the resistor is. since i know what they can be, i just need 2 colors per resistor. if it flashes purple its 100k, yellow 2.2k
if neither red
unless im testing the other resistor, then it does the same thing but with blue and orange
This section ``` if first_ohms == 100000:
return PURPLE
elif first_ohms == 2.2000:
return YELLOW
elif first_ohms == 330:
return BLUE
elif first_ohms == 100000:
return ORANGE
else:
return RED
Good point
yeah. i know
the resistor codes give me 2 possible values, so, assuming the code is accurate, i know the potential values
I don’t think this will accomplish what you’re planning
is there a way to rewrite it to have some leeway for tollerance
There is, but I don’t think this is a productive approach. You said you figured out a way to have the board plugged into your computer while also having the resistors attached?
kinda.
Can you elaborate please? I don’t understand what restrictions you’re working within.
if i knew where both my aligators were i could use those
other wise i need double female jumpers
Would something like this help? This is how I tested the code - connected both resistors to the point I connected the voltage measurement jumper wire, so that I only needed one wire.
yes, if i have a usb cable thats long enough
Why do you need a long cable? Can you not set the breadboard where the cable will reach?
cause my usb port is under my desk as the motherboard was not quite ment for the tower i have
Does your drawing tablet have a USB hub in it?
no
okay, so can you set the breadboard on top of your tower once you've wired it?
Maybr
you could have it hanging off the USB port if you really wanted to
alright - hopefully you can find something that will work for you here. I've got to shower and start my workday soon.
oh. i found one
neat
at some point it'd probably be good to go over the code in more detail so you can understand everything it's doing and why
I'm getting the impression it still seems pretty magical to you
which is totally fair, just, if you're going to be working with it, it'd be better if it didn't seem magic
i learn by doing really. the question now is which resistor goes to ground? the unknown one?
the known one
so the 5 k
yes
and i replace the 215 with 5000
in the code as the known resistance value, yes
as you probably also figured out, but I'll mention anyway to be thorough, you'll also need to set the power_out and analog_in pins to be what they actually are for you
and click serial?
yes
50k to 60k
hm, does that match what the resistor codes say?
im actually not sure
can you post a picture of the resistor?
that looks like 100k then
Cause it reached a high of about 100k?
Ok. The next is 240.7. So 2.2 k?
How do you know which way to read it
you hold the gold or silver stripe to the right
Thats orange though
oh is it
hm okay
well, sure, 100k it is
the brown looks just like gold this is confusing
Thes are cheap amazon resistors
so it's... brown, black, black, orange, brown?
Yes
okay! evidently that's 100k, and our measurement backs that up
Yet the next one is at highest 900 ish
Hovers around 400 though
I'm using https://www.eeweb.com/tools/5-band-resistor-calculator/ as the calculator
okay, so the next one you weren't sure between 10k and 2.2k?
yet the measurement is 400?
Brown black black red red
Butin reverse its r, r, bl, bl, br
So, 220 with a 2% varience
hrm
okay so what resistors do you have you're confident in
the 100k seems safe
and then you have a 5k
that's the known one connected to ground right
and then there's one that's either 10k or 220, but measures 400
maybe 5k is too far from 220 to give a reasonably close measurement
do you have one you're confident in that's closer to 220?
No
.what happens with 2 equal ?values
it should measure very precisely in that case
the microcontroller ADC doesn't have a lot of resolution, so when we're having most of the drop over the second resistor, the computed resistance has only a coarsely measured small drop to work with
2 100 ohms
does that make sense? I don't know how much you know around this
that looks like 213k ish to me
Sorry, 2 10 ohms
can you try using the 100k as the known and retesting?
Oh wait. Forgot to update the code
ah, yes, that would be very important
I'm sorry, I don't understand
I should just get new resistors
that might help, ultimately
you could get known values, even!
maybe even a proper multimeter, if it's in the budget
The 2 10 ohms give a readout of 24 to 26 ohms
sorry, which resistors are where for a measurement of 24.0 - 26.0?
I like being able to read it on my pc, jysr dont like how wildly different the reads are
Both resistors are 10ohm resistors
if the second resistor isn't set properly, or the connections are bad, that'll happen
did you set the second resistor to 10 ohms in the code?
Yes
huh. okay then.
that definitely doesn't... if they really are both 10... gruh
yeah agreed it's not a measurement technique that lends much confidence
Ilk just buy new ones
okay
Suvks as i have some but cant use them
yeah
are you up for buying a multimeter? it'd be good to have a proper measurement tool
then you can use them once you know with more confidence what their values are
Might be.
Kinda wish i could build one as i like a vhallenge buy i doubt ill find a diy thats as good as a prebuilt
makes sense
https://www.adafruit.com/product/2034 looks decent and inexpensive
want to choose resistor values and then I gotta go to work?
My meds make me tired and i vant quite focus on iy. Besifes, im happy i got some vode to work
yeah! I'm glad you were able to see the stuff it was printing
that'll be quite useful
that's how I figure out where it's hanging if it's not getting to the part I expected
I kinda want to get a screen for my set up so i dont have to use the pc to read it
would you like recommendations?
For? The screens?
yes
cool! that looks like a sensor to tell when it's opened?
I've been pleased with https://www.adafruit.com/product/4650
A Feather board without ambition is a Feather board without FeatherWings! This is the FeatherWing 128x64 OLED: it adds a gorgeous 128x64 monochrome OLED plus 3 user buttons ...
No, but it could be used that way
it's designed to work very easily with Feather boards, but you don't need a feather board to use it
Its just mounted for easy testing of my current project
as far as resistors - the ideal would be something that cuts maybe 3/4 or so - the battery max of ~4.3v must be at most 3.3
100k and 22k could work for that I think: https://www.adafruit.com/product/2787 and https://www.adafruit.com/product/2785
ΩMG! You're not going to be able to resist these handy resistor packs! Well, axially, they do all of the resisting for you!This is a 25 Pack of 100K Ω Resistors. ...
lemme test that real quick
so a resistor setup that removes 1v so the qt can safely read it. then the qt maths in that volt
well, it has to remove a ratio, not a constant voltage, but yes
I'm wrong about those values though - it's not acting like I thought
sorry, work paged me last night so I'm running on very little sleep
okay 47k works well https://www.adafruit.com/product/2786
its ok. this all can wait
it can, but it's fun, so I don't want it to :p
this split looks good
if you just got 100k it'd work, but 100k / 47k will make max voltage close to the max the board can read, and give you a good chance of getting decent voltage readings
does that make sense?
also the only reason we're going down this road is to avoid needing to shove a lipo battery level reading board into the constrained space inside your blaster, is that right?
yeah
i mean it could fit but id rather not throw yet another board into this and add to the programming requirements
for what it's worth, from my perspective it'd be WAY easier to add a library that just does the thing than try to get general purpose hardware to do it and have to write the code from scratch
but we can certainly try, it's just not the easier option
I gotta go - glad we got the resistance measuring kinda-working! :D
If I can find a decently accurate multimeter board, I am thinking of utilizing your code to make a sonic screwdriver. I can add a few other sensors that can be helpful
More like pop open a compartment and slot in a resistor. The device will have a known value resistor in it so the code wont have to update. The tip would be maybe a ir heat sensor and i may be able to include a few air quiality sonsors and such
Not sure if the resistor part will work well enough but the others may
Plan on using a flexible display hidden behind an expanding head shroud
I kinda want to use brass pipe for a steampunk look
that's an interesting idea
a more conventional input device would be easier to get working reliably
but I'm sure you know that
Id probably be able to fit it in a tricorder better, but i always wanted a working sonic
And yeah
"round" is a tough enclosure to work in
Yeah. I plan on doing alot of stacking so it looks like layers
The issue will be the microvontroller and battery
I can set it up to charge inductively by wrapping the shaft like a tesla coil. In fact, that may be a cool looking sonic
ooh cool
Luckily sparkfire has some air sensors that may be perfect diameters
Im thinking of having the qt py be the controller. Its the right size for it
adafruit has inductor pairs
they wouldn't be suitable for going along the entire length, though
True, but ahain, the shape. I may buy those and harvest the boards and do a rewrap. As long as they are the same number of coils it should be good right?
What i cant remember is which way the second coil goes in relation to the first
I haven't worked with inductive charging; I don't know
Ooh, the feather esp32-s2 has a built-in battery monitor
Great news. My finantial aid appeal was approved and im going back to school. One of the courses im taking this semester is microcontroller programing. Im going to school to learm this stuff
Nice! A formal basis in a topic can be very helpful.
Yeah
Congratulations!
Im also going to be able to afford a better pc now so i can do my classwork better
Before i was worried id have to divert funds from it just to go to school
Yay! If you’d like PC suggestions I’d be happy to help with that as well.
I actually have one designed
I'm using preexisting hard drives, case, and peripheral
Yeah
Oh. I had a sonic idea
In order to get readings off stuff like water level, and ambient heat, hook it up to an rfid writer and add an rfid could into the screwdriver, connected to the qt. The writer writes the rfid chip with the data and the rfid chip sends that to the qt. If I can only find a way to wire it in
I figure the tesla coil toroid, which will be a wire version, should work as an anttena
Ah, so you'll have sensors outside the screwdriver that put their values into RFID tags?
then the screwdriver reads them
Kinda, the tag would be in the screwdriver
The external sensor would write the info to the tag.
Just need a way to wire the tag into the qt
Hm, I wonder if there's a wireless technique better suited to this use case. RFID tags don't seem designed to be written a lot.
What about low-energy bluetooth?
Could use the rfid to trigger a data dump to the sonics memory
Basically same idea for the reader being external
Might even be cheaper and easier to program
Lots of options for sure
All i need for the screwdriver itself is the rfid chip. I can redo the antenna as part of the exterior design
Wont even need to wire it to anything
That would indeed be a perk
And I think I'm gonna go with a stemma device
That way I can use a qt
I like the size of it
yep for sure
it's very convenient to fit in small projects
you found a stemma QT short-range wireless thing?
For the antenna, I'm thinking about wrappin the enameled wire around a thicker wire. Then I can shape the thicker wire
Not yet
good idea for the antenna
hopefully the internal wire doesn't cause interference problems, but it seems like it'd be really easy to shape
Not sure if the thicker wires will interfere, or if the thicker wires can be used as the antenna
I'm not anywhere near enough of an RF engineer to know
annies projects
Hrm, I can get this display only to display its initial buffer contents and nothing else, unless I'm not trying to use it at the same time as another display.
What display
for this IR camera I'm working on
the left one is https://www.adafruit.com/product/1431 and the right one is https://www.adafruit.com/product/4650
We love our black and white monochrome displays but we also like to dabble with some color now and then. Our big 1.5" color OLED displays are perfect when you need a small display with ...
A Feather board without ambition is a Feather board without FeatherWings! This is the FeatherWing 128x64 OLED: it adds a gorgeous 128x64 monochrome OLED plus 3 user buttons ...
Ok. Logic i may be able to help with. How is it that you want it to work
I think it’s a software problem actually. I got it working using both at once with CircuitPython, but not with C.
I’m hoping that the monochrome display can show what mode the camera is in and more detailed statistics on the temperatures. If I can’t get the other display working, maybe I can use one of the buttons to toggle display of the image or of other information on the color display.
If frame rate isn’t actually that important maybe CircuitPython will be sufficient
in all the planning, did we ever figure out which pins to connect to? im thinking vlipo to resisters to a3
actually rx ant sck on the qt py so they are on different pmw slices. otherwise the same on the charger
or should it be vlipo to resistors then resistors to rx and ground?
Looking at the code here https://pad.riseup.net/p/RGB_battery_voltage it was A0-A4.
the resistor pair
voltage divider
i know we gut the voltage divider in specific places for the resistor tester, but not for my design
vlipo to the first resistor. First resistor to both A0 and the second resistor. Second resistor to ground.
If you want to run a diagram by me feel free
looks like i want vbat, not vlipo. vlipo, aslo called vs in the 100c is a shared output. its whatever the highest voltage is basically. it might work to externalize when its plugged in (ie if voltage is >4.2 fill blue,) but it wouldnt really do for power level management. lbo would do good for near dead, (ie, if lbo is tripped fill red) but vbat covers everything except charging
im thinking of removing the onboard leds since they are a redundant redundancy. the switch and the neo is handling what they do
Yep makes sense
i just ealised soething
this is the leds that tell you its chargingand when its done. is there a way to wire them into the qt py instead of the leds, so the qt py will read it and shine the proper colors set in the code? on a custom board of course
maybe wire it into an unused pmw slice? the resistors might need to be changed out for something else to protect the qt py part of the board
to lay out the pwms i have
a0)pwm6b led common
a1)pwm6a red led
a2)pwm5b green led
a3)pwm5a blue led
sda)pwm4a possible charge indicator input
scl)pwm4b possible charge indicator input
tx)pwn2a voltage divider
rx) pwm2b empty
sck)pwm3a possible charge indicator input
mi)pwm2a empty
mo)pwm1b possible charge indicator input
sda1)pwm3a empty
scl1)pwm3b empty
since the qt doesnt pin out every pwm slice, ill be able to play with these on my custom board
Inputs are independent of PWM
That does seem possible, yeah! I guess you’d have to desolder the LEDs; maybe test what voltage they’re at first before plugging them into a board, in case they’re 5v
they are coming directly of a 5v line, then going to the resistor if i read that schematic right, as for desoldering, thats quite a chore for this. since ill be making a board specifically for the blaster, ill be able to go right from the leds and resistor to the qtpy section via traces. the issue i have is if i desolder the leds from my current board, how will i solder it to the qtpy? is there a surface mount header i dont know about? cause that would probably solve it
Headers are a possibility. If you have a through hole you could solder a wire into it; working with headers is likely to require crimping tools.
If it’s coming off the 5v line that’ll require another divider to be safe for the microcontroller.
Couldnt one resistor drop it enough
I don’t know
i mean, if i read the diagram right, the led lights up before the power hits the resistor, so the power returning to the chip may not really matter
so long as its enough for the board to get the heads up
a larger pic may help
i dont think the divider is neccessary here. i think its talking more than it is powering. since its going to the rp 2040, the a0-a3 is powering the leds, and the code is handling the lighting pattern, i think we just need to make the mcp73871 talk quieter
or a buck down, if thats a thing
wait, i saw something while building my stockpile that may help
since we dont need to tell how much charge there is, but rather whether or not its charging, this may be all thats needed
so if i do this, it should lower the mcp73871s voice so it doesnt deafen the rp2040 so to speak
rather this one. surface mount and uses the same one from the qt py
im not sure if i need a cap on the output
should have looked here when i was first wanting to read bat level.
that does simplify things
Oh! Nice.
Did you end up ordering 10K ohm resistors?
yes. i ordered a pack of each resistor type
Cool! Looking forward to that.
question. could a feather do everything i want except boost the battery to 5v>
I expect so, yes. To make sure I understand, what are all the things you want this to do?
And what needs the 5v?
If you’re looking at feathers now, note that you don’t even need the resistor bridge if you are able to use something other than the RP2040. I can check my Cortex M4 feather’s battery level behavior tonight.
well, since i have the rp2040 and may be getting another free pink board with my next order, i may use them. if im no mistaken, i domt need alot of what has been done except the voltage divider as its needed to read battery. as for the 5v, the electro magnet needs it
this all really started because i wanted to be able to shine specific colors for specific battery levels, but needed a micro controller to do it. so i bought a cheap one. since the feather charges batteries and has a micro controller, i should be able to just take the code, modify it a bit, and plop it into the feather since they use the same coding language. the only thing i cant do is properly power the electromagnet
so, i just realised something. if i want the leds in my switch to indicate power level, then i need the voltage divider to go to the micro controller. however, if i switch to a feather, the microcontroller and battery charger are the same board, but ill still need the voltage divider to read the battery level. do i just wire the divider the way im supposed to and output it back to the feather?
This is in response to your question about adding in indicators:
#help-with-projects message
So quick note about the Battery level indicators: Pay Attention to the quiescent current. 1mA idle current will drain your battery so you want it low, like in the xx uA region. Ive used "IC Supervisors" in the past to tell me when the battery is low and that it needs to be charged. I usually have these hooked up to an LED. Really, thats all you need to know is when the battery is low.
APX803S-31SA-7DICT-ND is one I use for single cell lithium batteries. Vth is 3.08V. This one is out of stock, so you have to find something similar. I can provide example circuitry if you need to. Just @ me.
Another suggestion: Use comparators instead of resistors. Again, just pay attention to your ladder current and your quiescent current.
im looking to make this a kit that beginners can assemble with easy to understand circuits. thats part of the reason that the only boards being included (besides the custom one) is the charging board and the 5v amplifier
So that IC is actually just a comparator with a voltage reference and set point. You can build one and it would be a great demonstration of how comparators work, albeit a bit slow since the battery will take a long time to drain on simple circuits
look on page 2
https://www.diodes.com/assets/Datasheets/APX803S.pdf
alos, im placing it into an altoids tin so space is limited
the boars itself is already going to be short about 62 mm because of the battery
Are you putting components on the other side?
I think I know what you are getting at-You want to keep things simple yet functional, but I think (and imho) if you use that IC and tell the beginner what it does (along side giving an equivalent schematic) I think youd be OK
Also I'll post the schematic so you can see how little you actually need
This was going to a Micro, BUT you can control an LED the same way.
I am adding a second switch and a 5v booster as well as a micro lipo charger so i can switch between 5v and 3v. Not sure if i can acomplish that with a power boost as i burnt out some thing on mine somehow (wont read battery)
Another reason i wanted the resistor based is to have a kind of graph
You mean something to read from?
Though i was thinking of switching to surface mout
No, just a line of color
Yes
actually
If you go that route, you dont need that supervisor circuit
Because the lowest LED will be your "low battery" LED
(so 3.00V)
I placed one in this controll box i built. Cant open it as the various switches and pots kinda lock it shut (that was a pian to do)
That looks pretty good!
This one just plugs into a breadboard
Just supplying power?
You have a microswitch, a toggle on the side, a 10k logarithmic and a 10k linear, and the battery indicator
Unfortunately the tin isnt big enough for a battery to be added
So if you had a bigger enclosure, it would fit?
This one would be.
Curiosity question: Are you doing this as a challenge to get it to fit?
Or thats what you have on hand?
I got this just to have it incase i need it, but have no use for it yet
👍
I had an actuall altoids tin that i originally used, love metal and tactile. The control box was to be able to have each of the items on hand instead of having to grab one from storage, the indicator in that came about because i had room
(brb a moment have to check bread)
Me trying to ad the 5v switch and the inficator is because i want to sell to beginners to get them used to some of the most basic components
Kk
I even designed a label for the bat pack
I may do the surface mount version for people who are not beginners, but are getting into soldering surface mount components
If you make the pads big enough SOT23 isnt hard to solder with a iron. Tack one pin and put into place.
Very well done!
Thats why I think comparator is the way to go. I dont think you can do what you want to do with resistors alone. You need to "compare" it against something-A reference.
The indicator is fairly easy to make, just dont know where to place it in the over all circuit
Reguardless of resistor or comparator
https://www.instructables.com/Li-Ion-battery-level-indicator/
This is a good one. Simple. But I wouldnt use LED1 as a reference. I would use an actual reference. You may need to recalculate the resistors though.
Whats your overall circuit look like so far?
If you want to share.
Thats what im trying to figure out. Let me see if i can scematic my idea. Can correct mistakes after the idea is out there
Draw up a block diagram even
Im gonna use the resistors for now as i know how to draw that
On libreoffice
(or pen and paper-no shame in that)
Feel free to tag me or DM me if you need help. I'll try the best I can to get you to where you need to be 🙂
Ok so you want to use those LEDs on the left to indicate battery voltage, right?
yes
this is very rough and probably needs cleanup and correction. i hope its easy to understand
Yes but it wont work. As soon as your battery comes in, all those LEDs will turn on
(Resistors were randomly made up)
its the same circuit as is in my control box. you may be right. it worked when i tested it with a potentiometer, but im not sure if its working now
of course my battery may just not be low enough for it to really read it
Thats also possible but to get true level reading you will need a comparator. You were probably varying the voltage to the LEDs and because LEDs have a forward current, you were seeing them come on once that threshold was crossed
(if I had to guess)
Maybe
I may have drawn it wrong too
gthis is what i was aiming for
yeah, i drew it wrong
it sort of works But that last LED wont light since its a blue LED
and at 3V
Yea, I can only get it to work with 2 LEDs
from an earlier try at getting help: i want to have purple, red, yellow, chartruce (or similar), and green. maybe pink as some sort of indicator for a blown battery. not sure how to do that. maybe a stretch band that lights the pink when it deforms or something. or is there an easier way?
i found an easier way to indicate a blown battery
a wire taped to the top of the battery and one kept at a slight distance. if the bat blows, it will lift the wire and complete the connection
Blown battery? Meaning 0V?
Hmmm I think you would know since the battery most likely has a internal circuit
now you are getting into mech design and..you have to know how much the battery will puff up in order to design something
i have experience with phone batteries blowing and still working, not much else where
It would have to also be sensitive enough to rule out false positives-ie knocked around.
i figure a couple mm will be enough
IMHO I dont think that matters that much. A visual inspection should be good enough.
After all, the first think I do if I short out a battery is check to see if its warm or if it puffed up. I put it outside to be sure
and id be using a sheets of metal as the floating wire, so i would use stand offs mounted to the main board to keep its distance and it will be stiff, should eliminate accidental touch. stich some copper tape on the battery instead of bare wire
might use a coin cell battery to power the blown battery indicator. thin, and powerful enought to drive a single led
but now you are also introducing other points of failure and things that take up space
I would use a PTC type resistor to limit current
OR theres a battery protection circuit from Ti
You wont have to worry too much about that if you do those things
yes. the space isnt an issue in this area as there is room enough not the indicator circuit, but not for switches and pots and such
i could technically fit 2 btteries stacked in here
hmmm so I get why you want to do this, but consider this: is it really that much of an issue for someone? I mean think of the audience you are targeting for this. They most likely know about lithium batteries to begin with. Also if you've ever taken apart a power bank, they dont have such things inside of them either.
not trying to dissuade you though.
What they do have IS protection circuits so you cant draw a lot of current-1A should be enough. Infact, you can probably use a pot with the protection circuit so the user can adjust the current limit
i know you are not. the puff indicator is because i had phone bats do that and wish they had an indicator for it. i used a blown battery for a month before i realized
wait a minute. a pot to control power? so throw out the second switch, remove the 2 indicators and replace it with a pot. have the power booster output 5v to the pot, and the user can dial in the rigt power
So the problem is, like I said, good idea but you have to make sure your dimensions for the battery are consistent within a few 0.1mm or else you get too much variance
Well What I was getting at is this: Using one of the TI protection circuits, you can vary your current limit
Hold on, looking it up now
then wire in the level indicator with either the comarator or the resistors
not too much of an issue. my background is machining so presision is already something i have
ahh then you would appreciate the project I posted in show -n- tell 😉
ah threads. hated those
scroll down more 🙂 Current one
I should post the finished product though. It came out good
Also still looking for that circuit I talked about
https://www.ti.com/product/TPS2596
Something like this
TI’s TPS2596 is a 2.7-V to 19-V, 85mΩ, 0.13-2A eFuse with selectable over voltage protection clamp in leaded package. Find parameters, ordering and quality information
It might be too advanced for a beginner
but it will basically limit current
i started out with simple components. ics and microcontrollers were beyond me
So you can only have two LEDs max. The others wont light up. If you use Kirchhoff's voltage law, you'll see that the LED voltages add up to greater than 4.2V. Thats what happened when I simulated it
Thats ok! You're learning!
Semi-afk
You’ve gone over my head as well, but that’s how learning happens :)
im using 100ohm resistors
lowest i can get from adafruit
for some reason, i cant even get 3 leds to light up in series
i ran into an issue. with a 10k pot, i only get a .01v difference
Do you know of Kirchoffs voltage law? If you add up 3 LEDs + their current limiting resistors, you'll find that its greater than 4.2V