buzzing mindfulness bracelet code plus some new functions

CircuitPython on hardware including Adafruit's boards, and CircuitPython libraries using Blinka on host computers.

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
dastels
 
Posts: 15653
Joined: Tue Oct 20, 2015 3:22 pm

Re: buzzing mindfulness bracelet code plus some new functions

Post by dastels »

Code: Select all

while True:  # loop
    switch.update()  # all'inizio di ogni loop controlla il pulsante
    timer = time.monotonic() - start_time                              // LINE 1
    
    time_alarm = alarm.time.TimeAlarm(monotonic_time=time.monotonic() + interval)  
    # NUOVO
    alarm.light_sleep_until_alarms(time_alarm)  # NUOVO                // LINE 2
    
    # definisce timer come il tempo trascorso in ogni loop
    if timer >= interval and timer <= (interval + buzz):               // LINE 3
  
When the loop starts (after updating the switch) you compute the value for timer based on the current elapsed time (LINE 1). Then you sleep for interval seconds (LINE 2). After returning from the sleep (interval seconds later) you use the value of timer that was computed interval seconds in the past.

Looking at it more, you are unconditionally sleeping for interval seconds each time through the loop. That's probably not what you want. You probably want that only when timer < interval.

Dave

User avatar
bozzaglia
 
Posts: 131
Joined: Mon Aug 01, 2022 6:14 am

Re: buzzing mindfulness bracelet code plus some new functions

Post by bozzaglia »

Ok I need to look better at the code to understand.
In the meantime I would love some advise about the boards as I found a reseller in Italy who has both the ESP32-S3 and the ESP32-S2 PICO, which should both have Bluetooth and support the alarm module.
Can you advise about which one to get?

User avatar
dastels
 
Posts: 15653
Joined: Tue Oct 20, 2015 3:22 pm

Re: buzzing mindfulness bracelet code plus some new functions

Post by dastels »

The ESP32-S3 and ESP32-S2 are good. I don't know anything about the ESP32-S2-pico so I don't have much to say about it. They should be good for WiFi as well as BLE.

Dave

User avatar
bozzaglia
 
Posts: 131
Joined: Mon Aug 01, 2022 6:14 am

Re: buzzing mindfulness bracelet code plus some new functions

Post by bozzaglia »

So tomorrow I’ll probably be ready to solder the charger to the RP2040. I’ve ordered an ESP32-S3 with another charger but those should take at least 2 weeks to arrive.
I just wanted to confirm that I have to solder the two boards back to back using all the header pins on both sides and soldering every pad to the corresponding one on both boards. USB on same side as jst battery connector. Correct?

User avatar
dastels
 
Posts: 15653
Joined: Tue Oct 20, 2015 3:22 pm

Re: buzzing mindfulness bracelet code plus some new functions

Post by dastels »

So a QtPy annd BFF?

The BFF attaches under the QtPy as shown here: https://cdn-shop.adafruit.com/970x728/5397-09.jpg

Electrically, only 5v and Ground pins need to be attached. Attaching A2 will let you monitor battery voltage, sort of https://learn.adafruit.com/adafruit-qt- ... ep-3115769.

Note that you don't need to connect the back to back with headers, as long as 5v and ground on each board are connected. That lets you make the assembly thinner but with a bigger footprint... depends on your needs.

Dave

User avatar
bozzaglia
 
Posts: 131
Joined: Mon Aug 01, 2022 6:14 am

Re: buzzing mindfulness bracelet code plus some new functions

Post by bozzaglia »

“So a QtPy and BFF?”
You sound surprised... wasn’t that what you suggested, or did I miss something? :-)

Regarding the pins to solder, I think for my needs the back to back solution is best. I guess soldering all the headers (as shown in the attached picture from your website) makes the whole thing sturdier... or doesn’t?
After all I don’t plan to separate the boards or to change configuration later on.
Attachments
DDF6BBC5-AA51-4852-96FD-4AC41DF055EF.jpeg
DDF6BBC5-AA51-4852-96FD-4AC41DF055EF.jpeg (211.59 KiB) Viewed 114 times

User avatar
bozzaglia
 
Posts: 131
Joined: Mon Aug 01, 2022 6:14 am

Re: buzzing mindfulness bracelet code plus some new functions

Post by bozzaglia »

Hi, I’ve just finished soldering all the components and the add on charger to the RP2040. I plugged it into my windows 11 pc through a USB-C to USB-C cable (power and data capable), but it is not recognized (no usb icon or drive appearing). I tried pressing the reset button or the boot button but nothing happens. The led is on changing colors continuously.
Any idea how to fix this?

User avatar
dastels
 
Posts: 15653
Joined: Tue Oct 20, 2015 3:22 pm

Re: buzzing mindfulness bracelet code plus some new functions

Post by dastels »

What happens if you hold boot pressed while you press and release reset?

Dave

User avatar
bozzaglia
 
Posts: 131
Joined: Mon Aug 01, 2022 6:14 am

Re: buzzing mindfulness bracelet code plus some new functions

Post by bozzaglia »

I think it worked:
the led went off and the drive D: “RPI-RP2” appeared.
I noticed it doesn’t have a CODE.PY file inside, but just a file named INFO_UF2.
Do I have to install circuitpython?

User avatar
dastels
 
Posts: 15653
Joined: Tue Oct 20, 2015 3:22 pm

Re: buzzing mindfulness bracelet code plus some new functions

Post by dastels »

Yes, download CircuitPython 7.3.3 from https://circuitpython.org/board/adafruit_qtpy_rp2040/, and the latest Bundle for Version 7.x from https://circuitpython.org/libraries. Installation details are at https://learn.adafruit.com/adafruit-qt- ... cuitpython.

Once you install CP, the board should reset and CIRCUITPY should be available. Copy code.py to that and any libraries from the bundle to CIRCUITPY/lib.

Dave

User avatar
bozzaglia
 
Posts: 131
Joined: Mon Aug 01, 2022 6:14 am

Re: buzzing mindfulness bracelet code plus some new functions

Post by bozzaglia »

So I think I'm having a little emergency. Today while I was plugging the battery into the BFF and the QT PY was plugged in my USB port, I moved the wire going into the 3.3V pad and the led flashed yellow and the CIRCUITPY drive disappeared from my explorer.
I believe (but not sure) there was a contact betwen the wire and the adjacent pad M0.
I tried resetting, unplugging, restarting the pc but nothing worked. Then I used the same procedur you recommended at beginning: press reset while holding down boot. The drive appeared immediately with the other name I don't remember, so I pasted again the circuitpython UF2 file, nothing happened for a good couple of minutes while I kept trying stuff and then suddenly the CIRCUITPY drive reappeared.
It didn't last long though because after a few minutes the exact same thing happened, I moved inadvertently the wire and the led flashed and the drive disappeared. Just this time it seems it's not coming back no matter what I try. The board gets power from the pc, if I press boot+reset the "other" drive appears, but if I paste the UF2 file nothing happens...
Hope there is an easy solution to this... Thanks in advance

User avatar
dastels
 
Posts: 15653
Joined: Tue Oct 20, 2015 3:22 pm

Re: buzzing mindfulness bracelet code plus some new functions

Post by dastels »

What exactly do you mean by "I moved the wire going into the 3.3V pad". Generally you shouldn't mess with the wiring with a live circuit.

Dave

User avatar
bozzaglia
 
Posts: 131
Joined: Mon Aug 01, 2022 6:14 am

Re: buzzing mindfulness bracelet code plus some new functions

Post by bozzaglia »

Since I’m still making adjustments I haven’t encased the project and it is as in the picture (the kapton tape I added after this happened).
I guess my finger slipped while I was pushing the battery in the connector.
Attachments
686B7FE2-D6EE-4813-9318-234AD1439B17.jpeg
686B7FE2-D6EE-4813-9318-234AD1439B17.jpeg (359.83 KiB) Viewed 81 times

User avatar
bozzaglia
 
Posts: 131
Joined: Mon Aug 01, 2022 6:14 am

Re: buzzing mindfulness bracelet code plus some new functions

Post by bozzaglia »

OK, I think I solved the problem by using the USB “cleaning” software recommended on your website.
Now it looks like it’s working smoothly.

I am working on introducing the light sleep / alarm into my code, I will probably post an update about it later.

Thanks!

User avatar
dastels
 
Posts: 15653
Joined: Tue Oct 20, 2015 3:22 pm

Re: buzzing mindfulness bracelet code plus some new functions

Post by dastels »

Excellent. Try to avoid moving wires while it's powered. It's too easy to accidentally brush against something.

Dave

Locked
Please be positive and constructive with your questions and comments.

Return to “Adafruit CircuitPython”