#help-with-arduino

1 messages ยท Page 10 of 1

lethal yarrow
#

Multiplying DAC

random zealot
#

thank you! ๐Ÿ™‚

lethal yarrow
#

Analog also has some high voltage digipots, but I don't think that's what you want here.

random zealot
#

but I already have one for high voltage output 30V x4

#

AD5504

lethal yarrow
#

Small disclaimer: I work at Analog

#

(on automotive video chips, but there are some biomed guys in the same lab)

random zealot
#

Very thankful for you saying that, do you think you could help me build what I want to build? ๐Ÿ™‚

#

Ive been working on this for 9 months ๐Ÿ˜„

lethal yarrow
#

I'm happy to answer electronics questions and try to point you in the right direction though.

random zealot
#

I understand!

lethal yarrow
#

Analog does have a lot of biomed chips, including EEG and ECG. But those are for sensing, not neurostimulation.

random zealot
#

okay and what kind of advise would you give me if I needed to finish my medical hardware

lethal yarrow
#

Probably something along the lines of "talk to an applications engineer". I can't guarantee a response, but all of the apps engineers I've met have been very competent in their respective fields.

random zealot
#

okay, help me finish my board with potentiometer

#

MDAC instead of potentiometer, please! ๐Ÿ™‚

#

how would you wire this? ๐Ÿ™‚

lethal yarrow
#

MDACs are a bit weird, and usually need some external circuitry. They usually do best as current sinks. I would recommend taking a look at the end of some datasheets. They usually have some info about how they work.

random zealot
#

but I can wire them as simply as potentiometer?

lethal yarrow
#

No.

#

Each output acts as a current sink.

random zealot
#

okay so I just leave 1 output open ๐Ÿ™‚

random zealot
#

i cant get it done, I need your help, how can I connect this one and how can I even programm it? Isnt it completely unuseful? I can make a good enough POT in 20min

dusk orchid
#

@random zealot You need to seek professional help, what you are attempting is dangerous (electrostimulation, but anything >=48volts is considered unsafe in the UK). As Herr Brain said, an application engineer can guide you through your design goals and component selection. Most components offer a reference design (working circuit schematic), which is the minimum required to operate, and can be copied reliably.
More than that, if you say you have built 60 of the hardware devices already, then you really need to get professional help before you go any further, both for safety reasons, and because component selection will probably change the hardware design. Software is a secondary concern.

random zealot
#

and where do I seek help from ๐Ÿ™‚

stable forge
#

are you doing this for yourself, or are you working at a research institution or university?

random zealot
#

I am working with both and I have like 60 specialists behind me who told me nothing about "professional help"

stable forge
#

are you being paid by an institution? what country is it in?

random zealot
#

no, I am making a StartUp myself, Slovakia.

#

its a professional medical device

stable forge
#

it would be very good to seek the help of one or more professional electronics engineers, who specialize in medical devices. There are a great many regulations surrounding medical devices which are concerned with safety in all the countries I know of, and I assume the same is true in Slovakia. Can you find such a resource?

#

Medical devices need to be tested and certified

random zealot
#

I have talked to 500+ of them

#

every single one tells me a different answear on my baord

#

and my competition is literally rying to manipulate me and them into doing that

stable forge
#

But you yourself do not have the expertise.

#

do you mean your message board, or your company board?

random zealot
#

I do, I know how to build the device from anything

#

I literally can build it from a 9Volt

stable forge
#

As Herr Brain mentioned, you can consult with applications engineeers at Analog and other places. But it sounds you like need to hire an EE experienced in this field who you can trust. We cannot give you advice in this server for potentially harmful applications.

#

Our Code of Conduct says this is not allowed:

  • Discussion or promotion of activities or projects that intend or pose a risk of significant harm
#

neurostimulation without extremely careful consideration of the currents and voltages is such a project

#

that is what is worrying us

#

I am speaking as a moderator of the server

dusk orchid
#

@random zealot The general advice to seek professional help seems unhelpful, but there are different pro's with different expertise. The component manufacturers have Application Engineers that will guide you for your application to choose good components.
Also a Medical Device engineer or similar is required for your needs, along with legal help probably. This info about slovakian stimulation devices and testing may offer you further guidance but is probably already known to you.

plucky dune
#

Before soldering wanted to test the pled feather. Jumped off the 3.3v from the rp2040 feather then connected i2c. Loaded sample code into arduino ide uploaded but not seeing any changes. Perhaps someone can point out how Iโ€™m failing

muted gyro
#

This was the solution for a problem my friend recently had: solder those pin headers to the boards

#

He wanted to test something, had it set up like you, it didn't work. As soon as he soldered the pins, it worked

dusk orchid
#

I managed to use a thin string woven in some of the header holes, it forced the pins against the header holes, alternatively anything non conductive

plucky dune
#

not enough jumpers plugged in!

plucky dune
#

100% right on soldering btw. Had to hold it down for a stable connection

muted gyro
#

Is there a proper way to test/connect boards before/without soldering in pins/wires?
Like some spring-loaded pins? Or banana plugs except smaller? Clips?

#

I mean, there has to be an "official" way, right?

cedar mountain
#

The little mini-grabber hook clips may be helpful for that.

#

Professional setups often use jigs with pogo pins on them to connect to test pads on the board.

muted gyro
cedar mountain
#

Yeah, alligator clips aren't great.

muted gyro
#

are they small enough for those breadboard-friendly solder pads?

#

I can't really judge that from the pictures. But I guess I could just add them to my next order ๐Ÿ˜„

lethal yarrow
north stream
plucky dune
#

Yay

hollow frigate
#

Hi everyone;
I've run into a problem with circutmaker (altium) and I'm looking for help, does anyone have time to help out?

lethal yarrow
#

You'll never know unless you ask the actual question.

north stream
#

Please don't double post. People come and go and there may be no one around at a particular moment. Personally, I've never used Altium as it doesn't run on any operating systems I use.

orchid cliff
#

anyone know how i can make the file system visible in windows / linux / mac or whatever with the Pico W running C/C++

#

im looking through the docs but i cant see it in there

random zealot
#

guys i need to reproduce this with 30 resistors and 1 digital switch

#

please, is there something like potentiometer? And i cant use MDAC ๐Ÿ˜„

lethal yarrow
#

Well, low on resistance analog switches/multiplexers exist.

gilded swift
#

I donโ€™t think 30:1 muxes exist though

#

Thatโ€™s 5 control signals too

#

You could use a smรถl fpga

lethal yarrow
#

I think I've seen 24:1 before.

#

To switch resistors? Not really.

gilded swift
#

No

#

To turn on a mosfet

#

๐Ÿ˜›

north stream
gilded swift
#

Programmable regulators exist for that reason

north stream
#

Note: as drawn, it won't do what you want anyway.

gilded swift
#

Usually controlled over i2c

#

Or thatโ€™s a common mode anyway

random zealot
#

Thanky you guys! ๐Ÿ˜„

muted gyro
# orchid cliff anyone know how i can make the file system visible in windows / linux / mac or w...

I recommend you use the earlephilhower arduino-pico core and not the "official" mbed one.
Then I think you can use the Adafruit-TinyUSB stack. It has some examples
https://arduino-pico.readthedocs.io/en/latest/usb.html
https://github.com/adafruit/Adafruit_TinyUSB_Arduino

GitHub

Arduino library for TinyUSB. Contribute to adafruit/Adafruit_TinyUSB_Arduino development by creating an account on GitHub.

orchid cliff
orchid cliff
muted gyro
#

yes. The Pico SDK has TinyUSB

orchid cliff
#

i just need to figure out how to include it

#

is it just

#

#include <tinyusb>

#

or am i missing something

muted gyro
#

I think the Adafruit TinyUSB is just a more arduino-friendly version of TinyUSB

#

Honestly, not sure. I haven't used all that stuff yet :/

orchid cliff
#

well its confusing because vs code is useless because valid libraries show up as red squiggly lines

#

they compile perfectly fine but vs code is a pile of doo doo

#

like this just breaks

#

in vs code but works normally when i compile

muted gyro
#

ughhhh yeah... I use vs code with platformio and the earlephilhower core. Most of the time it works. But sometimes it just randomly thinks some include path is wrong ๐Ÿ˜†

orchid cliff
#

lmao i dont even know how i can like make it know that im using the pico sdk

#

lemme see if there is an extention

#

there isn't

#

so it shows up

#

bnut its red when i load it kekwarp

#

stupid vs code

#

when i remove the include it knows that the headers aren't there

#

so surely it should know that its a valid include

gilded swift
orchid cliff
#
# Generated Cmake Pico project file

cmake_minimum_required(VERSION 3.13)

set(CMAKE_C_STANDARD 11)
set(CMAKE_CXX_STANDARD 17)

# Initialise pico_sdk from installed location
# (note this can come from environment, CMake cache etc)
set(PICO_SDK_PATH "/mnt/d/Github Repos/PicoDuckyC/pico-sdk")

set(PICO_BOARD pico CACHE STRING "Board type")

# Pull in Raspberry Pi Pico SDK (must be before project)
include(pico_sdk_import.cmake)

if (PICO_SDK_VERSION_STRING VERSION_LESS "1.4.0")
  message(FATAL_ERROR "Raspberry Pi Pico SDK version 1.4.0 (or later) required. Your version is ${PICO_SDK_VERSION_STRING}")
endif()

project(ProjectName C CXX ASM)

# Initialise the Raspberry Pi Pico SDK
pico_sdk_init()

# Add executable. Default name is the project name, version 0.1

add_executable(ProjectName ProjectName.c )

pico_set_program_name(ProjectName "ProjectName")
pico_set_program_version(ProjectName "0.1")

pico_enable_stdio_uart(ProjectName 1)
pico_enable_stdio_usb(ProjectName 1)

# Add the standard library to the build
target_link_libraries(ProjectName
        pico_stdlib)

# Add the standard include files to the build
target_include_directories(ProjectName PRIVATE
  ${CMAKE_CURRENT_LIST_DIR}
  ${CMAKE_CURRENT_LIST_DIR}/.. # for our common lwipopts or any other standard includes, if required
)

# Add any user requested libraries
target_link_libraries(ProjectName 
        )

pico_add_extra_outputs(ProjectName)

#

i forgot to change the project name kekwarp

gilded swift
#

Yeah, make sure to update your file name in there too

orchid cliff
#

this is just a test project im not gunna keep using it its just so i know how to use the SDK

#

then i'll build what im actually trying to build

orchid cliff
#
/mnt/d/Github Repos/PicoDuckyC/pico-sdk/src/rp2_common/pico_stdio_usb/stdio_usb.c:251:2: warning: #warning stdio USB was configured, but is being disabled as TinyUSB host is explicitly linked [-Wcpp]
  251 | #warning stdio USB was configured, but is being disabled as TinyUSB host is explicitly linked
      |  ^~~~~~~
/mnt/d/Github Repos/PicoDuckyC/pico-sdk/src/rp2_common/pico_stdio_usb/stdio_usb.c:252:1: error: unknown type name 'bool'
  252 | bool stdio_usb_init(void) {
      | ^~~~
/mnt/d/Github Repos/PicoDuckyC/pico-sdk/src/rp2_common/pico_stdio_usb/stdio_usb.c:1:1: note: 'bool' is defined in header '<stdbool.h>'; did you forget to '#include <stdbool.h>'?
  +++ |+#include <stdbool.h>
    1 | /**
/mnt/d/Github Repos/PicoDuckyC/pico-sdk/src/rp2_common/pico_stdio_usb/stdio_usb.c: In function 'stdio_usb_init':
/mnt/d/Github Repos/PicoDuckyC/pico-sdk/src/rp2_common/pico_stdio_usb/stdio_usb.c:253:12: error: 'false' undeclared (first use in this function)
  253 |     return false;
      |            ^~~~~
/mnt/d/Github Repos/PicoDuckyC/pico-sdk/src/rp2_common/pico_stdio_usb/stdio_usb.c:253:12: note: 'false' is defined in header '<stdbool.h>'; did you forget to '#include <stdbool.h>'?
/mnt/d/Github Repos/PicoDuckyC/pico-sdk/src/rp2_common/pico_stdio_usb/stdio_usb.c:253:12: note: each undeclared identifier is reported only once for each function it appears in
make[2]: *** [CMakeFiles/PicoWDuckyC++.dir/build.make:605: CMakeFiles/PicoWDuckyC++.dir/mnt/d/Github_Repos/PicoDuckyC/pico-sdk/src/rp2_common/pico_stdio_usb/stdio_usb.c.obj] Error 1
make[1]: *** [CMakeFiles/Makefile2:1789: CMakeFiles/PicoWDuckyC++.dir/all] Error 2
make: *** [Makefile:103: all] Error 2```
#

apparently it doesn't know what a boolean is

#

im so confused

gilded swift
#

Probably something not getting linked properly

orchid cliff
#

maybe but its confusing

north stream
#

It does suggest including the stdbool.h header, maybe do that?

gilded swift
#

It should have it automatically

#

Which makes me think a breaking change happened at some point in the sdk

#

Or perhaps they need to reclone the pico sdk

north stream
#

Or the toolchain

gilded swift
#

That too

random zealot
#

can you tell me how to change plus to minus voltage and vice versa? ๐Ÿ™‚

muted gyro
#

H bridge๐Ÿค”

random zealot
#

I need help with coding ๐Ÿ™‚

muted gyro
#

with what?

random zealot
#

its very complicated but arduino circuit ๐Ÿ™‚

muted gyro
#

then you should imho describe the circuit, describe what you want to do and where exactly you need help

cedar mountain
random zealot
#

in other words, I want to make alternating current

#

I have 30V output that goes from 0,1-10mA but it doesnt describe whether it is positive or negative

#

so how to make this current output alternating? ๐Ÿ˜„

muted gyro
#

dc to ac converter?

random zealot
#

it already is DAC and it goes to current regulator

#

so the current can sty and it is just the voltage that has to go from neg to positive and back?

lethal yarrow
#

You can't regulate both. You have to be actively controlling either the voltage or current. The other will track depending on your load. Also not to soft mod but remember the code of conduct.

gilded swift
#

Yeah, I really tend to think if you are making a device intended to be used medically that you should hire a professional engineer with the skills do make what you are describing. Note that it absolutely has to be reviewed by a board of professionals anyway in most EU countries and for approval in the US. Even just to sell in the EU/UK you need very specific testing which will require you have a professional engineer anyway. This discord really isnโ€™t the appropriate place to get advice for medical devices, and honestly opens up a bit of liability that I doubt many would want to deal with.

cedar mountain
#

At least in the U.S. you can't even build a medical device and then get it certified later. The certification process wants to look at the whole development along the way too, making sure that way done properly.

orchid cliff
#

i dont think im googling the right thing can someone help, with the Pico SDK how can i make the on board flash memory show up on a computer when it's plugged in

#

as a mass storage device*

gilded swift
orchid cliff
#

i mean like

#

idk

#

yk when you install circuit python

#

the uf2

#

once that's installed

#

you can still write to the flash

#

i dont think im making sense

livid osprey
#

Oh, you want a file system on your not Python environment

orchid cliff
#

yes filesystem

#

im using C++

#

but i cant find it in the SDK documentation anywhere

#

it thinks im adding an SD Card reader

#

every time

livid osprey
#

I donโ€™t know if it shows up as a mountable drive, but you can create a file system with I think it was LittleFS?

gilded swift
#

You can use TinyUSB I believe

orchid cliff
#

idk

orchid cliff
#

typically i like my projects to require zero setup for the end user

#

they just drag and drop and or just open the executable or whatever

#

i think i can use Fat

#

iirc

#

but like, obviously before i can start coding the actual program i need to be able to let the user add files to the flash after the uf2 is loaded

muted gyro
gilded swift
orchid cliff
#

i tried that

#

i have that currenlty compiled

#

and running on my pico but it doesn't load

#

so do i like need some external software to be able to view the file system or something

gilded swift
#

Should just be file explorer or finder on Mac

orchid cliff
#

then no, it doesn't work for whatever reason

#

i haven't even modified it at all

#

i tried it both on a pico and a pico W

#

and neither work

gilded swift
#

Does it show up under device manager? Or under /dev/ as a usb device?

orchid cliff
#

i haven't checked

orchid cliff
#

i have zero communication but i know its running the binary because the led is blinking

gilded swift
#

Hmm

#

Very strange

orchid cliff
#

okay i added cmake pico_enable_stdio_usb(project 1)

#

to the cmake file

#

now i have a compile error

#

unrelated

#
[ 69%] Building C object CMakeFiles/msc_file_explorer.dir/mnt/d/Github_Repos/PicoDuckyC/pico-sdk/src/rp2_common/pico_stdio_usb/stdio_usb_descriptors.c.obj
/mnt/d/Github Repos/PicoDuckyC/pico-sdk/src/rp2_common/pico_stdio_usb/stdio_usb.c:252:2: error: #warning stdio USB was configured, but is being disabled as TinyUSB host is explicitly linked [-Werror=cpp]
  252 | #warning stdio USB was configured, but is being disabled as TinyUSB host is explicitly linked
      |  ^~~~~~~
compilation terminated due to -Wfatal-errors.
cc1: all warnings being treated as errors
[ 70%] Building C object CMakeFiles/msc_file_explorer.dir/mnt/d/Github_Repos/PicoDuckyC/pico-sdk/src/rp2_common/pico_unique_id/unique_id.c.obj
make[2]: *** [CMakeFiles/msc_file_explorer.dir/build.make:657: CMakeFiles/msc_file_explorer.dir/mnt/d/Github_Repos/PicoDuckyC/pico-sdk/src/rp2_common/pico_stdio_usb/stdio_usb.c.obj] Error 1
make[2]: *** Waiting for unfinished jobs....
[ 71%] Building C object CMakeFiles/msc_file_explorer.dir/mnt/d/Github_Repos/PicoDuckyC/pico-sdk/src/rp2_common/hardware_flash/flash.c.obj
/mnt/d/Github Repos/PicoDuckyC/pico-sdk/src/rp2_common/hardware_flash/flash.c: In function 'flash_range_erase':
/mnt/d/Github Repos/PicoDuckyC/pico-sdk/src/rp2_common/hardware_flash/flash.c:71:30: error: declaration of 'flash_range_erase' shadows a global declaration [-Werror=shadow]
   71 |     rom_flash_range_erase_fn flash_range_erase = (rom_flash_range_erase_fn)rom_func_lookup_inline(ROM_FUNC_FLASH_RANGE_ERASE);
      |                              ^~~~~~~~~~~~~~~~~
compilation terminated due to -Wfatal-errors.
cc1: all warnings being treated as errors
make[2]: *** [CMakeFiles/msc_file_explorer.dir/build.make:696: CMakeFiles/msc_file_explorer.dir/mnt/d/Github_Repos/PicoDuckyC/pico-sdk/src/rp2_common/hardware_flash/flash.c.obj] Error 1
make[1]: *** [CMakeFiles/Makefile2:1761: CMakeFiles/msc_file_explorer.dir/all] Error 2
make: *** [Makefile:103: all] Error 2```
#

i removed the cmake line and the compile error has gone

#

i ran make clean

#

then compiled again

#
io_usb/stdio_usb.c.obj
/mnt/d/Github Repos/PicoDuckyC/pico-sdk/src/rp2_common/pico_stdio_usb/stdio_usb.c:252:2: error: #warning stdio USB was configured, but is being disabled as TinyUSB host is explicitly linked [-Werror=cpp]
  252 | #warning stdio USB was configured, but is being disabled as TinyUSB host is explicitly linked
      |  ^~~~~~~
compilation terminated due to -Wfatal-errors.
cc1: all warnings being treated as errors
make[2]: *** [CMakeFiles/msc_file_explorer.dir/build.make:657: CMakeFiles/msc_file_explorer.dir/mnt/d/Github_Repos/PicoDuckyC/pico-sdk/src/rp2_common/pico_stdio_usb/stdio_usb.c.obj] Error 1
make[2]: *** Waiting for unfinished jobs....
[ 69%] Building C object CMakeFiles/msc_file_explorer.dir/mnt/d/Github_Repos/PicoDuckyC/pico-sdk/src/rp2_common/pico_stdio_usb/stdio_usb_descriptors.c.obj
make[1]: *** [CMakeFiles/Makefile2:1761: CMakeFiles/msc_file_explorer.dir/all] Error 2
make: *** [Makefile:103: all] Error 2```
#

that's with the cmake line

gilded swift
#

Hmm interesting

orchid cliff
#

i need that cmake line because i dont have headers on my pico w so i cant use uart

#

with the pico probe thing

orchid cliff
#

IT SHOWS UP

#

BUT NOT AS A MASS STORAGE DEVICE

#

i've managed to get it to show up in device manager

#

Driver Name: null
Class Guid: {00000000-0000-0000-0000-000000000000}
Driver Date: 
Driver Version: 
Driver Provider: 
Driver Section: 
Driver Rank: 0x0
Matching Device Id: 
Outranked Drivers: 
Device Updated: false
Parent Device: USB\VID_2E8A&PID_000A\E66118604B5D2627```
orchid cliff
#

ayyyyyyyyyyyyyyyyyyy

spare ember
#

Question: i have an Arduino mega and want to use 18 arcade buttons. The buttons have 12v leds and i want to use 12v for them from a power supply so they are bright enough t use during daylight. I'm thinking about using two ls2 level shifters so my signal from 5v Arduino will light the leds of 12v on the arcade buttons. https://www.ezsbc.com/product/ls2/ is this a safe construction? 5v to V-in, ground to in I-ground, 12v to V-out ground to O-ground and then then 5v signals to i-1 to I-8 and 12v to 0-1 to O-8

The LS2 is a twelve channel 12V level shifter and buffer. It can convert and buffer 12 digital signals.

north stream
limpid thunder
#

I want to make a controller using joysticks and a arduino micro

#

I want to add two analog triggers though and I dont know how

#

I don't know the pinout neither the code has to be

#

Can someone help please ?

gilded swift
#

Can you share what youโ€™ve tried so far?

limpid thunder
gilded swift
#

My suggestion, start with the basic examples Arduino provides, get a feeling for how analog inputs work on Arduino, then try what you want to do.

gilded swift
#

The best way to learn in many cases is to work through and try to understand the minimal examples. Theyโ€™ll give you the foundations for more complex solutions.

lethal yarrow
#

For two analog joysticks you'll need four ADC channels (x and y for each).

lethal yarrow
#

Most joysticks are basically just potentiometers. All you have to do is connect power and ground, then measure the voltages at the wiper pins.

limpid thunder
#

But I don't want joysticks

#

I want the analog triggers like a ps5

lethal yarrow
#

The complexity is in the firmware: do you need to filter the samples? How do you account for dead zones?

lethal yarrow
limpid thunder
#

Or is it not how it works ?

gilded swift
#

You still need to have a threshold value to know when to trigger. Reading the voltage and sending a USB/Bluetooth HID command

lethal yarrow
#

Most game controllers now use USB HID, so essentially what you'd have to do is emulate an existing controller.

#

If you want an analog trigger, it will show up as an axis.

limpid thunder
#

I thought that it works like

#

If it's at 512 it's medium

#

If it's at 700 it's semi high

#

Some like that

#

Or is it like a button?

#

So there is no reason to add an analog trigger?

lethal yarrow
#

Yes, but what if it's at 511, or 515? Do those still count as medium?

lethal yarrow
limpid thunder
#

Let's say

#

I have a game

#

In which game

#

If you press the trigger ligthly

#

A water pistol shoots slow

#

Then when pressing it medium

#

It shoots faster

#

And etc etc

#

How would that work

#

?

#

But also

#

I want it to work like buttons to a game that does not recognize such mechanisms

muted gyro
#

If you have a microcontroller, that can do HID, you can do whatever you want. But the game of course needs to support it in some way

limpid thunder
#

I have the arudino micro

#

Which has built in hid

muted gyro
#

For example if the game doesn't support analog triggers, but it does support 3 buttons for "shoot slow", "shoot medium" and "shoot high". Then you could read the analog value of the trigger and depending on that send a button press for slow, medium, or fast.

gilded swift
#

Technically HID isnโ€™t built in, it just has library support

limpid thunder
lethal yarrow
#

Ok, I think I see where you're going with this:

  1. There's a game you play that lets you shoot something as fast as you can push a button.
  2. You have a squirtgun and want to change how fast the game gun fires based on how hard you pull the trigger.
gilded swift
#

Essentially youโ€™ll translate analog voltage ranges to values sent over HID that correspond to expected values for trigger pressure

limpid thunder
#

Wait

#

I will explain with a voice message

lethal yarrow
#

If the game is expecting a button input, you will need to produce what the game recognizes as "button presses" at a rate proportional to how hard you are pulling the trigger.

gilded swift
#

All the USB HID supported commands

limpid thunder
gilded swift
#

They even have the ones for golf lol

limpid thunder
#

Idk if map is the command because I forgor

#

But can I map the potentiometer

#

Potentiometer input?

#

How is it called ?

#

I think input

#

To 10?

#

Like 1023 will be 10

#

And 0 0

#

So

#

There will be modes ?

#

So 0 will be low

#

10 high

#

And the rest

#

Idk

gilded swift
#

For 0-1023, Iโ€™d recommend 8 steps

#

0-7

limpid thunder
#

Problem is will that work ?

#

Like if I play a car game

#

And I press the trigger fully

#

It goes maximum horsepower

#

Slightly = less horsepower

#

None = 0 km

#

Can I?

gilded swift
#

Yeah, itโ€™s all based on the max value that the HID can send

#

The HID document specifies what is standard and they donโ€™t list a value that has to be max, only that it has a specified range. Those ranges and available controls are communicated when the device sets up with the computer

limpid thunder
#

So at the file you've sent me above

#

What should I look for

lethal yarrow
gilded swift
#

Look at automobile control as a starting point since thatโ€™s a pretty common example of ranged HID inputs

limpid thunder
#

I want to drive a car at a game and depending at how hard I press the trigger it's speed increase or decrease

#

But

#

At another game

#

Which such mechanism does not exist

#

I don't want to change the whole code

#

I want the code to support both modes

gilded swift
#

It will just take the min and max value in those cases

limpid thunder
#

Idk if that's possible

lethal yarrow
gilded swift
#

They want to support both

#

Which is possible

lethal yarrow
#

That assumes they have some degree of control over the game.

gilded swift
#

For ones where there is no variable acceleration, it would simply catch the โ€œnot pressedโ€ and โ€œfully pressedโ€ inputs

muted gyro
limpid thunder
#

Oh okay cool

lethal yarrow
#

If I were to guess, this sounds like a first person shooter that they want to build a custom controller for. I've never seen an FPS game that allows you to control rate of fire with an analog axis.

gilded swift
#

Same

#

Itโ€™s always been full send or none at all

muted gyro
#

hopefully not offtopic: If that game is a multiplayer game or features leaderboards, scores, etc, make sure that what you're doing isn't cheating.
Imho building a device that can fire faster than me clicking the mouse, could be considered cheating

gilded swift
#

But that analog trigger also allows you to have variable acceleration in racing games too

#

Thatโ€™s why Iโ€™m saying that you donโ€™t need to try and support both in code because itโ€™s already supported in the host

lethal yarrow
limpid thunder
#

That was an example

#

Why cant we say he ll no

#

I wanted to say bruh he ll no to your message penpengu

lethal yarrow
#

Swears are blocked by the bot in this server

gilded swift
#

The word is considered vulgar to some people

#

So while it might not be bad to a subset of people, it can be to others

limpid thunder
#

First server that supports crrhistianity

#

Religions in general

#

๐Ÿ‘

gilded swift
#

We support all people as long as they are not rude or hateful towards others

lethal yarrow
#

So, what are you trying to do? Are you using this for a game you are writing?

#

If so that could significantly simplify things.

limpid thunder
#

Like a ps4 or ps5

#

With analog triggers

lethal yarrow
#

... so basically you want to plug an xbox controller into your playstation?

gilded swift
#

I donโ€™t think PlayStation 4/5 games support analog triggers?

#

I thought the controllers used push button triggers

#

Oh the new ones have adaptive triggers which are basically motors with worm gears which then provides a voltage input to the controllers MCU

muted gyro
#

yeah, they're really cool tech ๐Ÿ˜„

gilded swift
#

But also used to change the feel of the trigger too. Neat

muted gyro
#

I think the triggers on the PS4 are normal analog

#

fun fact: the triggers on the XBox one controller use hall sensors (or something like that. It's definitely contactless)

gilded swift
#

Ah maybe the ps4 is analog. Thanks steam for detailed infographics

gilded swift
#

I bought one with the clear case because why not

muted gyro
#

Interesting how long it's taking them to switch the thumb sticks to hall ๐Ÿ˜„

muted gyro
gilded swift
#

I bought an AfterGlow controller

#

Works well enough

midnight sleet
#

Is there a way to get the file system to show up on windows when using an Arduino program?

#

The SPI flash example can write a file to the circuit python's filesystem

#

And if circuit python is installed you can read the file on the computer

#

Ok wait I forgot the details

#

I'm using a CPX and writing to the onboard flash

#

So my question is

#

Can I somehow mount the drive with the circuit python files from an Arduino program?

stable forge
midnight sleet
#

Update: read the TinyUSB description and looks like what I need, but... can't get the option under tools to get it to compile

midnight sleet
#

Yea id that the right one?

#

Tried installing the Adafruit SAMD boarda instead of the Arduino ones
And after adding the custom board url it showed up to install

stable forge
#

yes, was just verifying there wasn't some thing more specific or newer

midnight sleet
#

But I installed it and the boards don't show up : ๐Ÿ˜ญ

#

At all

stable forge
#

you need to install first the Arduino and then also the Adafruit SAMD boards

midnight sleet
#

Ah

#

So does the Adafruit one add extra info I guess?

stable forge
#

yes, I think I have a pointer to describe that ... hold on

midnight sleet
#

Huh

midnight sleet
#

Uninstalling and reinstalling made the boats show up

stable forge
#

the CPX board def is actually part of the Arduino SAMD, unlike other Adafruit SAMD boards

midnight sleet
#

But is it also part of the Adafruit SAMD boards?

stable forge
midnight sleet
#

Since I read somewhere you gotta use that to use TinyUSB

stable forge
#

anyway, install both

midnight sleet
#

Ok

stable forge
#

swing back if you get stuck -- this is ongoing ๐Ÿ™‚

midnight sleet
#

Yay it worked! Thank you so much!

charred salmon
#

Quick question about EEPROM availability. Under normal circumstances (that is, not using any libraries that explicitly need EEPROM storage) I should have free reign over the entire EEPROM region of a chip, right? It's not like I run the risk of stomping on a piece of data that the Arduino IDE is going to expect to be available for some low level function?

#

I know that the EEPROM and program storage are different regions, so this isn't about stomping on the actual code.

north stream
#

In general, the EEPROM is yours to do with as you please.

charred salmon
#

Awesome. I only need one byte, but just wanted to make sure that going with the obvious choice of byte 0 wasn't going to be a problem.

north stream
#

I saw one project that needed to store a single byte that hid it in one of a few bytes of battery backed RAM in a real time clock chip.

charred salmon
#

I saw one project where the guy needed a few extra bytes of RAM, and took over a number of registers for functions that weren't actually needed.

#

The crazy things that can be done

north stream
#

Oh, that works. I saw another one that used the custom character storage in an LCD display to cache some data.

charred salmon
#

Oh, the fun thing with that is you can include a function to let you directly view the memory in question.

north stream
#

That's handy!

charred salmon
#

For my purposes, I want to allow the option of attaching a button, and swapping between two sets of switch settings, and have them persist after poweroff to avoid reconfiguring every time since the controller may not always be easily accessible, nor is reconfiguring quick.

#

Set the switches to one mode, hold the button to save. Then change the switches to a second mode, and tap the button to toggle them.

#

Also useful if you only want one mode, but the ability to turn the lights off. If the saved and physical settings are the same, toggling will turn the lights on or off.

lethal yarrow
#

The main rule with EEPROM is that you want to try to limit how much you write to it. Like flash (actually the reverse since flash was derived from EEPROM), it has a finite lifecycle. A discrete EEPROM can usually handle 1-2 million writes, but for microcontrollers this will typically be an order of magnitude lower.

charred salmon
#

Oh I should be getting nowhere near any wear limits. This will get written like, a few hundred times over the life of the unit.

lethal yarrow
#

Yeah it's fine then.

charred salmon
#

I'm not even going to do a sanity check on the value on bootup because ultimately any 8 bit value will be valid for something.

lethal yarrow
#

The only other (potential) issue I can think of is some library wanting to store its state, but this is rare

charred salmon
#

Yeah, that's what I was mostly worried about. The only library I'm importing is the NeoPixel one, which is unlikely to need it.

lethal yarrow
#

Yeah should be fine then.

charred salmon
#

I figure though, any libraries that would want to use EEPROM would be fairly explicit about it, and in a sane world would have to configure where in EEPROM their data will live specifically to avoid conflicts.

lethal yarrow
#

Yeah

brazen wadi
#

can anyone recommend a microcontroller with support for around 15 - 20 digital pins and space still for 6 analogs?

#

also data which can be sent over usb. for a gamepad

#

i was looking at esp32 but dont need wifi or bluetooth

brazen wadi
#

thanks @north stream what's the black housing for next to the usb?

north stream
#

That's for a lithium polymer cell, the board includes a charger so it can charge the cell when it's connected to USB, and run from the cell if it's not connected to USB. If you don't need battery functionality, you can ignore it, the board runs fine without one.

brazen wadi
#

i hear ya

#

quite pricy tho eh

#

i can get 3x esp32 clones for this price

muted gyro
brazen wadi
#

dont know what a matrix is sorry

muted gyro
#

google "keyboard matrix" and I bet you find an explanation that's better than what I could write ๐Ÿ˜„

#

this principle is used in PC keyboards as well

brazen wadi
#

something like this?

muted gyro
#

๐Ÿค” i don't think so

north stream
#

I'm partial to the HT16K33 for driving keypads (it's technically an LED driver, which is useful, but includes keypad functionality). But you can use a few GPIOs in rows and columns to read an array of switches.

brazen wadi
#

i mean the esp32 or the adafruit feather has pins for all my needs

#

and maybe if im smart i can send data via esp32

#

๐Ÿ™‚

muted gyro
#

I don't think all ESP32 have native usb, just pay attention to that when choosing it

brazen wadi
#

im just looking at the devkits

#

thanks though

muted gyro
#

still, just because you can upload your program using the USB port on a dev kit, doesn't mean that the microcontroller can also act as a HID device (game controller, Keyboard, Mouse, etc)

brazen wadi
#

yeh wise words i'm probably going to copy a tutorial exactly

muted gyro
#

๐Ÿ‘ sounds like a safe plan

north stream
#

The 32U4 is a nice one, with native USB/HID support, 5V logic, and several existing projects using it as a keypad. The RP2040 is another possibility.

muted gyro
#

RP2040 only 4 analog inputs :/

#

but Raspberry Pico only costs like 4โ‚ฌ so maybe you could just use 2 ๐Ÿ˜†

brazen wadi
#

the problem im facing is the software ecosystem around rk3588 chips from rockchip. there's lots of deadends so i feel offloading to a dedicated feather board will allow more flexibility

#

also adafruit-mcp3xxx hasn't yielded results for me yet with it only returning a max / min value.... however i'm still figuring out if i'm using the right pins

#

i can't seem to build retroarch in armbian atm altho i'm told there's an aur source that might build, yeh definitely ideally armbian but still not making the big break throughs

#

batocera is using build root so limited library support unless they are bundled

#

it's just a mess in my head atm

#

yeh 2040 just falls a bit short, thanks for helping

#

esp32 seems to be the way over bluetooth

#

thanks @north stream i think 32u4 is going to be the one here. it's got the analog chanels and enough io

#

a bit more pricy than i hoped but it's a one time thing so why not

quick maple
#

like 1KB/3.5KB 16kb firmware

brazen wadi
#

must be enough to receive and store the values then broadcast as keypress

#

im dealing with a 9kb file in python

#

basicaly a port of that

north stream
#

Note that the 32U4 cannot run Python, so you'd have to port the code to Wiring

brazen wadi
#

thanks @north stream my frustrations with syntax are firmly stuck after language 7

quick maple
#

I cant figure out how to talk to my pico W in the arduino IDE

#

I installed the board manager URL and everything it propose to download, I see the UF2 files on my G: drive but cant get board info no matter what port I choose and adafruit learn doesnt seem to say much except to use the board managers URL and everything should happens by magic or something then it just talks about circuitpython. Also on Im the more recent arduino IDE and I cant find tools->board manager

#

I installed the board manager URL and everything it propose to download, I see the UF2 files on my G: drive but cant get board info no matter what port I choose and adafruit learn doesnt seem to say much except to use the board managers URL and everything should happens by magic or something then it just talks about circuitpython. Also on Im the more recent arduino IDE and I cant find tools->board manager

north stream
#

Arduino support for the Pico is known to be iffy. Some people apparently opt for the earlephilhower core instead.

quick maple
#

yeah that is what I seem to have installed

#

their docs from the link above offer several install options one of which is a board manager URL

north stream
#

Does it show up in the ports list?

quick maple
stable forge
#

go to Tools->Board->Board Manager

#

that was where it was on the old IDE also

muted gyro
quick maple
#

yeah the board is installed and I selected the uf2 port but it keep showing a communication error with it

#

but the upload seem to have worked

#

something seems off here, why flashing just to upload a less than 1kb sketch...

stable forge
#

The RP2040 has no internal flash. All firmware is on the external flash chip

#

why it's 600k, not sure, but may drag in a lot of libraries

muted gyro
#

The memory usage is so gigantic because it needs to pull in a giant firmware blob for the Wifi module and I think even an entire IPV4 stack because the LED_BUILTIN is connected to the wifi module and not the RP2040

stable forge
#

did not see it was the W

quick maple
#

ok so it seems everything seems normal to you so I will just get used to the pico W way of behaviours in the arduino IDE

#

the led blinks etc and if I disconnect it the program is gone if I hold bootsel and still there if I dont hold bootsel so it seems everything is fine and I can still recover

stable forge
#

If there is a working program running, bootsel is not necessary, but if it's hard-crashing, you need to get it into boot mode manually (PenPengu can confirm).

muted gyro
#

exactly

quick maple
#

so bootsel is hooked to tp6 right ? So I could mount another safer button externally instead of touching the tiny bootsel button and risking esd damage/pins damage right ?

#

like say a physical on off switch

muted gyro
#

Honestly, I'm not really worried about ESD damage with those boards.
When we worked with expensive FPGA boards, the prof told us to first touch the PC case or the USB on the board but idk

stable forge
#

you could, but I've never heard of anyone zapping their board that way. If it's really low humidity, a wrist ground strap or just discharging yourself in advance is a good idea for anything.

muted gyro
#

Touching a radiator supposedly also discharges you

quick maple
#

yeah i touch my pc case first. but even then in the final mounting the bootsel button will be facing down and not able to be used

stable forge
#

then for convenience, sure

quick maple
#

thanks for your help ! ๐Ÿ™‚ now I need to ask somewhere else so it can speaks with uart with a 5V 32u4

stable forge
#

or replace the 32u4 with some arduino-shaped board that is 3.3V native

#

assuming it is a Leonardo or simialr

quick maple
#

yeah those are the shifters I have and I cant replace the board it's a custom one for a robot kit(zumo 32u4) based on 32u4 atmel but it's not actually a due/leonardo

#

My old code uses a serial.println but that doesnt seem to go throught on UF2 port ??

charred salmon
#

I believe if the microcontroller features native USB support, that is what will be used if you initialize and try to use the "default" serial port. To use the physical pins you have to initialize a different serial port.

#

Try initializing and using serial1 instead of just serial.

muted gyro
quick maple
#

nope not getting anything either with serial or serial1 also when I turn on serial monitor the uf2 port disappears and I have to upload with com3

muted gyro
#

UF2 is only the bootloader

quick maple
#

but it does run on uf2 bootloader... that's what confuse me. The led turn on like I code it

#

and the led on the ir receiver is off when pin is initialised. And yes Im very confused this is my first time with an rp2040

muted gyro
#

I think maybe the UF2 port stays there in the IDE ๐Ÿค”

#

However, if you want to communicate with your code COM[SomeNumber] is correct

#

You can't communicate with your code using UF2

quick maple
#

so Im supposed to reboot everything I compile a sketch and to put a sketch on it I have to hold bootself ?!

muted gyro
muted gyro
#

2 ways to upload sketches:

  1. Hold Bootloader button while plugging it in. Then select the UF2 port thing in the IDE.
  2. Just plug in the Pico normally. Your code runs. In the IDE, select the correct COM[Number] port. Just click upload.
quick maple
#

Still not getting anything and screenshot show Im trying to use both serial1 and serial COM3 shows the thing to the right

muted gyro
#

After uploading it should automatically start your program

quick maple
#

But on the "hardware" level it seems to work. IR receiver light up when I use my remote and the led keep blinking so the program "works" just not getting any serial.println or serial1.printlin with the name of the button pressed

muted gyro
#

Serial = USB
Serial1 = UART0 (Pins on the side of the board)
Serial2 = UART1 (Pins on the side of the board)

quick maple
#

thanks for your help it works now ๐Ÿ™‚

muted gyro
#

๐Ÿฅณ

#

A random issue I just noticed:
while(!Serial) get's stuck. It only continues after I send one enter from the PC to the Pico ๐Ÿค”

quick maple
#

yeah the while thing is what I needed for it to work

#

where as that is not necessary on the mega 2560

muted gyro
#

ah interesting

quick maple
#

Protocol=UNKNOWN Hash=0x 13 bits (incl. gap and start) received OK ๐Ÿ˜ฆ ๐Ÿ˜ข Just like I thought my sony remote doesnt use a sony protocol supported by an arduino library ๐Ÿ˜ฆ

#

to give some context: Ive been mapping manually between buttons and hex values but Id rather find a library that already has it. But only libc for linux has it (ie: a C++ RPI program. Since the ir receiver works now I want to all support for all buttons

quick maple
#

13:54:43.775 -> P=SIRCS | 0x1 A=0xB C=0x9 13:54:43.900 -> P=SIRCS | 0x1 A=0xB C=0x9 R (VCR target version)
13:54:45.378 -> P=SIRCS | 0x1 A=0x1 C=0x9 13:54:45.517 -> P=SIRCS | 0x1 A=0x1 C=0x9 R (TV target version)

proper forum
#

Hi, I have a project using an itsybitsy m0 that seems to be having some conflict involving the servo library and interrupts. I have a servo connected on D5 and an interrupt set up on A5. In my code, if I enable the interrupt and have the servo connected, the servo will twitch about twice per second. If I comment out the attachInterrupt in the code and upload, the servo does not twitch. I only see this behaviour when running off my ESC's built in BEC and not when the itsybitsy is connected my computer through USB

midnight sleet
#

I'm getting the error

Compilation error: Adafruit_BLE.h: No such file or directory

which is odd because
a. I did install Adafruit BLE firmata library
b. I had a BLE example working yesterday...

midnight sleet
#

oh wait wrong module thingy

maiden trellis
#

Hi all! I have an esp32-s2 feather board (with the built in i2c lipo info chip) but I'd like to try detect if it's powered by usb or the lipo. Is this possible (without additional components)

stable forge
maiden trellis
#

lol. I meant in code running on the board.

#

but thank you fellow linux nerd ๐Ÿ™‚

stable forge
#

or you can connect a 2/3 voltage divider to the USB pin and check the level of that with another pin

maiden trellis
#

Ah, so usb_connected would return true if it had a computer connected, but false if it was powered by a "dumb" usb supply?

stable forge
#

right. usb_connected sees whether it's enumerated its USB devices to the host

maiden trellis
#

that's really cool, but in my case this is for a iot'ish device that would most likely be powered by a dumb usb power supply.

stable forge
#

then the voltage divider check is the thing

maiden trellis
#

I really need to give circuitpython a go. I'm an actual python engineer but I got stuck in arduino land many years ago when circuitpython was still very new and never tried it out again.

maiden trellis
stable forge
#

anyway, the voltage divider will work in for either

maiden trellis
#

hey, it's all good ๐Ÿ™‚

#

Since you're. a core contrib, is vscode the best way to get going with circuitpython?

muted gyro
maiden trellis
#

(for someone who is already using vscode for work / python)

stable forge
#

there is circuitpython plugin, I haven't tried it. Other good choices are Mu and pycharm.

maiden trellis
#

thanks @stable forge

stable forge
north stream
muted gyro
#

Definitely. At least if you're using tinyusb. I don't actually need it, it just seems kinda weird to me that it's not there. Though I guess most of the time if(Serial) is all you need

north stream
#

It would have saved some effort on a previous project of mine where the touch sensitivity varied depending on whether it was grounded (via USB) or not.

#

I do agree it's a little weird, but I guess the original Arduinos had a separate serial chip, so didn't have a way to check for USB enumeration. The USB native chips (32U4, M0, etc.) came later.

muted gyro
stable forge
muted gyro
#

I didn't even know there was a USBDevice object ๐Ÿ˜† ๐Ÿ‘ Thanks

stable forge
muted gyro
#

doesn't seem like there is (on RP2040 arduino-pico) according to the IDE2s auto-complete :/

stable forge
#

rp2040 is a different story -- it uses TinyUSB

muted gyro
#

oh right ๐Ÿ˜„

stable forge
#

The USBDevice thing is for 32u4, etc.

north stream
#

Basically a Circuit Playground on a stick with copper tape touch rings to control it, for drawing in the air with LEDs

muted gyro
#

๐Ÿฅณ

muted gyro
#
#include <tusb.h>
void setup() {
  pinMode(LED_BUILTIN, OUTPUT);
  digitalWrite(LED_BUILTIN,LOW);
  digitalWrite(LED_BUILTIN,HIGH);
}

void loop() {
  if(tud_ready()){
    digitalWrite(LED_BUILTIN, LOW);
    delay(50);
    digitalWrite(LED_BUILTIN, HIGH);
    delay(50);
  } else {
    digitalWrite(LED_BUILTIN, LOW);
    delay(500);
    digitalWrite(LED_BUILTIN, HIGH);
    delay(500);
  }
}

Hardware: Pico-W with earlephilhower/arduino-pico
USB-Stack-> Pico-SDK (default)
I'm not sure how safe it is to just call tinyusb functions in your sketch. Didn't test if this interferes with USB-HID or USB-Serial. Because (I assume) it's only a check and doesn't do anything, I assume it should be fine.
However this seems to work. Connected to PC: it blinks fast. Connected to Phone charger: blinks slowly

midnight sleet
#

When using TinyUSB, is there a way to detect when the file system is mounting?

dense yacht
#

Hi, im just switching from circuitpython too arduino and having some problems...

How do I define the pinouts for a feather v2?

#

I want to use SCK and A5

mortal ridge
#

About to loose my mind on this. I am trying to use the NRF24L01 modules for a SIMPLE turn thing on and off. However I am having no luck in getting them to connect. I have tried about 10 different tutorials and guides, multiple arduinos, changed the wires, changed teh NRF module, NOTHING IS WORKING. I have used these in the past with ease in about 3 other projects but cannot get this to work. Can someone help me go through and try to fix this with me.

#

Really anyone with any experience with a NRF24L01 would be amazing. I am just wondering if I am just missing something simple.

#

I have also used an arduino nano

dense yacht
#

Literally use "A5"

native kelp
#

not sure if i should ask here or somewhere else but when using ESP.Restart() to restart an esp32 board, does it do like a proper full restart or does stuff like the networking hardware retain their old state? im trying to figure out what i could do to make a full proper clean restart of the board from time to time

stable forge
native kelp
#

someone seemed to mention also abort() there too

#

welp i hope that ESP.Restart() will be fine enough

stable forge
#

i haven't heard about that. I'm not that familiar with the Arduino API

native kelp
#

i see

native kelp
#

ah, so it doesnt really reset the network interface stuff

#

got it

stable forge
#

double negative that 's a bit confusing

native kelp
#

ahhh, yeahh

#

that's what probably got me

midnight sleet
#

I have both Arduino SAMD boards and Adafruit SAMD boards installed and when I plug in the CPX it auto selects it through Arduino boards. Is there any way to have it auto select the Adafruit SAMD version so uploading a new TinyUSB sketch is less annoying?

stable forge
#

on Windows, the top-level directory will be Arduino15. I'm not sure where it is, but a websearch would tell you

old moat
#

I'm working with a Adafruit M0 Adaloggrer, right now trying to detect the SD card connected to the board

Thought this snippet should work to turn on/off the led depending on the card status

int button = 7;
int led = 13;

void setup() {
pinMode(led, OUTPUT);
pinMode(button, INPUT_PULLUP);
}

void loop() {
digitalWrite(led, digitalRead(button) == HIGH ? HIGH : LOW);
}

The card is connected to pin#13 according to adafruit document Adafruit Feather M0 Adalogger Created by lady ada
The LED is pin 7

LED is working
But it does not change state depending on card insertion status!!

Any tips?

north stream
#

Looks right to me. I suppose you could view the pin state via the serial monitor, or attempt to measure it, if there's a way to probe that signal on the board.

clear mulch
#

You mentioned the LED being pin 7 but in the above you have it as pin 13.

#

And the button with a pullup on 7.

old moat
#

ahh... need do check... think pin nunbers in code is right though

#

yeah... i think the pins are under the sd card socket on the board.. need to verify that too. though

clear mulch
#

https://learn.adafruit.com/adafruit-feather-m0-adalogger/pinouts

#7 - used as the MicroSD card CD (card detect) pin. If you want to detect when a card is inserted/removed, configure this pin as an input with a pullup. When the pin reads low (0V) then there is no card inserted. When the pin reads high, then a card is in place. It will not tell you if the card is valid, its just a mechanical switch

Yeah 7 looks right for the CD so code numbers are correct as you mentioned.

tawny veldt
#

You can also use the WDT (watchdog timer peripheral) in ESP32 instead. I prefer this method for resetting WiFi state on ESP32 arduino boards as I can set a timeout period (in case something hangs/stalls internally like I2C). We use this in production in the Adafruit WipperSnapper firmware. The Adafruit_SleepyDog Arduino library provides a very simple wrapper around the ESP32's function calls.

pallid grail
#

Guide feedback says the I2C scan demo doesn't show the second one.

#

Both are showing up on WIRE.

safe shell
#

I've found a few of those to be odd too. In theory, you could use D24/D25 as a secondary I2C on port0 (the primary / Stemma QT is on port1), so I think it's just making that a bit easier. But there are other pin combos you could use for a second I2c too.,

pallid grail
#

Running the demo and trying both options.

#

Uff.

#

That's a bit beyond this guide page.

leaden walrus
#

@pallid grail try with latest BSP release. there have been some changes to the i2c pin setup stuff. those __WIRE0__DEVICE defines are new-ish

#

i'lll test real quick also

pallid grail
#

This machine is brand new as of less than a month ago, I think. I didn't transfer anything, so Arduino was installed fresh in that timeframe.

#

I can see if there are updates, but I think I have the latest.

#

No updates.

#

I think I have the info I need for this guide page.

#

I also updated the serial screenshot because it was before the two WIREs were swapped.

leaden walrus
#

@pallid grail both work per those pins defines. need more info on what the confusion is.

pallid grail
#

This page is the "I2C Scan Test" template that goes into board guides. @leaden walrus It's not meant to handle other pin combinations. It uses the STEMMA QT port. I don't think there's any issue at this point. My confusion was stemming from the guide feedback. But I'm clear on it now.

leaden walrus
#

can you link to that template page

#

uses testbed

#

@pallid grail the philhower core behavior has changed w.r.t. i2c pins and resulting Wire. older original behavior was using any pins that were RP2040's I2C0 peripheral became Wire and pins using I2C1 peripheral became Wire1. so STEMMA QT on Feather RP2040 ended up being Wire1. but now the core allows mapping to either - that's what these lines are doing in that BSP pins files:

#define __WIRE0_DEVICE i2c1
#define __WIRE1_DEVICE i2c0

note the mix/match, i.e. Wire0 is RP2040's IC21, etc. that's the newer behavior.

#

so now STEMMA QT is Wire

#

but the testbed scanner should scan both

#

@pallid grail yah, guide needs updating in a few places. STEMMA QT is now Wire and Wire1 is on SDA=24, SCL=25

#

my serial output above had a BME280 (0x77) on STEMMA QT and a SGP40 (0x59) on 24/25

pallid grail
#

@leaden walrus Not sure I follow what on that page needs updating. The original is in the Metro ESP32-S2 guide, FWIW. That page isn't meant to handle extra pin combinations. It doesn't use the pins to begin with, it uses the STEMMA QT connector. If you think something should be tweaked, will you consider doing it? Because I don't understand how the rest of this applies. (AFKish for a while.)

leaden walrus
#

note that was done May of this year. so if you're looking at guide feedbacks older than that, those comments may or may not apply to the current setup

pallid grail
#

@leaden walrus I'm looking at all my guide feedbacks, and the only references to this are on that I2C Scan Test page.

#

Ok. I removed it entirely from the I2C Scan Test page, because as I said, it uses STEMMA QT only.

#

I will update the Pinouts page.

#

@leaden walrus Are Wire and Wire1 called "ports"? e.g, What does the Feather have two of?

leaden walrus
#

yah, ports

pallid grail
#

Thanks

#

@leaden walrus Is it Wire or WIRE?

leaden walrus
#

Wire

pallid grail
#

Thank you

leaden walrus
#

WIRE is a #def

#

and could be anything

#

#define MY_SUPER_COOL_I2C_PORT Wire

#

its just a name reference

pallid grail
#

Ah ok

leaden walrus
#

or like in the sketch on that page:

#define DEFAULT_I2C_PORT &Wire
pallid grail
#

I'm on the Pinouts page ๐Ÿ˜„ or I would have checked that

leaden walrus
#

yah, just Wire for that page

pallid grail
#

Added this to Pinouts under the Logic Pins header (down where it talks about I2C etc in CP). Is this sufficient?

#

I think the D24/5 designations are right, I grabbed that from the Philhower core PR.

leaden walrus
#
#define PIN_WIRE1_SDA  (24u)
#define PIN_WIRE1_SCL  (25u)
#

yep

#

The Arduino -> Arduino

pallid grail
#

I originally had "The Feather". Good catch.

#

@leaden walrus Thanks for yet again sticking with me through this! ๐Ÿ˜„

leaden walrus
#

@pallid grail np. thanks for updating!

modern seal
#

Does anyone here have history using the USR-ES1 ethernet module?

maiden trellis
#

Hi all. I have a weird one. Brand new Adafruit esp32-s2 feather (from digikey) and when I upload the battery state readout code from https://learn.adafruit.com/adafruit-esp32-s2-feather/lc709203-simple-data the output suggests that the battery voltage is 4.001v (or around that) and a battery percent of 99.9% even when there is no battery plugged in.

Plugging a battery in turns on the charge LED and after a reset the voltage reported is around 4v and the capacity drops to 88.4%. I believe those values are correct.

How is it possible that it is reporting voltage when there is no battery present? Is this "by design"? How would I programatically determine whether a battery is actually present?

Adafruit Learning System

Make your IoT project fly!

lyric pivot
#

Unfortunately you can't, the output of the charger is what's being measured there.

maiden trellis
#

@lyric pivot hmm, that makes sense I guess. But I've also noticed some oddities when reading off voltages when the device isn't plugged in via USB-C, specifically it occationally reports 0v. I need to dig to find out if that simply a failed i2c read, or is it actually a the chip reporting 0.

#

@lyric pivot do you just "know" that it's reporting the output of the charger or is that documented in the datasheet?

lyric pivot
#

Experienced similar issues in multiple other boards

#

Most of these linear chargers don't fully shut down when no battery is present

#

Some do pulse the output (visible as charge LED dimly blinking) but with any stray capacitance on the fuel gauge IC that can easily be filtered out to a low DC voltage

north stream
#

They'll tend to oscillate when no cell is connected, as they're designed to operate with a cell connected.

maiden trellis
#

Thanks both @lyric pivot @north stream

modern seal
#

Does anyone here have history using the USR-ES1 ethernet module?

pine bramble
#

im pretty sure i bricked my itsybitsy m4 twice, so i was messing around with compilar optmizations on my first board, it went into a state of only being in the boot mode, and not going to the run mode. After this I built a new fc and flashed my software with the compilar flags turned off im pretty sure and now its bricked again

#

do i need a SWD programmer to fix this

#

idk

#

i can still upload code to it and it goes through without a issue it just doesnt return to the run state

#

its constantly in boot mode

#

the uf2 thing still shows up

#

the cable is ok

#

im looking up similar issues on google and cant find anything

#

i think i have a fix ๐Ÿซฐ

#

when i drag the uf2 file to upload the bootloader in it just ejects and i get the same issue

#

the file said it updated so the board still works

#

weird

#

and now i cant even upload code to it anymore

modern seal
#

Does your itsybitsy have a reset jumper?

pine bramble
#

i press the button

#

it has a reset pin but thats connected to the button

modern seal
#

Gotcha gotcha. Had a similar upload issue with my Seeeduino XIAO... when the sketch uploaded, it compiled the code, re-mounted the XIAO as a mass storage device and replaced the uf2 file with the new one and reset it as normal.

#

It wouldn't switch to mass storage on its own, so I had to jump the reset contacts to force it to do-so.

pine bramble
#

hmm

modern seal
#

Wasn't sure if your itsybitsy did the same thing or not.

pine bramble
#

no its different than that

modern seal
#

Ah, that was my only guess. dang.

pine bramble
#

ok i fixxed it

#

it wasnt uploading becaue i had arduino open lol, flashing the new uf2 fixxed it let me try it on my old FC

#

This is me soldering the new fc today, nice to have a few extra on hand if I fry some so itโ€™s not a waste of time ๐Ÿ˜†

floral breach
#

I'm using the Adafruit Feather M4 CAN, with associated CANSAME5x library. I see in the lib that the CAN send is blocking?

#

Are there any hardware mailboxes I can have it populate instead?

#

Ah man there are Tx Buffers and a FIFO. Neither of which are configured -_-

mellow forge
#

I kinda need some help please, why does my esp32 give me this error code "E (178) psram: PSRAM ID read error: 0xffffffff"

#

thats the code I'm trying to run

#

for my rc car

#

I didn't write this code myself, this is from a tutorial

#
GitHub

This repository contains code and diagram for ESPNOW RC Car using esp32 - GitHub - un0038998/ESPNOW_Car: This repository contains code and diagram for ESPNOW RC Car using esp32

In this video we are going to make RC Car using ESPNOW Protocol.
We will use transmitter created using Analog joystick and esp32 board to send car control commands.
Transmitter and receiver esp32 modules will communicate using ESPNOW protocol.
Car will be controlled in 2 modes, simple movement and throttle+steering mode.

I have explained in det...

โ–ถ Play video
cedar mountain
mellow forge
#

I have these

#

I have no clue if they have PSRAM

cedar mountain
#

The listing says 4MB, which would imply PSRAM, but who knows if the listing is accurate.

mellow forge
#

there is no documentation either

#

I might just return them

#

but do you think these would work

mellow forge
cedar mountain
mellow forge
#

oh

#

thanks for the explanition

north stream
stark kindle
#

@cedar mountain I'd guess that 4MB in that listing is the flash size, not PSRAM

#

@mellow forge You shouldn't need PSRAM for that small a program. First guess is that in the Arduino IDE you chose a board with PSRAM, which is why it's complaining about not finding it. What board are you targeting the build for? the boards you linked to look like basic NodeMCU clones.

cedar mountain
stark kindle
plucky dune
#

Seems Iโ€™ve busted my little oled feather. All of the buttons and the reset button work but display itself wonโ€™t power. Any tips for troubleshooting or just get another?

dusk orchid
#

run something very basic, like the learn guide for that featherwing. How did you possibly kill it?

plucky dune
#

Honestly good question. I soldered the extension pins to the bottom feather because loose connection wasnโ€™t allowing it to work when stacked on the board. All solder tips have voltage. Iโ€™m gonna try some extra wires connecting the i2c pins

dusk orchid
#

maybe cleaning up the solder joints on the featherwing could save you. some of those connections in the image look iffy. You could try just wiping off excess on those that are blobby (use a clean-ish but tinned tip and warm the solder then wipe up the pin away from the board, then clean the tip again to remove that collected solder). Then apply a little extra, after warming the existing joint, to those that dont have a shiny joint all the way around the ring i.e. are not fully covering the rings.
Basically rewarm most of the solder connections, and re apply some solder if required (possibly removing some excess first/after).

mellow forge
#

for my code

#

well its not MY code but you get the point

#

it keeps giving me this error, PLEASE HALP:

E (181) ESPNOW: Peer interface is invalid
Failed to add peer

safe shell
#

you may need to set the peerInfo interface (e.g., peerInfo.ifidx = WIFI_IF_STA;)

mellow forge
#

ill try that rn

#

and ill get back to you when I do that

#

untill then, time to bash my head against my laptop untill stuff happens

stark kindle
mellow forge
#

esp32 dev module

#

sory, I hadnt understood the question, im a little dumb

stark kindle
mellow forge
#

ok well that fixed that issue, thank you for the help and clarification

safe shell
#

notthepotato, curious if you got the peer issue sorted

mellow forge
#

not by any stretch of imagination

#

I started last night at like 12:00

#

but then I passed out

maiden trellis
#

I've got an intermittent issue with an esp32-s2 feather. This is specifically to do with the i2c occasionally dying (nothing comes up from scans) but only intermittently, including sometimes an issue that persists through a hard power down and power up... Soooooo, Am I definitely dealing with faulty hardware or could this still be a software thing?

stable forge
#

what are the devices?

maiden trellis
#

The one is the onboard lipo charger and the other is the Adafruit SHT-45. So, hopefully not a tricky combo.

stable forge
maiden trellis
#

The LC7...

stable forge
#

the LC709203F can go to sleep and be hard to wake up. Recent versions of its library try to get around this.

#

When the hang occurs, could you measure the voltage on the SDA and SCL lines? One might be pulled low.

maiden trellis
#

I've read about (and tried) calling begin() repeatedly a few times to wake it up... So that doesn't fix it.... And I also lose the sht-45 so. ...

maiden trellis
stable forge
#

you could put the SHT-45 on a separate I2C bus, which might or might not help. (Might not help if the LC7 hangs up and you really need it.)

#

When I mentioned the libraries above, I was thinking of the CircuitPython library.

maiden trellis
#

I've read those posts too.

maiden trellis
#

I should probably just buy another board and test that below tearing my hair out.

stable forge
#

ESP32-S3 problems, specifically. ESP32-S2 has been much more reliable

#

the newer boards have the MAX sensor

#

is the SHT sensor close by or far away?

maiden trellis
#

5cm

stable forge
#

that should be fine

maiden trellis
#

I'll desolder the SHT and see if I can replicate without it.

safe urchin
livid osprey
#

Not sure if that was the answer you're looking for, but hopefully that helps?

safe urchin
#

#define TRINKET_PINx PINB is the pin B I am talking about

#

Seems like a macro for a macro but no idea what it is

safe urchin
#

Alrighty I got a bit more on rotary encoders figured out. Still didn't manage anything really with this encoder but oh well

weak olive
#

Hey, i have an led 64x32 display with a matrix m4 running arduino and im trying to use the imageReader library to display bmp files, However i cant seem to find a place to put them onto the m4 in order to run them. Could anyone please help me out with it.

north stream
weak olive
#

Ahh thank you so much, I had started to wonder if theres no real direct way considering no amount of search gave me answer.

dense cave
#

Hey, I've got a problem with a feather rp2040 usb a host. I'm starting with the dual role hid_device_report example, and as soon as I include the SD library, nothing else, it won't compile. I've played around a bit, and I've found that it will compile with 2 out of 3 of SD.h, pio_usb.h, Adafruit_TinyUSB.h but not all 3.

north stream
#

If it doesn't compile, there should be some sort of error message that might contain clues as to what's going on

dense cave
#

In file included from C:\Users\bradw\AppData\Local\Arduino15\packages\rp2040\hardware\rp2040\3.3.0\libraries\Adafruit_TinyUSB_Arduino\src/Adafruit_TinyUSB.h:78,
from C:\Users\bradw\sketchbook\library_test\library_test.ino:2:
C:\Users\bradw\AppData\Local\Arduino15\packages\rp2040\hardware\rp2040\3.3.0\libraries\Adafruit_TinyUSB_Arduino\src/arduino/msc/Adafruit_USBH_MSC.h:35:69: error: expected class-name before '{' token
35 | class Adafruit_USBH_MSC_BlockDevice : public FsBlockDeviceInterface {
| ^
Multiple libraries were found for "SD.h"
Used: C:\Users\bradw\AppData\Local\Arduino15\packages\rp2040\hardware\rp2040\3.3.0\libraries\SD
Not used: C:\Program Files (x86)\Arduino\libraries\SD
Multiple libraries were found for "SdFat.h"
Used: C:\Users\bradw\AppData\Local\Arduino15\packages\rp2040\hardware\rp2040\3.3.0\libraries\ESP8266SdFat
Not used: C:\Users\bradw\sketchbook\libraries\arduino_640327
exit status 1
Error compiling for board Adafruit Feather RP2040 USB Host.

gentle meteor
#

Is there a Sensor that can detect when I blow on it?

lethal yarrow
#

Barometric pressure sensors should be able to easily pick that up.

sour tide
#

or a microphone

lethal yarrow
#

Funny thing, in principle a microphone just senses rapid changes in pressure.

north stream
dense cave
north stream
#

I'm not sure in detail, in the past I've been known to either (ab)use #define statements to rename things, or like you said, go into the libraries and redefine things there.

dense cave
#

Okay, thanks for the help

floral breach
#

Is there an easy way to remove the CircuitPython bootloader from a Feather M4 Express?

safe shell
floral breach
safe shell
stable forge
# floral breach ๐Ÿค” hard to tell if this bootloader will let me avoid the whole UF2 file system j...

The bootloader acts as both a UF2 "fake drive" bootloader and a regular Arduino bootloader. Note that if the user program crashes, the detection of the 1200baud changeup, which puts the board into bootloader mode, will not work. (This is true of 32u4 boards like Leonardo as well -- the 1200baud detection is in software.) So you need to double-click reset. It is always fine to double-click reset to get into bootloader mode before uploading from Arduino. Make sure the Port is set correctly after double-clicking.

pine bramble
#

Hey Hi all, I am new to Arduino and starting with the "Adafruit QT Py - SAMD21 Dev Board with STEMMA QT" and following its Arduino start-up guide. When I try to install "Adafruit SAMD boards" and "Arduino SAMD boards" packages in Board Manager in arduino IDE, I get error as Error: 13 INTERNAL: Server responded with: 403 Forbidden and Error: 2 UNKNOWN: read tcp 10.122.168.169:58977->104.18.13.241:80: wsarecv: An existing connection was forcibly closed by the remote host. I tried by putting antivrus down and running the Arduino in administrator mode and also PC restart, it is not working, but I am able to download other board packages, could please help out ? Thanks in advance ๐Ÿ™‚

stable forge
pine bramble
#

yeah yeah

stable forge
# pine bramble yeah yeah

sometimes when you install a Java program like Arduino for the first time it asks permission to change some firewall settings for it

#

make sure the Preferences setting for the URL(s) is not messed up.

#

there maybe several comma-separated URL's in there. What country are you in?

whole dagger
#

Is there a way to write to the IO registers on a SAMD51 in a similar way to port manipulation on the Arduino Uno?

lethal yarrow
#

Yes, but the register names will be different.

#

Also there is probably more configuration.

whole dagger
#

I've seen some forum posts about finding the underlying code for the digitalWrite function, but I can't find where that code is on my computer

muted gyro
#

I'm just curious:
The RP2040 has alignment requirements. For example, a char can start at any address. An int16_t can only start at an address that is divisible by 2. An int32_t can only start at an adress that is divisible by 4.
Does this only apply to primitive data types like ints, char, float, etc?
Or does it also apply to custom classes I write?
For example if I had

struct foo{
char a;
char b;
char c;
}

would that struct have to be aligned in a specific way?

#

(I know the compiler handles this correctly. I'm just curious. And I think you can use that to really optimize memory usage)

#
struct foo{
  char a;
  char b;
  int32_t c;
};
...
Serial.println(sizeof(foo)); // 8

The fact that sizeof(foo) is 8 in this case and not sizeof(char)+sizeof(char)+sizeof(int32_t) is also caused by alignment, correct?

lilac ginkgo
#

yeah, that's almost for sure some alignment, you can maybe use __attribute__((packed)) to prevent it (perhaps other compilers flag that configuration in another way?)

muted gyro
#

great that you mention attribute packed because that's my next question! ๐Ÿ˜†

#
struct foo{
  char a;
  char b;
  int32_t c __attribute__ ((packed));
};
...
  Serial.println(sizeof(foo)); // 6
  foo foobar[10];
  foobar[0].c = 10;
  Serial.println(foobar[0].c); //10
  foobar[1].c = 11;
  Serial.println(foobar[1].c); //11
  Serial.println(sizeof(foobar)); //60

How does that work? Why does it work?

#

The int32_t inside foo can't be properly aligned on addresses that are divisible by 4 inside that foobar array. So I should not be able to directly work with those int32_t c.
But I can. What am I missing?

lilac ginkgo
#

why did you use the packed on a field of the struct on not thee struct itself? no idea what that would do tbh

muted gyro
lilac ginkgo
#

perhaps it works by the int saying "i dont mind about my own alignment" and the struct follows on that

muted gyro
#

yes but the int32_t inside that struct would still need to be 4-byte aligned, not?

lilac ginkgo
#

i dont think so

muted gyro
#

why?

#

I recently did some casting of charArray[] (in flash) to int32_t and the char-Array was aligned wrong, so the char I tried to cast to int32_t wasn't aligned on a 4-byte address and it crashed the RP2040

lilac ginkgo
#

AFAIK
the aligment is basically that processors can only read memory starting in addresses that are multiples of (lets say) 16.
if your data is not aligned, the processor will need to strip some data out of the region it read and whatnot, to read your actual information
so alignment speeds up reading information, at the cost of taking more spaces, depending on the use case you may or may not want it

muted gyro
#

but why can I, in this case with attribute ((packed)), use the int32_t. That's what I don't understand

#

yes. But afaik, on the RP2040 alignment is enforced. Wrong alignment = hard crash

lilac ginkgo
#

i ran into a similar issue actually... it's an issue/bug with M0 iirc (someone helped me identify that on QMK server)

muted gyro
lilac ginkgo
muted gyro
#

great to see that I'm not alone and you had basically the exact same issue as I ๐Ÿ˜†

lilac ginkgo
muted gyro
#

i tried reading an address (which was originally u8) as int32 and it hardfaulted

lilac ginkgo
#

welcome to the club

#

i ran insane on it, because my data was coming over a custom HID endpoint, from a custom program of mine running on the PC (this code runs on the keyboard), and i thought about issues anywhere but the casting ๐Ÿคฃ

muted gyro
#

i ran insane on it, because the wrong alignment depended on how long the text inside a Serial.println() was. Serial.println("sta") = by chance the charArray was aligned correctly.
Serial.println("starting") = charArray aligned wrong. ๐Ÿ˜‚

lilac ginkgo
muted gyro
#

๐Ÿ˜‚

muted gyro
# muted gyro ```cpp struct foo{ char a; char b; int32_t c __attribute__ ((packed)); }; ...

but here in this array, it's not possible that all int32_t c are aligned on a divisible-by-4-byte address. *
So why does accessing int32_t c there work?
But casting a char on a not-divisible-by-4-adress to int32_t doesn't work.
Does the compiler add some extra instruction to that foo struct? ๐Ÿค” Like "to access int32t_c first copy the 4 bytes to a different address in ram and then use them as int32_t"?

#

(* afaik gaps in arrays are not allowed so it can't have gaps in the array so that all int32_t c are aligned on divisible-by-4-byte-addresses)

lilac ginkgo
#

i guess C compiler is smart enough to know that you have unaligned data on your structs and treat it properly (no idea how), but it has no clue about a random pointer being casted

muted gyro
#

yeah, that sounds like the most likely thing to me

stark kindle
muted gyro
#

build_flags = -Wall -Wextra -Og

stark kindle
#

If you want to find out exactly what's going on you can have the compiler generate assembly code and read that to find out. You should se that the packed version is using more instructions to manipualte the same data.

muted gyro
#

now, I'm not sure why I had to make the foo finside the loop volatile. Without making it volatile it was always 0ms, so I think it optimized the entire loop away. But I thought -0g would already prevent the compiler from "optimizing something away completely"

muted gyro
stark kindle
#

Try the -S option on build_flags (not 100% certain here but that's usually how GCC works)

stark kindle
#

volatile told the compiler it couldn't do those optimizations

lilac ginkgo
#

from https://godbolt.org (with/out the packed)

sample code used: ```c
typedef struct {
char a;
int b;
} Foo;

int main() {
Foo foo = {'a', 42};
return foo.b;
}

#

dont ask me what's going on there, please ๐Ÿ˜›

stark kindle
muted gyro
muted gyro
muted gyro
#

very nice. It also lets me see exactly which compiler options were active for each file

#

(verbose build, only shows which compiler options were set using the CLI command to run the compiler. But something like -Wall actually enables a bunch of options)

stark kindle
muted gyro
#

there are so many rabbit holes to jump into ๐Ÿ˜†

stark kindle
muted gyro
# lilac ginkgo from <https://godbolt.org> (with/out the packed) sample code used: ```c typede...

now just one more question, if you know the answer ๐Ÿ˜„
Obviously here, the compiler knows that the int32_t might not be correctly aligned. And it generates specific code that can handle that.
If I'm doing a typecast from for example int8_t to int32_t, is there a way for me to tell the compiler, that it might not be alligned properly, so that it generates this specific "handles unaligned int32_t" code there as well?

lilac ginkgo
#

I dont think so, just use a memcpy

#
myStruct dummy;
memcpy(&dummy, raw, sizeof(myStruct));

dummy.field;
muted gyro
#

๐Ÿ‘ I'm just curious if there are other ways to solve this issue ๐Ÿ˜„

#

not saying that your solution is bad

#

just curious ๐Ÿ˜„

#

Anyway. Thank you so much @lilac ginkgo @stark kindle Very interesting stuff, learned a lot

north stream
muted gyro
#

(no more questions for today. Just some note:

void clean_up(int* f){
  Serial.println("Variable went out of scope");
}
void setup() {
  Serial.begin();
  while (!Serial);
  delay(1000);
  int a __attribute__ ((cleanup(clean_up)));
  a = 10;
  Serial.println(a);
}
void loop() {}

There is a whole new world out there! ๐Ÿ˜„)
I bet you can mess up a lot with these attributes

stark kindle
floral breach
stark kindle
floral breach
lilac ginkgo
#

I mean, you were not manually creating data, but casting something coming from elsewhere, right?

pine bramble
muted gyro
#

Well that was the problem I actually had. All the other stuff around packing, etc was just curiousity. Not sure how I will use that ๐Ÿ˜†

lilac ginkgo
#

That code is just the data in an array of u8, not casting anything yet

#

Problem comes at the time of consuming it

muted gyro
#

Yes of course

lilac ginkgo
#

I was curious about such consumption

#

Adding alignment to the array maybe made it quite bigger?

muted gyro
#
#include <Arduino.h>
#include <I2S.h>
#include <StarWars30.h>

long sampleRate = 22050;
I2S i2s = I2S(OUTPUT);

void setup() {
  pinMode(LED_BUILTIN, OUTPUT);
  digitalWrite(LED_BUILTIN, LOW);
  i2s.setBCLK(26);  // WS = 27
  i2s.setDATA(28);
  i2s.setBitsPerSample(16);
  i2s.setBuffers(4, 64);
  Serial.begin();
  while (!Serial);
  delay(1000);
  Serial.println("Starting");//comment this line to make playback work.
  if (!i2s.begin(sampleRate)) {
    digitalWrite(LED_BUILTIN, HIGH);
    while (true);
  }
}

void loop() {
  const unsigned char *ptr = StarWars30_raw;
  unsigned int toPlay = StarWars30_raw_len;
  while (toPlay > 10) {
    //===Make the track stereo and quieter
    int16_t frame[2];
    frame[0] = (*(int16_t *)ptr) / 16;
    frame[1] = (*(int16_t *)ptr) / 16;
    //===Write one L+R sample to I2S
    if (!i2s.write16(frame[0], frame[1])) {
      digitalWrite(LED_BUILTIN, HIGH);
    }
    toPlay -= 2;
    ptr += 2;
  }
  //===END
  i2s.end();
}
#

though tbh, yes, could have also solved it in code by first moving the bytes to RAM

#

This was actually a test sketch I very quickly wrote to test I2S

lilac ginkgo
#

Move to RAM? RP stores const data there too afaik

#

AVR's PROGMEM is another whole world

muted gyro
#

not sure really ๐Ÿค”
I mean taking 4 bytes moving to RAM, so that they start at a divisible-by-4 address and then do the casting

lilac ginkgo
#

Whatever, it works already :p

muted gyro
#

that char Array took I think 80% of my Flash. Definitely didn't fit into RAM

muted gyro
#

And I learned a lot

muted gyro
#

30 seconds 16 bit per sample, 22050 sample rate, mono, wav file (without header)

#

not sure what the original file size was

#

1,3MB I guess

muted gyro
#

i've heard the word before but I have no idea what it is ๐Ÿ˜†

#

oh wow that's an interesting thing

#

make a union that can hold 4 char or 1 int32. That ensures that the first char is properly aligned that a cast to in32 works? Is that how union is relevant here?

north stream
#

Yes, that's well put, and what I was getting at.

#

And since it's a union, you don't have to cast it, the type alias is "already there"

pine bramble
#

Hello,

#

i bought a brand new itsy bitsy 5v.
I can't upload any code on it

#

i tried to restart ide/computer i also checked the permissions (im using linux)
but i cant find the solution

north stream
#

The root error isn't in that screen shot.

pine bramble
#

sorry about that

pine bramble
#

<@&617066238840930324>

stable forge
dusk orchid
#

anyone got an rp2040 and come accross missing functions from stdlib like `ltoa' and 'ultoa' when building in arduino ide?

floral breach
#

libstdc++ that ships with Arduino is often hacked to pieces. Although I would expect C lib functions to be there...

dusk orchid
#

it has itoa and utoa but not the long variants

#

throwing errors compiling adafruit io arduino library for the rp2040 wiznet W5500-EVB-PICO.
I feel silly hacking it about to compile, so thought I'd shout the brain-trust

#

from the pico sdk help file.

north stream
dusk orchid
#

arduino arm mbed os rp2040 latest

#

with pico sdk installed separately following the rp2040 vscode instructions

north stream
dusk orchid
#

brilliant, thanks.

muted gyro
north stream
#

It does depend on how it's laid out in memory, in both cases, which gets into issues of endianness and packing.

muted gyro
#

๐Ÿ‘ Thanks

#

so code wouldn't be truly crossplatform

north stream
#

If you need guaranteed functionality across multiple architectures, you're probably stuck explicitly masking and shifting. However, if you're implementing on a known architecture, you can look at the layout and determine what's going to happen.

muted gyro
#

explicitly masking and shifting... that would be additional instructions = worse performance than just cast and pray, right? ๐Ÿ˜„

north stream
#

Right. Although modern architectures (ARM, PPC, etc.) are very fast at it, it still takes a few clocks to execute uint32_t y = (uint32_t) x[0] << 24 | (uint32_t) x[1] << 16 | (uint32_t) x[2] << 8 | (uint32_t) x[3] << 0;

#

Unless the compiler/optimizer figures out what you have in mind and realizes the current architecture will let you accomplish the same thing in zero clocks by register renaming.

#

You'll see a lot of this in networking code since the network byte order is standardized, and processor architectures vary

muted gyro
#

very interesting

#

(uint32_t) x[0] isn't that part already "sus"? What exactly is happening here?
Does that only cast the single byte/char at x[0] to uint32_t and fills the rest with zeros? Doesn't it also take x[0], x[1], x[2] and x[3] and "combines them together" to an int32_t?

north stream
#

Yes, the << 0 doesn't do anything, the compiler won't generate any code for that operation

#

Fortunately, the language specification explicitly defines what happens when an 8-bit value is cast to a 32-bit value (although it does depend on whether either or both of them are signed or unsigned, surprise)

#

So 0x80 might become 0xffffff80 due to sign extension

muted gyro
#

In my code I basically had

char array[4];
int32_t b = (int32_t) *array;

and that took all four bytes from the array

north stream
#

Which is why I generally use unsigned variable types when doing bit manipulations

#

Yup, that will work, but. If the array contains [ 0x01, 0x02, 0x03, 0x04 ], b might end up as 0x01020304 on one architecture and 0x04030201 on another (and 0x02010403 on a VAX)

muted gyro
#

I see

muted gyro
#

(to actually always get the correct result, you have to cast the uint32 and int32 to int64)

north stream
#

Yes, you have to cast at least one of the operands to 64 bits first. And multiplying unsigned by signed can be squirrely as well

muted gyro
#

but funny thing is, for int32 = uint16 * int16 that doesn't apply. I think because, since RP2040 is a 32-bit architecture it does all "less than 32 bit" operations as 32 bit actually

north stream
#

There are performance considerations to different platforms as well. On a 32-bit CPU, storing a boolean in 32 bits is faster, since it doesn't have to promote a byte to a word before testing it. On an 8-bit CPU, storing a boolean in 32-bits is slower, as it has to check them 8 bits at a time.

#

Weirdly, an int on an 8-bit Arduino is 16 bits

muted gyro
#

Related question... does typecasting or static_cast<>() actually always result in any machine code? Or is that (sometimes) just for the compiler?
I mean uint32_t and int32_t are exactly the same bits, just interpreted differently.
But if I typecast from int8_t to int32_t it has do actually do something and fill the rest with zeros or sign extension, right?

north stream
#

In a lot of cases, there will be no generated code for the operation. But in some cases there will

#

And in some cases, the compiler just keeps track of the given type, and conditions later operations on it. If you cast int8_t to int32_t and then do an AND with 0x00000001, the sign extension would have been superfluous, and many compilers will omit that step.

#

Note that many modern architectures support that sort of thing anyway, so on ARM64, the LDRB instruction will load a byte and sign extend in a single operation.

#

Oops, LDRB zero extends, it's the LDRSB instruction that sign extends

muted gyro
#

compilers are such a black magic ๐Ÿ˜†

#

Thank you so much

sage lichen
#

Hey guys, trying to pair with a HC-05 bluetooth module from my computer. I already set the device mode & name using the at commands. It is now in pairing mode (I think) bc the led is flashing rapidly, but I am unable to discover the device on either my computer or my phone

winter python
#

Hello guys, I am trying to include a header file from library and when I was compiling it, it says no such file or directory.

#

I was working on Linux system, and first time run this code on WIndows.

#

I didn't change code , and it was working on Linux.

#

Also from the example, I can find the example the the LMP91000 library.

#

I think the library is installed properly, but some other reason prevent the compiler from find the file. Can anyone help me with this?

north stream
#

Look in arduino/libraries for it and see if the file is there or in an "include" subdirectory

winter python
#

the file is in the subdirctory "LMP91000" of directory "libraries".

#

Sorry I am not sure is it what you mean

north stream
#

The LMP91000.h file the compiler is complaining about, is it present in that directory?

winter python
#

yes

north stream
#

So it could be an include path problem. One thing that may or may not work (I admit I haven't bothered to research why) is to change <LMP91000.h> to "LMP91000.h" (basically quotes instead of <>) in the include statement.

winter python
#

Still doesn't work. But the wired thing is the compilier can locate some other file

#

Not sure why this happen

north stream
#

Yeah, you're in the Twilight Zone. Could be weird case problems, something randomly gone off into the weeds (maybe try a reboot), aliasing, etc.

hard whale
#

Is there a reason why a falling interrupt would fail to fire on a pin while high, rising, and low seem to work appropriately? And I am seeing falling edges on a scope

#

On a feather m0

lethal yarrow
#

How fast of a pulse are we talking?

hard whale
#

I'm trying to get interrupts from a bno085 - it's pretty fast, I think

#

I've tried a few pins and no joy

lethal yarrow
#

You have a scope, can you measure the pulse width?

hard whale
#

they're variable but on the order of hundreds of micro to a few milliseconds

lethal yarrow
#

That shouldn't be a problem.

north stream
#

You can often set which edges an interrupt pin should respond to

hard whale
#

Oh, ok, I just figured this out - and it's a pretty dumb one

#

I added a serial print in the isrs to debug and I think the printing for the rising isr was masking the falling isr.

#

So that's fun

north stream
#

Oh yeah, printing in ISRs is problematic

hard whale
#

I am very inexperienced, if you can't tell

#

Didn't realize how slow it would be

safe shell
#

you can set a flag in the ISR, and check the flag and print outside the ISR

#

ISR should be as simple and fast as possible

hard whale
#

Yeah, that's how I have the actual code implemented. I was just struggling to get the falling one to fire seemingly

hard whale
#

Hm. Ok, here's another (probably simple) question:

#

The interrupt should be active low. It seems to have this brief low voltage which I think is causing some issues

#

Excuse the crappy image

#

it's a few microseconds in duration

#

I am also RTFM for the chip