I'll explain what I'm broadly trying to do first, to give context to the questions that follow.
What I would like to do is to send accelerometer data from two Arduino 33 BLEs to be read by a puredata patch on a computer. Because there's no obvious way to send the BLE data to puredata, my plan is to receive the accelerometer data over BLE with a third arduino connected via USB to the computer.
I was successful in getting accelerometer data (using the serial protocol) to PD, so I'm confident with that bit.
Conceptually, what I'm thinking is to have a sketch on the "central" arduino (the one connected to the computer) that connects to a a service on the peripheral arduino, and pass on that data to the computer.
Questions:
what would be good examples for me to start from? I should imagine that there are some relatively close examples. I have found “Connecting Nano 33 BLE Devices over Bluetooth”, but I'm not clear on how to modify it because it sends the data from the central to the peripheral rather than the other way around.
What would be the mechanism by which my "central" receives BLE using serial and sends to the computer also with Serial? In other words, if
"Serial.begin(9600);"
opens the "default" (?) serial connection, how do I open both one for BLE (for the peripheral) and one for serial-over-USB (for the computer)?
google says " Pure Data is an open source visual programming environment". presumably this is what runs on your PC.
does it support any particular protocols or is is just a serial interface that expects ASCII strings?
how are the various devices connected. they can't all be connected to the same serial ports with something like RS-485 interfaces which support half-duplex communication over a shared pair of wires. but sharing an interface generally requires prefixing each packet with a device address.
Yes, Pure Data is a visual programming environment for sound. In PD programmes, I can connect to an arduino connected to USB using the "comport" object, which is serial terminal-type communication object. Once a connection is open it receives every byte received. With a single arduino connected with USB that works perfectly. ASCII strings work well.
how are the various devices connected. they can't all be connected to the same serial ports with something like RS-485 interfaces which support half-duplex communication over a shared pair of wires. but sharing an interface generally requires prefixing each packet with a device address.
I don't really understand what that question means. I don't know what RS-485 refers to.
What I'm trying to do is have a single Arduino Nano 33 BLE (the "central") connected to the computer via USB (with a USB-micro to USB-C lead to the computer), and for that Nano 33 BLE to subscribe via BLE to a custom service on another Nano 33 BLE (the "peripheral"). The only physical connection will be the the USB connection between the "central" arduino and the computer.
but sharing an interface generally requires prefixing each packet with a device address.
I have no idea what that means. I don't know what you mean by "sharing an interface", now what you mean by packet, or "device address". Can you please clarify?
"interface" generally mean the external connections of some electronic device. this may be pins on a device or board.
the serial interface is one type of interface. PCs today use USB interface to support that type of interface. in the past it has been RS-232. there is a chip on Arduinos that translate the USB signals to the TX and RX pins (1 & 2) on an Arduino for the serial interface on the Avr chip.
by packet, i meant the buddle of information sent between the nano and PC. i guess there's a distinction between packet, frame, record or just a string of ASCII characters.
you can't connect more that one device to the RX pins of a serial interface. in generally you can't connect more that 1 active output to an input without corrupting the data from the other output.
RS-485 is an interface that support half-duplex communication, where only one device transmits at a time. the arudino, would enable its transmitter while transmitting and disable it when transmission completes. there is a protocol (e.g polling) for when it is allowed to transmit. this mechanism allow many devices to share the pair of wire connecting them the RS-485 see the diagram at the bottom of pg 7 of the max485 datasheet
when sending "packet" of information to specific devices over a shared interface (pair of wires), there is typically an address in the packet indicating the device the information is intended for
I think if you study the linked example carefully, you should be able to work out how to send data via BLE from the sensor Nano to the central Nano. You will have to make major modifications to the example code anyway, so just consider the "central" Nano to be the peripheral, and vice versa.
Make sure to get that example working as presented, and that it is well understood before proceeding.
Just use Serial.print to send the data to the PC. If you need it, the Nano 33 BLE has a second serial port, called Serial1.