Receiving data to pure data/Max MSP

Hey,

I am currently working on a project in which I intend to use accelerometers or IMU’s (whichever is best) attached to the arms of a pendulum in order to receive a stream of data, which is taken from tracking the movement of the arms of the pendulum. I then wish to use this data in order to modulate sounds I have created in ableton via either pure data or Max MSP.

So, as I am relatively new to all this, I could do with some help choosing the right accelerometers for the job.

Ideally this needs to be wireless as I feel the wires may get tangled with the movement of the arms.

Hi saxon.

Unfortunately we don’t carry any wireless accelerometers or IMUs, but we do have quit a few wired ones. I think for your application just an accelerometer would probably work just fine.

You might have a look at our [SparkFun Triple Axis Accelerometer Breakout - MMA8452Q as a good place to start. Using that along with a [RedBoard Qwiic and a [Qwiic cable should get you started gathering data.

You might want to have a read through the [MMA8452Q Hookup Guide to get an idea what you need to do as far as hardware setup and programming to start getting data from the accelerometer. Once you have things working the way you want, then you could start looking for ways to make the accelerometer wireless.](https://learn.sparkfun.com/tutorials/qwiic-accelerometer-mma8452q-hookup-guide)](https://www.sparkfun.com/products/14429)](SparkFun RedBoard Qwiic - DEV-15123 - SparkFun Electronics)](https://www.sparkfun.com/products/14587)

Thanks, if I was to have a couple of the accelerometers would I need another redboard for each extra one, or would they be able to run from the same one if serving similar functions?

also, Could you give me an insight into what sort of methods there are to make the accelerometer wireless?

if I was to have a couple of the accelerometers would I need another redboard for each extra one, or would they be able to run from the same one if serving similar functions?

It depends on the type of accelerometer you're using how it's done, but generally yes, you can use more than one on the same RedBoard/Arduino. It would take changes to the code to add more than one though.

also, Could you give me an insight into what sort of methods there are to make the accelerometer wireless?

You could use a [microcontroller that has a radio built in, or you could add a [radio or even [Bluetooth to an existing micro controller. Keep in mind that adding parts will require you to do some electronics construction and will also require you to write your own software to make everything work. Unfortunately it’s not as easy as just plugging things together and having everything just work.](https://www.sparkfun.com/products/12576)](XBee 3 Module - PCB Antenna - WRL-15126 - SparkFun Electronics)](https://www.sparkfun.com/products/13711)

One way to go wireless is to use a Raspberry Pi ZeroW, the remote feature of pigpio to bridge to the board serial of an Arduino board. This allows serial over a LAN connection (or I2C, SPI). I have done I2C, serial and PWM whis way.

I am a mechanic not a programmer but I do have functioning code I will share.

Dale

TS-Chris:

if I was to have a couple of the accelerometers would I need another redboard for each extra one, or would they be able to run from the same one if serving similar functions?

It depends on the type of accelerometer you're using how it's done, but generally yes, you can use more than one on the same RedBoard/Arduino. It would take changes to the code to add more than one though.

also, Could you give me an insight into what sort of methods there are to make the accelerometer wireless?

You could use a [microcontroller that has a radio built in, or you could add a [radio or even [Bluetooth to an existing micro controller. Keep in mind that adding parts will require you to do some electronics construction and will also require you to write your own software to make everything work. Unfortunately it’s not as easy as just plugging things together and having everything just work.
[/quote]

Okay, good to know. So now I’m thinking I could have two accelerometers each attached to an arduino/redboard. Would the arduino then be able to communicate to my computer wirelessely or would it involve more wires?](https://www.sparkfun.com/products/12576)](XBee 3 Module - PCB Antenna - WRL-15126 - SparkFun Electronics)](https://www.sparkfun.com/products/13711)

tech-mech:
One way to go wireless is to use a Raspberry Pi ZeroW, the remote feature of pigpio to bridge to the board serial of an Arduino board. This allows serial over a LAN connection (or I2C, SPI). I have done I2C, serial and PWM whis way.

I am a mechanic not a programmer but I do have functioning code I will share.

Dale

Thanks, I’ll look into it. If you could share the functioning code that would be great.

Would the arduino then be able to communicate to my computer wirelessely or would it involve more wires?

Unless you’re using an Arduino that has built in wireless, you’d need to add some sort of wireless module to tha Arduino.

This is Python 3 serial communication test code. If I remember correctly the Python pigpio module will run on Windows and Mac as long as the target is a Raspberry Pi. On the Raspberry Pi you need to run sudo pigpiod from a command prompt.

'''
# Serial test  by Dale Bartel
# In terminal on remote execute sudo pigpiod

# Comment out either local or remote
# Uncomment an ipAdrs to use remote
'''

import pigpio

ipAdrs = ('XXX.XXX.XXX.XXX')  # Use a real IP address

port = 8888                   # 8888 is default

pi = pigpio.pi(ipAdrs, port)  # For remote use

#pi = pigpio.pi()              # For local use

# Define the communication port
#tty_port = '/dev/ttyS0'       # For mini UART, boards with Bluetooth
tty_port = '/dev/ttyAMA0'     # For PL011, boards without Bluetooth

baud_rate = 115200

com_port = pi.serial_open(tty_port, baud_rate)  # Create pigpio UART port

# Loop
try:
    while True:
        dataRdy = pi.serial_data_available(com_port)
        if dataRdy > 0:
            (byteCnt , byteArray) = pi.serial_read(com_port, dataRdy)
            receivedString = str(byteArray, encoding = 'utf-8', )
            print(receivedString)
        inputString = input('> ')
        pi.serial_write(com_port, inputString)

except KeyboardInterrupt:  # Keyboard CTRL c, Shut down serial and close
    pi.serial_close(com_port)
    pi.stop()

Check out http://abyz.me.uk/rpi/pigpio/ for much more info.

Dale