Integration Adafruit MMA8451

Moderators: mdrjr, odroid

Integration Adafruit MMA8451

Unread postby Tinkerpete » Tue Oct 30, 2018 6:32 am

Hello everybody,

i try to integrate the MMA 8451 Acceleration Sensor in Odroid-Go. But i have no luck. Has anybody a example for me? I have tried with the adafruit example, but it seems it did not start the sensor. I have tried to add 'Wire.begin (15, 4)', but did also not work. I have add '#include <odroid_go.h>' but it comes to compile problems. I have seen, that Odroid have own 'cpp' and 'h' files for certain sensors in his library directory. But what must i change in the adafruit libraries fpr working MMA 8451?

Thomas
Tinkerpete
 
Posts: 19
Joined: Tue Oct 16, 2018 3:46 pm
languages_spoken: english
ODROIDs: Odroid-Go

Re: Integration Adafruit MMA8451

Unread postby tobetter » Tue Oct 30, 2018 8:49 am

Tinkerpete wrote:Hello everybody,

i try to integrate the MMA 8451 Acceleration Sensor in Odroid-Go. But i have no luck. Has anybody a example for me? I have tried with the adafruit example, but it seems it did not start the sensor. I have tried to add 'Wire.begin (15, 4)', but did also not work. I have add '#include <odroid_go.h>' but it comes to compile problems. I have seen, that Odroid have own 'cpp' and 'h' files for certain sensors in his library directory. But what must i change in the adafruit libraries fpr working MMA 8451?

Thomas

I think there is no example of MMA8451 runs on ODROiD-GO. When I looked at the site for the board, it says it's based on I2C for data transfering and two interrups. So my guess is that after porting the code from Adafruit, you would check I2C bus if the register can be written, then you have to write up code to handle the interrupts from the board. Even the page said that you have to look into the datasheet for the detail. By the way, what does "Wire.begin(15, 4)" make it for MMA8451? Power?
User avatar
tobetter
 
Posts: 2461
Joined: Mon Feb 25, 2013 10:55 am
Location: Paju, South Korea
languages_spoken: Korean, English
ODROIDs: X, X2, U2, U3, XU3, C1

Re: Integration Adafruit MMA8451

Unread postby Tinkerpete » Tue Oct 30, 2018 9:22 pm

"Wire.begin(15, 4)"

I think this give the Odroid-Go Expansion-Port pins for I2C to the library.
Tinkerpete
 
Posts: 19
Joined: Tue Oct 16, 2018 3:46 pm
languages_spoken: english
ODROIDs: Odroid-Go

Re: Integration Adafruit MMA8451

Unread postby Tinkerpete » Tue Oct 30, 2018 9:38 pm

Here ist there original Adafruit code. It did not work on the Odroid-Go. It says always: "Couldnt start"

#include <Wire.h>
#include <Adafruit_MMA8451.h>
#include <Adafruit_Sensor.h>

Adafruit_MMA8451 mma = Adafruit_MMA8451();

void setup(void) {
Serial.begin(9600);

Serial.println("Adafruit MMA8451 test!");


if (! mma.begin()) {
Serial.println("Couldnt start");
while (1);
}
Serial.println("MMA8451 found!");

mma.setRange(MMA8451_RANGE_2_G);

Serial.print("Range = "); Serial.print(2 << mma.getRange());
Serial.println("G");

}

void loop() {
// Read the 'raw' data in 14-bit counts
mma.read();
Serial.print("X:\t"); Serial.print(mma.x);
Serial.print("\tY:\t"); Serial.print(mma.y);
Serial.print("\tZ:\t"); Serial.print(mma.z);
Serial.println();

/* Get a new sensor event */
sensors_event_t event;
mma.getEvent(&event);

/* Display the results (acceleration is measured in m/s^2) */
Serial.print("X: \t"); Serial.print(event.acceleration.x); Serial.print("\t");
Serial.print("Y: \t"); Serial.print(event.acceleration.y); Serial.print("\t");
Serial.print("Z: \t"); Serial.print(event.acceleration.z); Serial.print("\t");
Serial.println("m/s^2 ");

delay(500);
}
Tinkerpete
 
Posts: 19
Joined: Tue Oct 16, 2018 3:46 pm
languages_spoken: english
ODROIDs: Odroid-Go

Re: Integration Adafruit MMA8451

Unread postby Tinkerpete » Tue Nov 06, 2018 11:51 pm

Any ideas?
Tinkerpete
 
Posts: 19
Joined: Tue Oct 16, 2018 3:46 pm
languages_spoken: english
ODROIDs: Odroid-Go

Re: Integration Adafruit MMA8451

Unread postby tobetter » Wed Nov 07, 2018 12:24 am

Tinkerpete wrote:Any ideas?

Is your MMA8451 board power up? Do you see the I2C bus is swing? What's the log stuck?
User avatar
tobetter
 
Posts: 2461
Joined: Mon Feb 25, 2013 10:55 am
Location: Paju, South Korea
languages_spoken: Korean, English
ODROIDs: X, X2, U2, U3, XU3, C1

Re: Integration Adafruit MMA8451

Unread postby Tinkerpete » Wed Nov 07, 2018 5:31 am

I had test it with a I2CScanner program and it shows 01XD as address. I think it is correct wired.

I have test it with a Arduino Uno and it works.
Tinkerpete
 
Posts: 19
Joined: Tue Oct 16, 2018 3:46 pm
languages_spoken: english
ODROIDs: Odroid-Go

Re: Integration Adafruit MMA8451

Unread postby tobetter » Wed Nov 07, 2018 8:45 am

Tinkerpete wrote:I had test it with a I2CScanner program and it shows 01XD as address. I think it is correct wired.

I have test it with a Arduino Uno and it works.

The first problem I guess is "Wire.begin(15, 4)" is missing in your code, according to Wiki it's to enable I2C bus. Also, you would check your code can recognize the sensor since you have tested the wires and it's correct.
User avatar
tobetter
 
Posts: 2461
Joined: Mon Feb 25, 2013 10:55 am
Location: Paju, South Korea
languages_spoken: Korean, English
ODROIDs: X, X2, U2, U3, XU3, C1

Re: Integration Adafruit MMA8451

Unread postby Tinkerpete » Wed Nov 07, 2018 4:29 pm

I had test it with 'Wire.begin(15, 4)' but it did not work.
Tinkerpete
 
Posts: 19
Joined: Tue Oct 16, 2018 3:46 pm
languages_spoken: english
ODROIDs: Odroid-Go

Re: Integration Adafruit MMA8451

Unread postby Tinkerpete » Wed Nov 07, 2018 5:14 pm

I have already tried this with a Wemos OLED ESP 32 module. It didn't work there either. Is it possible that the ESP 32 is incompatible with the MMA8451?
Tinkerpete
 
Posts: 19
Joined: Tue Oct 16, 2018 3:46 pm
languages_spoken: english
ODROIDs: Odroid-Go

Re: Integration Adafruit MMA8451

Unread postby tobetter » Wed Nov 07, 2018 5:52 pm

Tinkerpete wrote:I have already tried this with a Wemos OLED ESP 32 module. It didn't work there either. Is it possible that the ESP 32 is incompatible with the MMA8451?

What I am not sure is that whether I2C bus is swing whenever a function is called from ODROID-GO and whether slave address is matched for MMA8451.
What about the signal level?
User avatar
tobetter
 
Posts: 2461
Joined: Mon Feb 25, 2013 10:55 am
Location: Paju, South Korea
languages_spoken: Korean, English
ODROIDs: X, X2, U2, U3, XU3, C1

Re: Integration Adafruit MMA8451

Unread postby Tinkerpete » Wed Nov 07, 2018 7:42 pm

Did you mean the voltage on pin 4 and 5? I can measure 3.3 Volt on each pin, but can not detect a rectangle signal with a Fluke 123?
Tinkerpete
 
Posts: 19
Joined: Tue Oct 16, 2018 3:46 pm
languages_spoken: english
ODROIDs: Odroid-Go

Re: Integration Adafruit MMA8451

Unread postby Tinkerpete » Wed Nov 14, 2018 4:01 pm

Who has a Adafruit MMA8451 Accelerometer Breakout connected to a Odroid-Go?
Tinkerpete
 
Posts: 19
Joined: Tue Oct 16, 2018 3:46 pm
languages_spoken: english
ODROIDs: Odroid-Go


Return to Arduino Coding Camp

Who is online

Users browsing this forum: No registered users and 1 guest