How to read motion sensor data using M4 Arduino?

Discussion in 'UDOO NEO' started by fgs, Jun 24, 2016.

  1. fgs

    fgs New Member

    Joined:
    Jun 24, 2016
    Messages:
    9
    Likes Received:
    0
    I can't seem to get any data from the motion sensors when reading them via Arduino. I visited this page but the link is broken: http://www.udoo.org/docs-neo/Arduin...e_9-axis_motion_sensors_from_the_M4_Core.html

    I initially (successfully) tested the sensors by checking the UDOO web dashboard and checked via console using:

    echo 1 > /sensors/accelerometer/enable
    cat /sensors/accelerometer/data


    I then removed I2C bus 4 from external pins using the Device Tree Editor (as shown here: http://imgur.com/jHJ4axu). This resulted in UDOO's web dashboard NOT showing motion sensor data, and the /sensors/accelerometer directory disappearing.

    I cloned https://github.com/UDOOboard/udooneo-arduino-libraries-release to ~/Arduino/libraries.

    I uploaded the following simple sketch via the dashboard Arduino IDE:

    #include <Wire.h>
    #include <FXOS8700CQ_neo.h>

    FXOS8700CQ accMagSensor = FXOS8700CQ(0x1E);

    void setup() {

    pinMode(13, OUTPUT)
    Serial.begin(115200);
    Wire1.begin();
    accMagSensor.init();
    }

    void loop() {

    accMagSensor.readMagData();
    Serial.print((int)accMagSensor.accelData.x);
    Serial.print(", ");
    digitalWrite(13, HIGH);
    delay(100);
    digitalWrite(13, LOW);
    delay(100);
    }

    The LED on the board blinks as expected, however when reading from serial using an onboard Linux Python script (also at 115200 baud) I just get comma separated zeroes: 0, 0, 0, 0, ...

    Am I missing a step somewhere?

    Using UDOO Neo Full.
     
    Last edited: Jun 24, 2016
  2. waltervl

    waltervl UDOOer

    Joined:
    Dec 12, 2015
    Messages:
    2,314
    Likes Received:
    580
    fgs and Andrea Rovai like this.
  3. fgs

    fgs New Member

    Joined:
    Jun 24, 2016
    Messages:
    9
    Likes Received:
    0
    Thanks, I managed to get some numbers out although stability seems patchy. Which is the best library for the Neo Full?
    FXOS8700CQ_neo from GitHub?
    FXOS8700CQ_neo from apt-get?
    FXOS8700CQ?
     
  4. Lothar

    Lothar New Member

    Joined:
    Aug 8, 2016
    Messages:
    13
    Likes Received:
    5
    accMagSensor.readMagData();
    doesn't read accelerometer data, so it's not surprising to get zeros after that.

    You should use
    accMagSensor.readAccelData();
     

Share This Page