Jewelry Sound Instrument

Hi! I'm working on a project in collaboration with jewelry design. We want to use two accelerometers to track a dancer's arms. We are using MMA8452Q accelerometers. For now we are trying to make one work.

The idea is to have the data from the accelerometers go to Pure Data, where the artist can select the sound he/she likes the best (the sound part is already covered in PD). The problem I have is I don't understand much on how the arduino is getting the data from the accelerometer. So far I get the values in the serial monitor, but I have to send that to PD (for which we will add a wifi module, since the idea is the dancer to move freely).

My question is, how do I send the data to PD? from what I can see in the example, provided by sparkfun, what is being printed is:

xdata "/t" (I understand that part in the code as a space) ydata "/t" zdata

In my interpretation that is not creating an array of the data is sending one by one separated by a space. Here comes my question, how do I create an array with the x,y,z data? How is it sent (ASCII, char, float...)?

I will really appreciate any possible help, thank you!

A.

By the way, how do I connect the other accelerometer? On the example they don't specify inputs or how to treat more than one.

I assume you know what an I2C bus is. It seems that you can set the device to two different addresses. From the datasheet: "I2C 7-bit address = 0x1C (SA0 = 0), 0x1D (SA0 = 1)"

What example.

"for which we will add a wifi module" Why not use a WiFi enabled Arduino directly, like the WeMos D1 mini (and others). Leo..

Yes, I'm getting an arduino due, since the uno only offers one connection. I didn't know about the wemos, but thanks for the info. I was recommended the arduino due and a wifi shield.

The example is the one from the library of the accelerometer that you find at sparkfun. I'm understanding it a bit better. My concern right now is to communicate Arduino with pure data. Would I be able to transmit it through wifi from the arduino?

solaris92: Yes, I'm getting an arduino due, since the uno only offers one connection. I didn't know about the wemos, but thanks for the info. I was recommended the arduino due and a wifi shield.

The example is the one from the library of the accelerometer that you find at sparkfun. I'm understanding it a bit better. My concern right now is to communicate Arduino with pure data. Would I be able to transmit it through wifi from the arduino?

I2C is a bus. Can have up to 127 devices connected to the same two pins, as long as they have different addresses.

A Due + WiFi shield would be harder to set up, and a shipload more expensive than a ~$4 WeMos. A WeMos D1 could fit in a matchbox, so easier to carry by the dancer. There are also ESP8266 Arduinos with LiPo battery connection and/or charger.

Split the project in two. 1) Reading sensor(s) and displaying the data on the serial monitor. 2) Setting up a WiFi link. If you understand both, then combine the two.

Beginner's guide to the ESP8266. Leo..

How do I assign the addresses for the I2C? Does this mean I can use an UNO and just assign a different address for each sensor?

I have never use wemos, is this similar to the uno or mega?

I am already reading data and printing it on the serial monitor, but only one. I still have to connect the other one which I just got in.

I am getting an ESP8266 to connect to the UNO I have, that should be this weekend.

The other part of this is sending the data to pure data. I did that with the accelerometer I already have in place, but is not getting the same data I saw on the serial monitor.

Thanks for the link!

Ana

Never used those sensors, but yes. Some sensors can be set to different addresses by connecting a chip select pin to VCC or ground.

A Wemos D1 mini is one of many all-in-one ESP8266 based boards. Nothing else needed (well, maybe a micro USB lead). It's ESP8266 WiFi chip can be programmed directly with the Arduino IDE. One drawback could be fewer I/O pins, but you only need two for I2C.

An Uno + bare ESP8266 module (ESP-01) is clumsy, and much more difficult to connect and program. Beware that you can't blindly connect 3.3volt devices to 5volt devices. Leo..

Advantage WeMOS/NodeMCU: those operate at 3.3V (instead of the 5V levels of the Arduinos).

It doesn't sound like you need that many outputs, but you do want WiFi, making the ESP8266 based boards a natural fit for your project.

Wawa: Never used those sensors, but yes. Some sensors can be set to different addresses by connecting a chip select pin to VCC or ground.

A Wemos D1 mini is one of many all-in-one ESP8266 based boards. Nothing else needed (well, maybe a micro USB lead). It's ESP8266 WiFi chip can be programmed directly with the Arduino IDE. One drawback could be fewer I/O pins, but you only need two for I2C.

An Uno + bare ESP8266 module (ESP-01) is clumsy, and much more difficult to connect and program. Beware that you can't blindly connect 3.3volt devices to 5volt devices. Leo..

I looked at the demos and I like it. I think I'll be getting one. I'm getting the ESP8266 by saturday, so I can try and program how the communication with pure data can go. You are right, I only need two for I2C, and one thing I liked about the wemos is that the SA0 inputs are labeled in the board.

I am aware of the connection between 3.3V devices to 5V, but thank you for the reminder, I appreciate it.

wvmarle: Advantage WeMOS/NodeMCU: those operate at 3.3V (instead of the 5V levels of the Arduinos).

It doesn't sound like you need that many outputs, but you do want WiFi, making the ESP8266 based boards a natural fit for your project.

You are right. To be honest what's been giving me more trouble is sending the data to Pure Data. There is something there, but is not changing when I move the accelerometer. It looks to me like random data. Looking at my code I see that I am not mapping the values from the accelerometer... maybe that is why?

That sound like a problem to me indeed.

wvmarle:
That sound like a problem to me indeed.

I’m starting to thing that that’s one of the big issues I’m having. I forgot about mapping until now. I’ll do it, and keep you posted.

Thank you! you helped me a lot in understanding more about this! :slight_smile:

You basically can not track an arm position using an accelerometer, that is why your numbers look like random ones.

To communicate with PD from the WI-Fi send the data as OSC packages.

I know, sorry the way I described it that would be the interpretation. Is more about the movement of her arms than her position. The data that I'm getting right now only oscillates between 2 values, even though I'm drastically moving the accelerometer.

Thank you for that info! If I'm correct I'll need mrpeach library, right?

If I'm correct I'll need mrpeach library, right

Not familiar with that one.

What are the two values you get? Probably time to post your code and schematic.

I'll most definitely will. I'll do it by tomorrow night since I can't right now. Also, I don't have the wifi shield yet, so it'll be through serial port.

Thank you for your help!

I sat down during the weekend and followed the ideas on this forum. I am now sending the values from Arduino to Pure data through Serial port. As promised, here is my code:

#include <Wire.h> // I include Wire library for I2C protocol
#include <SparkFun_MMA8452Q.h> // I include the accel library

/* Begin using the library by creating an instance of the accel class. */

MMA8452Q SOL;

/* Setup function simply starts serial and initializes the accel */

/* I declare the variables */

int x;
int y;
int z;

void setup(){

Serial.begin(9600); /* I start the serial */
//Serial.println(“MMA8452Q TESTO”);

SOL.init(SCALE_4G, ODR_12); /* Initialize the accelerometer */

}

void loop(){

if (SOL.available()){

SOL.read(); /Read the new variables/

printAccels(); /Print digital readings/

}

Serial.write(x); /Serial port send/

}

void printAccels(){

x = SOL.cx*100; // Calculated acceleration values in units of g’s. I multiply x 100 to get audible data in pd

if ((x <= -8)&&(x >=-10 )){ // Values when not moving

x = 0;

}

}

/*************************************************************************

I am just sending the x value. Tried y and z and it works. Thank you so much for your help! I just got the ESP8266, so I’ll give that a go while wemos arrives. I’ll keep you posted. :slight_smile: