As I wrote in an other post, I want to detect movement of the device. As of now I'm not interested in the direction[*], just that the device is moving. I'm using the following code, and it seems to work. Is there a better way? Code: #include <Wire.h> #include <FXOS8700CQ.h> static FXOS8700CQ accMagSensor = FXOS8700CQ(0x1E); static float factor; void setup() { Serial.begin(115200); Wire1.begin(); accMagSensor.init(); factor = accMagSensor.getAres(); } void loop() { static unsigned long nextDisplay = 0; const unsigned long now = millis(); if (accMagSensor.isAccelDataRdy()) { accMagSensor.readAccelData(); if (now >= nextDisplay) { float f = factor * sqrt(pow(accMagSensor.accelData.x,2) + pow(accMagSensor.accelData.y,2) + pow(accMagSensor.accelData.z,2)); if (f < 0.995 || f > 1.015) { Serial.println(f); } nextDisplay = now + 500; } } } [*] I don't need it for my idea, but still.... I'd like to know how to do that
I am in the know that @estebanSannin developed a similar demo with UDOO Neo some time ago. In this demo, UDOO Neo tweets whenever you move it. Esteban, can you point @Maurice in the right direction?
Here is the code for automatic detection: http://www.slideshare.net/maubau/udoo-iot-platform We've uploaded the presentation of the demo I were talking about.