#annies projects

1 messages · Page 1 of 1 (latest)

nova ingot
#

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

keen nacelle
#

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

nova ingot
#

@keen nacelleyou said you may be able to help with programming right?

keen nacelle
#

Yes; I’m off work in ~2 hours

nova ingot
#

kk. i can wait 🙂

keen nacelle
#

@nova ingot I’m available for the next few hours. What’s your timing? And what have you done so far?

nova ingot
#

nothing. i cant figure out how to access the qt py

keen nacelle
#

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

nova ingot
#

thanks for pinging. im simplifying my board and dont have general notifications on

#

nothing happens

keen nacelle
#

No lights on the board? No connection chime on the computer?

#

How quickly are you double clicking the button?

nova ingot
#

lights yes, no computer reaction

keen nacelle
#

Ooh lights that’s not nothing

nova ingot
#

might be a power only cable

keen nacelle
#

Seems quite likely

#

Do you have one you’re sure supports data?

nova ingot
#

should soon

keen nacelle
#

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?

nova ingot
#

Yes

#

Going to take a bit. My pc reset on my

nova ingot
#

yeah, not working at all

keen nacelle
#

Okay. Well once you get a USB C cable that can handle data we can try this again.

nova ingot
#

im trying to rewrite your code a bit and dont know how to do something

keen nacelle
#

Can you be more specific?

keen nacelle
#

What are you trying to do?

nova ingot
#

im trying to expand the if thens but dont know how to alter it to make it work

nova ingot
#

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

keen nacelle
#

I don't know how to define percentage

#

oops, didn't see this

#

@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
keen nacelle
#

@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?

nova ingot
#

i dont know. i was thinking of just using the program code from the fuel guage board

keen nacelle
#

That gave percentages?

#

I didn't notice

#

Oh you mean from the board I linked?

nova ingot
#

im not 100 % sure. coding isnt in my wheelhouse yet

keen nacelle
#

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?

nova ingot
#

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

keen nacelle
#

I forget what code I supplied

#

can you paste it here please?

nova ingot
keen nacelle
#

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

nova ingot
#

the closest i have to programing is using rpg maker to make games

keen nacelle
#

unlike else, elif needs a condition

nova ingot
#

i cal them if then else statement chains

keen nacelle
#

yep exactly

#

okay so let's say... 3.5v is a cutoff for orange

nova ingot
#

i can write those. its the numbers that excape me

keen nacelle
#

let's stare at this graph together then

#

so currently red is < 3.2

nova ingot
#

so the discharge capacity is kinda reversed.100% is 100% dead

keen nacelle
#

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

nova ingot
#

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

keen nacelle
#

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?

nova ingot
#

it says 3.7 on the batery

keen nacelle
#

alright

#

so uh there's a YELLOW, but there's no orange

#

are you familiar with color pickers?

nova ingot
#

like in paint?

#

and there is an orange

keen nacelle
#

oh

nova ingot
#

oh. in the program you sent

keen nacelle
#

I guess you added on then, yeah

nova ingot
#

ok, i read that wrong

keen nacelle
#

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

nova ingot
#

whitespace?

keen nacelle
#

spaces and tabs

#

characters that render as empty space

nova ingot
#

oh, yeah i can

keen nacelle
#

I'm pretty sure 3.0v is the outright minimum, so your board would likely be dead before it displays red with these thresholds

nova ingot
#

ok, so 3.7 is full and 3 is dead

keen nacelle
#

I believe so, yes

nova ingot
#

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

keen nacelle
#

what

#

where's orange defined?

#

also things are case-sensitive so yellow should be YELLOW

nova ingot
#

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()

keen nacelle
#

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?

nova ingot
#

NOTEPAD++

keen nacelle
#

it'll make it easier to test things

#

there's a "serial" button where you can run code directly on the microcontroller

nova ingot
#

i dont have the microcontroller hooked up

keen nacelle
#

still waiting on a cable?

nova ingot
#

waiting on a pc. mine dont have 3.0 usbs

keen nacelle
#

you don't need USB 3.0

nova ingot
#

ill try again then

keen nacelle
#

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

nova ingot
#

ok

keen nacelle
#

one moment working on a change

#

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?

nova ingot
#

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

keen nacelle
#

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

nova ingot
#

thats what python shell is saying too

keen nacelle
#

ah, you're pasting from your code, not the one I gave you

#

I mean the first code I gave you

nova ingot
#

yeah. im doing yours in a sec

keen nacelle
#

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

nova ingot
#

fixed indents at least

#

fixed first syntax issue

keen nacelle
#

elif voltage 3.2-3.3 is not valid Python

nova ingot
keen nacelle
#

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 #

nova ingot
keen nacelle
#

so after led.fill(GREEN) you can put # and it'll ignore the comment

nova ingot
#

ok, except for the comment issue, it says it understands it

keen nacelle
#

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

nova ingot
#

i already fixed it on my end

keen nacelle
#

cool!

nova ingot
#

seeems that was the last problem

keen nacelle
#

yay

#

I've got to go pick up my car; hopefully we can make more progress another day :)

#

bye for now

nova ingot
#

i finally got the qt to resister in my pc

nova ingot
#

Now i just need to figure out how to upload the code. Tomorrow i think

full dune
#

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.

keen nacelle
#

Ah, so it’s dead before it gets disconnected? The article does say that, now that you mention it. Thanks!

keen nacelle
keen nacelle
#

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.

nova ingot
#

Yes. I held boot while plugging it in.

#

Ill probably have to upgrade the memory on my custom board then

keen nacelle
#

Oh! I didn't realize that did anything.

#

I thought only double-clicking reset did anything.

full dune
#

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.

keen nacelle
#

The QT PY only exposes the reset button, though.

full dune
#

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>

keen nacelle
#

Oh! I… it sure did. You’re right! I was wrong about which board is in use here.

full dune
#

Sorry to have jumped in with irrelevant information....

keen nacelle
#

@nova ingot I’m wrong - if you’re using a QT PY RP2040, you have plenty of RAM.

keen nacelle
full dune
#

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.

nova ingot
#

It is the rp2040

nova ingot
#

btw does the leds blink with this code or shine solid

#

and how do i get it to effect off board leds?

nova ingot
full dune
nova ingot
#

@keen nacelle is there a but statement? ie if voltage is < 3.9 but > 3.7 then return orange

nova ingot
full dune
#

AND might work <3.9 and > 3.7

full dune
keen nacelle
#

@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

nova ingot
#

ok. so how do i make this work on an off board led

keen nacelle
#

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?

nova ingot
#

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

keen nacelle
#

okay

#

do you have the LEDs connected?

nova ingot
#

not yet

keen nacelle
#

do you need help figuring out how to do that?

nova ingot
#

Maybe, unless its just soldering the led wires to a0-a3

keen nacelle
#

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

nova ingot
#

Not currently. Not able to get to my desk, though i beleve c is the common on it

keen nacelle
#

yep - it's a common anode, so that connects to the USB pin

nova ingot
#

I didnt read your followups before answering

keen nacelle
#

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

nova ingot
#

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

keen nacelle
#

what do you mean?

#

are you talking about PWM slices?

nova ingot
#

And i may need to get some diy female header parts as i cant perminately wire it up.

nova ingot
keen nacelle
keen nacelle
#

You can use a breadboard to avoid soldering LED lines to it

nova ingot
#

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

keen nacelle
#

correct

#

I didn't realize you were talking about ordering

nova ingot
#

Sorry if i am hard to understand. I understand things by equating. I learned how to play magic by drawing paralells to yugioh

keen nacelle
#

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.
nova ingot
#

So if i wire red and green to 1 and 3, then blue has to go to either 0 or 2

keen nacelle
#

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)

nova ingot
#

Ah. So its kinda like a trafic light, left cant go if you are driving forward

keen nacelle
#

sure

nova ingot
#

So, how do i getthe third color in there?

keen nacelle
#

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

nova ingot
#

So, if i pic a0, id have to go with any pwn6 pin, so miso may work? Or did i get that wrong somewhere

keen nacelle
#

Once you pick a PWM6 pin, you cannot use the other PWM6 pin for PWM.

#

MISO would work too, yes

#

because it is PWM2

nova ingot
#

OH! SO I CAN DO A PMW2, 5, AND 6

keen nacelle
#

yes!

nova ingot
#

but i cant do 2 pmw5 and a 6

keen nacelle
#

correct

nova ingot
#

Ok. Slight rework to my custom board design but nothing to extranuous

keen nacelle
#

aw crap I'm wrong

#

sigh. I've taught you incorrectly

#

how about we both read this documentation carefully?

nova ingot
#

Ok, so i need to look at the data sheet or the schematic and find out whish pins are which pmws

keen nacelle
#

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.

nova ingot
#

So, each pwm has 2 outputs? If using one shuts down the other then why

keen nacelle
#

no, I was wrong about that

#

you can use a0-a2 like you wanted to originally

nova ingot
#

Ok, so the a0 through a3 pins. I misunderstood

keen nacelle
#

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?

nova ingot
#

I know, i mean to say i can use any of the 4

keen nacelle
#

ah, gotcha

nova ingot
#

Any 3 of the 4

keen nacelle
#

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?

nova ingot
#

yes, just not in use

#

i understand the meaning but lack the language

#

btw, where is it reading the power level from?

keen nacelle
#

oh!

#

that depends on where you've connected it to read the power level

nova ingot
#

i think through various helpers we came up with bat to a0

keen nacelle
#

the thing we're doing here is to read the voltage of the battery itself as an analog value

nova ingot
keen nacelle
#

so, yes, if the battery is connected to a0, it'll use that to read battery voltage

nova ingot
#

so analog_in = AnalogIn(board.A0)

keen nacelle
#

provided the appropriate imports before that line, yes

nova ingot
#

import time
import board
import neopixel
from analogio import AnalogIn

keen nacelle
#

yep that'll do it

nova ingot
#

and the neopixel needs to be changed

#

so import analogout?

keen nacelle
#

those imports you gave are already correct

#

er oh

#

wait what

nova ingot
#

except om not using the neopixel, at least not primarily as its hidden inside a casing

keen nacelle
#

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

nova ingot
#

ok, so the neopixel will show what is supposed to happen in case the rgb switch isnt working

keen nacelle
#

yep! I think that'd be helpful

nova ingot
#

so leave the code we established for the neo

keen nacelle
#

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

nova ingot
#

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()

keen nacelle
#

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

nova ingot
#

using voltage_to_color?

keen nacelle
#

yeah

nova ingot
#

so all i need is to update the rgb values and the if thens

keen nacelle
#

yep

nova ingot
#

ok. updated the if thens

#

i plugged it into python shell and its saying undefined name led

keen nacelle
#

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?

nova ingot
#

no

#

give me one second. i gave to fish out my switch

#

green is c

#

from there each wire is: d, ground, +, b, a

keen nacelle
#

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

nova ingot
#

i need to test them real quick

keen nacelle
#

okay

#

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?

nova ingot
#

yes, but bat is essentially direct power from the battery, not the board, so isnt that like 3.7?

keen nacelle
#

usually, yes, and up to 4.2. either way, it's more than 3.3v, so it can't be put as an input

nova ingot
#

so vlipo wont work either as its both 5v and vbat

keen nacelle
#

what's vlipo?

nova ingot
#

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

keen nacelle
#

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

nova ingot
#

yeah, fritzing dont have 1000c

keen nacelle
#

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

nova ingot
#

is there something else that can safely read the voltage and tell the qt what the number is? something small, like a component?

keen nacelle
#

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?

#

it describes voltage dividers

nova ingot
keen nacelle
#

I see

#

well, that's the component-sized solution I can think of

nova ingot
#

ok, so d is blue,b b is green, and a is red

#

can we get it to read from the usb somehow

keen nacelle
#

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

nova ingot
#

so when the qt reads 2 its actually 4

keen nacelle
#

yep

#

the higher resistance resistors you can find, the less power it'll eat

nova ingot
#

so if i get a resistor set that divides by 4, 1 would be as 4 and 2 would be as 8

keen nacelle
#

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

nova ingot
#

My new iron cleaner 😜

keen nacelle
#

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

nova ingot
#

its just a printed salt shaker that my mind went "needs brains"

keen nacelle
#

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

nova ingot
#

yeah. we can do it tomorrow

keen nacelle
#

okay!

nova ingot
#

i need to get my boards ready on the breadboard

keen nacelle
#

it looks like you're using a permaproto board

#

are you aware that prototyping breadboards exist?

#

they don't require soldering

nova ingot
#

yes

#

I used the protoboard to make an energency light using the 1000cs onboard blue light

keen nacelle
#

alrighty

nova ingot
#

and to stablize my battery. the stock wires broke

keen nacelle
#

oh wow

#

that's not fun

nova ingot
#

i wasnt exatly carefull and it was stranded wire

nova ingot
keen nacelle
#

Aah, I see why you didn't want to deal with another board taking up space.

nova ingot
#

in all fairness, this wasnt the final project

keen nacelle
#

do you know if that battery has protection circuitry? It looks like it might be a raw cell

nova ingot
#

here is the boards compared to the project

keen nacelle
#

ooh! cool!

#

Blender is one software package I have continually failed to understand

nova ingot
keen nacelle
#

I do, yes

#

so... good :)

nova ingot
keen nacelle
#

please do! :)

nova ingot
keen nacelle
#

it's an addon to oculus quest 2 controllers?

nova ingot
#

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

keen nacelle
#

this interacts with the game??? wild

#

I didn't realize RE4 had VR support

nova ingot
#

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

keen nacelle
#

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 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

nova ingot
#

i kinda can play horror, when im able to mentally handle it

keen nacelle
#

have you tried RE5?

#

I've seen playthroughs and it looks horrific, which for horror folks I think is good?

nova ingot
#

i have all of them

#

they all are good but the pov ones are more triggering

nova ingot
#

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

keen nacelle
#

yay

#

thank you for not getting mad when I realize I'm wrong

nova ingot
#

its all good, thats why im not going right into wiring everything then programing

keen nacelle
#

especially not when you're soldering it all, yeah

nova ingot
#

besides, your mistakes teach me too

keen nacelle
#

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

nova ingot
#

on the voltage divider a 9 ohm and a 3 ohm should yield about 1.05 v yes?

keen nacelle
#

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

nova ingot
#

yes, 4.2

keen nacelle
#

You have 9 and 3 ohm resistors? Those values seem really low. Or are those just example values?

nova ingot
#

examles i suppose. i figure that a 1:3 ratio should divide by 4

nova ingot
#

how about 10 and 30

keen nacelle
#

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.

nova ingot
#

sorry, original number was 3k to9k

keen nacelle
#

oh that makes so much more sense. yes.

#

that'll work

nova ingot
#

i did find some resistors but i dont know what they are yet

keen nacelle
#

oh neat I can paste math formulas from wikipedia

#

note that this means the smaller resistor goes second

nova ingot
#

its either a 330 ohm or 100k

keen nacelle
#

330...k? or 330?

nova ingot
#

330

keen nacelle
#

330 / (330 + 100000) = hmmm

nova ingot
#

i have a few loose that i have to identify

keen nacelle
#

oh good

nova ingot
#

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

keen nacelle
#

the markings are ambiguous?

#

hmm... maybe we can use the QT PY RP2040 to measure the resistance

nova ingot
#

yeah, i don know which way they are supposed to be read unless they are silver or gold

keen nacelle
#

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

nova ingot
#

no. that was the only one i had labeled

keen nacelle
#

un ambiguous? like, not ambiguous.

nova ingot
#

oh sorry

keen nacelle
#

no worries

nova ingot
#

I found a calc, but it didnt really solve anything beyond the 1s and the 10s

keen nacelle
#

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

nova ingot
#

Sure

keen nacelle
#

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?

nova ingot
#

Yes and no, i know of it but keep forgetting it

keen nacelle
#

k same

#

am I making sense so far?

nova ingot
#

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

keen nacelle
#

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?

nova ingot
#

1I think so

keen nacelle
#

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

nova ingot
#

Ok. Ill look it all over. Right now i think i need a nap

keen nacelle
#

alrighty. I'll finish up this circuitpython for measuring

keen nacelle
#

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()
nova ingot
#

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

nova ingot
#
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

keen nacelle
#

No way of reading… the resistance?

#

That’s not something we need to integrate with the RGB button stuff

full dune
#

you have some duplicated code.

keen nacelle
#

If you click monitor in Mu Editor it’ll show you the things it’s printing @nova ingot

full dune
#

def main led = .... analog_in gets redefined ???

keen nacelle
#

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.

full dune
#

there are also 2 while True: loops -- you will never exit the first one

keen nacelle
#

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

nova ingot
#

i dont have a way of seeing the values

keen nacelle
#

You do - you just don’t know it yet

#

While the board is plugged into your computer, click the Monitor button in Mu Editor

nova ingot
#

so i just use jump wires to connect the resistors and use my computer in place of a dedicated screen

keen nacelle
#

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

nova ingot
#

true, i just dont really know if i have a cable thats long enough. need to look

keen nacelle
#

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

nova ingot
#
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

full dune
#

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

keen nacelle
#

Good point

nova ingot
#

yeah. i know

#

the resistor codes give me 2 possible values, so, assuming the code is accurate, i know the potential values

keen nacelle
#

I don’t think this will accomplish what you’re planning

nova ingot
#

is there a way to rewrite it to have some leeway for tollerance

keen nacelle
#

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?

nova ingot
#

kinda.

keen nacelle
#

Can you elaborate please? I don’t understand what restrictions you’re working within.

nova ingot
#

if i knew where both my aligators were i could use those

#

other wise i need double female jumpers

keen nacelle
#

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.

nova ingot
#

yes, if i have a usb cable thats long enough

keen nacelle
#

Why do you need a long cable? Can you not set the breadboard where the cable will reach?

nova ingot
#

cause my usb port is under my desk as the motherboard was not quite ment for the tower i have

keen nacelle
#

Does your drawing tablet have a USB hub in it?

nova ingot
#

no

keen nacelle
#

okay, so can you set the breadboard on top of your tower once you've wired it?

nova ingot
#

Maybr

keen nacelle
#

you could have it hanging off the USB port if you really wanted to

nova ingot
keen nacelle
#

alright - hopefully you can find something that will work for you here. I've got to shower and start my workday soon.

nova ingot
#

oh. i found one

keen nacelle
#

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

nova ingot
#

i learn by doing really. the question now is which resistor goes to ground? the unknown one?

keen nacelle
#

the known one

nova ingot
#

so the 5 k

keen nacelle
#

yes

nova ingot
#

and i replace the 215 with 5000

keen nacelle
#

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

nova ingot
#

and click serial?

keen nacelle
#

yes

nova ingot
#

50k to 60k

keen nacelle
#

hm, does that match what the resistor codes say?

nova ingot
#

im actually not sure

keen nacelle
#

can you post a picture of the resistor?

nova ingot
#

it has tape on it

keen nacelle
#

that looks like 100k then

nova ingot
nova ingot
keen nacelle
#

yeah

#

if it's between 100k and 130, then it's 100k

nova ingot
#

Ok. The next is 240.7. So 2.2 k?

keen nacelle
#

maybe?

#

when I use this calculator on the picture you posted I get 100 Ohms

nova ingot
#

How do you know which way to read it

keen nacelle
#

you hold the gold or silver stripe to the right

nova ingot
#

Thats orange though

keen nacelle
#

oh is it

#

hm okay

#

well, sure, 100k it is

#

the brown looks just like gold this is confusing

nova ingot
#

Thes are cheap amazon resistors

keen nacelle
#

so it's... brown, black, black, orange, brown?

nova ingot
#

Yes

keen nacelle
#

okay! evidently that's 100k, and our measurement backs that up

nova ingot
#

Yet the next one is at highest 900 ish

keen nacelle
#

what are the colors on that one

nova ingot
#

Hovers around 400 though

keen nacelle
#

okay, so the next one you weren't sure between 10k and 2.2k?

#

yet the measurement is 400?

nova ingot
#

Brown black black red red

keen nacelle
#

that claims to be 10k

#

but from what we can measure it isn't

nova ingot
#

Butin reverse its r, r, bl, bl, br

keen nacelle
#

oh brain error my bad

#

that is indeed ambiguous

nova ingot
#

So, 220 with a 2% varience

keen nacelle
#

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?

nova ingot
#

No

keen nacelle
#

okay

#

let's call it 220 then

#

this method is quite coarse

nova ingot
#

.what happens with 2 equal ?values

keen nacelle
#

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

nova ingot
#

2 100 ohms

keen nacelle
#

does that make sense? I don't know how much you know around this

#

that looks like 213k ish to me

nova ingot
#

Sorry, 2 10 ohms

keen nacelle
#

can you try using the 100k as the known and retesting?

nova ingot
#

Oh wait. Forgot to update the code

keen nacelle
#

ah, yes, that would be very important

nova ingot
#

The 10s hover around 25 with a 1.2 variance

#

So thats a 25, not a 10

keen nacelle
#

I'm sorry, I don't understand

nova ingot
#

I should just get new resistors

keen nacelle
#

that might help, ultimately

#

you could get known values, even!

#

maybe even a proper multimeter, if it's in the budget

nova ingot
#

The 2 10 ohms give a readout of 24 to 26 ohms

keen nacelle
#

sorry, which resistors are where for a measurement of 24.0 - 26.0?

nova ingot
#

I like being able to read it on my pc, jysr dont like how wildly different the reads are

#

Both resistors are 10ohm resistors

keen nacelle
#

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?

nova ingot
#

Yes

keen nacelle
#

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

nova ingot
#

Ilk just buy new ones

keen nacelle
#

okay

nova ingot
#

Suvks as i have some but cant use them

keen nacelle
#

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

nova ingot
#

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

keen nacelle
#

makes sense

#

want to choose resistor values and then I gotta go to work?

nova ingot
#

I may be able to get that

#

Im done testing these today

keen nacelle
#

oh sure

#

I meant choosing values to get if you're buying more

nova ingot
#

My meds make me tired and i vant quite focus on iy. Besifes, im happy i got some vode to work

keen nacelle
#

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

nova ingot
#

I kinda want to get a screen for my set up so i dont have to use the pc to read it

keen nacelle
#

would you like recommendations?

nova ingot
#

For? The screens?

keen nacelle
#

yes

nova ingot
#

This is my current enclosure and sure id love some recomendations

keen nacelle
#

cool! that looks like a sensor to tell when it's opened?

nova ingot
#

No, but it could be used that way

keen nacelle
#

it's designed to work very easily with Feather boards, but you don't need a feather board to use it

nova ingot
#

Its just mounted for easy testing of my current project

keen nacelle
#

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

#
#

lemme test that real quick

nova ingot
#

so a resistor setup that removes 1v so the qt can safely read it. then the qt maths in that volt

keen nacelle
#

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

nova ingot
#

its ok. this all can wait

keen nacelle
#

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?

nova ingot
#

yeah

#

i mean it could fit but id rather not throw yet another board into this and add to the programming requirements

keen nacelle
#

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

nova ingot
#

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

keen nacelle
#

what, tap it on things and get a rough resistance measurement?

#

that'd be neat

nova ingot
#

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

keen nacelle
#

that's an interesting idea

#

a more conventional input device would be easier to get working reliably

#

but I'm sure you know that

nova ingot
#

Id probably be able to fit it in a tricorder better, but i always wanted a working sonic

#

And yeah

keen nacelle
#

"round" is a tough enclosure to work in

nova ingot
#

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

keen nacelle
#

ooh cool

nova ingot
#

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

keen nacelle
#

adafruit has inductor pairs

#

they wouldn't be suitable for going along the entire length, though

nova ingot
#

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

keen nacelle
#

I haven't worked with inductive charging; I don't know

keen nacelle
#

Ooh, the feather esp32-s2 has a built-in battery monitor

nova ingot
#

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

keen nacelle
#

Nice! A formal basis in a topic can be very helpful.

nova ingot
#

Yeah

keen nacelle
#

Congratulations!

nova ingot
#

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

keen nacelle
#

Yay! If you’d like PC suggestions I’d be happy to help with that as well.

nova ingot
#

I actually have one designed

#

I'm using preexisting hard drives, case, and peripheral

keen nacelle
#

Very nice!

#

Graphics cards sure are painful right now

nova ingot
#

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

keen nacelle
#

then the screwdriver reads them

nova ingot
#

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

keen nacelle
#

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?

nova ingot
#

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

keen nacelle
#

Lots of options for sure

nova ingot
#

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

keen nacelle
#

That would indeed be a perk

nova ingot
#

And I think I'm gonna go with a stemma device

#

That way I can use a qt

#

I like the size of it

keen nacelle
#

yep for sure

#

it's very convenient to fit in small projects

#

you found a stemma QT short-range wireless thing?

nova ingot
#

For the antenna, I'm thinking about wrappin the enameled wire around a thicker wire. Then I can shape the thicker wire

keen nacelle
#

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

nova ingot
#

Not sure if the thicker wires will interfere, or if the thicker wires can be used as the antenna

keen nacelle
#

I'm not anywhere near enough of an RF engineer to know

nova ingot
#

annies projects

keen nacelle
#

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.

nova ingot
#

What display

keen nacelle
#

for this IR camera I'm working on

#
nova ingot
#

Ok. Logic i may be able to help with. How is it that you want it to work

keen nacelle
#

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.

keen nacelle
#

If frame rate isn’t actually that important maybe CircuitPython will be sufficient

nova ingot
#

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?

keen nacelle
nova ingot
#

the resistor pair

#

voltage divider

#

i know we gut the voltage divider in specific places for the resistor tester, but not for my design

keen nacelle
#

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

nova ingot
#

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

nova ingot
#

im thinking of removing the onboard leds since they are a redundant redundancy. the switch and the neo is handling what they do

keen nacelle
#

Yep makes sense

nova ingot
#

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

keen nacelle
#

Inputs are independent of PWM

keen nacelle
nova ingot
#

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

keen nacelle
#

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.

nova ingot
#

Couldnt one resistor drop it enough

keen nacelle
#

I don’t know

nova ingot
#

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

nova ingot
#

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

nova ingot
#

should have looked here when i was first wanting to read bat level.

keen nacelle
#

oh, we don't need battery level?

#

alright

keen nacelle
#

that does simplify things

nova ingot
#

no, we do. there was a link in there, or at lease there was supposed to be

keen nacelle
#

Oh! Nice.

keen nacelle
#

Did you end up ordering 10K ohm resistors?

nova ingot
#

yes. i ordered a pack of each resistor type

keen nacelle
#

Cool! Looking forward to that.

nova ingot
#

question. could a feather do everything i want except boost the battery to 5v>

keen nacelle
#

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.

nova ingot
#

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

nova ingot
#

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?

keen epoch
#

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.

nova ingot
#

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

keen epoch
#

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

nova ingot
keen epoch
#

(the oscillator is only present to give a delay time)

#

Interesting

nova ingot
#

the boars itself is already going to be short about 62 mm because of the battery

keen epoch
#

Are you putting components on the other side?

nova ingot
#

Tgis is the original prototype.

keen epoch
#

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.

nova ingot
#

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)

keen epoch
#

Space wise its U4/R10

#

R10 is a 1206 resistor

#

You can cram it tighter if you want

nova ingot
#

Another reason i wanted the resistor based is to have a kind of graph

keen epoch
#

You mean something to read from?

nova ingot
#

Though i was thinking of switching to surface mout

keen epoch
#

Like hook it up to an arduino?

#

Hmmmm

nova ingot
keen epoch
#

Or do you mean:
LED 1=3V
LED 2=3.3
LED 3=3.6
Etc

#

Quad Comparator is the way.

#

Wait

nova ingot
#

Yes

keen epoch
#

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)

nova ingot
#

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)

keen epoch
#

That looks pretty good!

nova ingot
#

This one just plugs into a breadboard

keen epoch
#

Just supplying power?

nova ingot
#

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

keen epoch
#

So if you had a bigger enclosure, it would fit?

nova ingot
#

This one would be.

keen epoch
#

Curiosity question: Are you doing this as a challenge to get it to fit?

#

Or thats what you have on hand?

nova ingot
#

I got this just to have it incase i need it, but have no use for it yet

keen epoch
#

👍

nova ingot
keen epoch
#

(brb a moment have to check bread)

nova ingot
#

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

keen epoch
#

If you make the pads big enough SOT23 isnt hard to solder with a iron. Tack one pin and put into place.

keen epoch
keen epoch
nova ingot
#

The indicator is fairly easy to make, just dont know where to place it in the over all circuit

#

Reguardless of resistor or comparator

keen epoch
#

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.

Instructables

Li - Ion Battery Level Indicator: Are you looking for a simple circuit to measure your Lithium Ion single cell charging and discharging level? Here is one chip circuit, powered up from the same Lithium Ion battery you want to measure.This circuit is design to measure 3.7V rechargeab…

keen epoch
#

If you want to share.

nova ingot
#

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

keen epoch
#

Draw up a block diagram even

nova ingot
#

Im gonna use the resistors for now as i know how to draw that

keen epoch
#

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 🙂

nova ingot
#

@keen epoch

#

the center and right are the schematics for the 2 premade boards

keen epoch
#

Ok so you want to use those LEDs on the left to indicate battery voltage, right?

nova ingot
#

yes

#

this is very rough and probably needs cleanup and correction. i hope its easy to understand

keen epoch
#

Yes but it wont work. As soon as your battery comes in, all those LEDs will turn on

#

(Resistors were randomly made up)

nova ingot
#

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

keen epoch
#

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)

nova ingot
#

Maybe

#

I may have drawn it wrong too

#

gthis is what i was aiming for

#

yeah, i drew it wrong

keen epoch
#

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

nova ingot
#

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

keen epoch
#

Blown battery? Meaning 0V?

nova ingot
#

meaning the battery got thicker.

#

i find they still work, but i dont trust them

keen epoch
#

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

nova ingot
#

i have experience with phone batteries blowing and still working, not much else where

keen epoch
#

It would have to also be sensitive enough to rule out false positives-ie knocked around.

nova ingot
#

i figure a couple mm will be enough

keen epoch
#

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

nova ingot
#

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

keen epoch
#

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

nova ingot
#

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

keen epoch
#

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

nova ingot
#

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

keen epoch
#

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

keen epoch
#

Hold on, looking it up now

nova ingot
#

then wire in the level indicator with either the comarator or the resistors

nova ingot
keen epoch
nova ingot
#

ah threads. hated those

keen epoch
#

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

nova ingot
keen epoch
#

It might be too advanced for a beginner

#

but it will basically limit current

nova ingot
#

i started out with simple components. ics and microcontrollers were beyond me

keen epoch
# nova ingot

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

keen epoch
#

Semi-afk

keen nacelle
#

You’ve gone over my head as well, but that’s how learning happens :)

nova ingot
#

im using 100ohm resistors

#

lowest i can get from adafruit

#

for some reason, i cant even get 3 leds to light up in series

keen epoch
#

Simulate it first 😉

#

Im reading/following along-just baking cookies

nova ingot
#

i ran into an issue. with a 10k pot, i only get a .01v difference

keen epoch
#

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