# Accelerometer via Serial?

**URL:** <https://forum.realdash.net/t/accelerometer-via-serial/1562>\
**Category:** Custom Hardware / Electronics\
**Created:** [February 25, 2023, 10:41pm UTC](https://forum.realdash.net/t/accelerometer-via-serial/1562 "2023-02-25T22:41:35Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![dmakhkamov](https://forum.realdash.net/user_avatar/forum.realdash.net/dmakhkamov/32/22_2.png) [@dmakhkamov](https://forum.realdash.net/u/dmakhkamov)\
**Post date:** [February 25, 2023, 10:41pm UTC](https://forum.realdash.net/t/accelerometer-via-serial/1562/1 "2023-02-25T22:41:35Z")

</div>

Hi @realdashdev,

I’ve am running RealDash on Raspberry Pi, running on Android.

I’ve got a [wit-motion.com](http://wit-motion.com) accelerometer, which, from what I understand, communicates via Serial (it has 4 cables, vcc, gnd, txd, rxd). Is there a way already, where I can add such device as data source?

---

<div class="post-metadata">

**Author:** ![realdashdev](https://forum.realdash.net/user_avatar/forum.realdash.net/realdashdev/32/6_2.png) [@realdashdev](https://forum.realdash.net/u/realdashdev)\
**Post date:** [March 1, 2023, 8:02am UTC](https://forum.realdash.net/t/accelerometer-via-serial/1562/2 "2023-03-01T08:02:55Z")

</div>

Sure, send the data to RealDash as CAN frames with RealDash CAN protocol:

[https://github.com/janimm/RealDash-extras/tree/master/RealDash-CAN](https://github.com/janimm/RealDash-extras/tree/master/RealDash-CAN)

---

<div class="post-metadata">

**Author:** ![dmakhkamov](https://forum.realdash.net/user_avatar/forum.realdash.net/dmakhkamov/32/22_2.png) [@dmakhkamov](https://forum.realdash.net/u/dmakhkamov)\
**Post date:** [March 4, 2023, 8:58pm UTC](https://forum.realdash.net/t/accelerometer-via-serial/1562/3 "2023-03-04T20:58:35Z")

</div>

> [@](#):
>
> Sure, send the data to RealDash as CAN frames with RealDash CAN protocol:
> 
> [RealDash-extras/RealDash-CAN at master · janimm/RealDash-extras · GitHub](https://github.com/janimm/RealDash-extras/tree/master/RealDash-CAN)

Just to confirm if I got you right:

You are suggesting getting the numbers and sending them as analog numbers in the CAN data, right? Is there any specific format I should send? XYZ altogether or separately? The goal is to have the G-Map on Lexus-inspired dash to work.

---

<div class="post-metadata">

**Author:** ![realdashdev](https://forum.realdash.net/user_avatar/forum.realdash.net/realdashdev/32/6_2.png) [@realdashdev](https://forum.realdash.net/u/realdashdev)\
**Post date:** [March 6, 2023, 8:58am UTC](https://forum.realdash.net/t/accelerometer-via-serial/1562/4 "2023-03-06T08:58:26Z")

</div>

You can send any data to RealDash with RealDash CAN protocol. For Accelerometer, send X, Y and Z acceleration (in G) to inputs 6, 7, and 8. See complete list:

[http://realdash.net/manuals/targetid.php](http://realdash.net/manuals/targetid.php)

---

<div class="post-metadata">

**Author:** ![dmakhkamov](https://forum.realdash.net/user_avatar/forum.realdash.net/dmakhkamov/32/22_2.png) [@dmakhkamov](https://forum.realdash.net/u/dmakhkamov)\
**Post date:** [March 6, 2023, 8:12pm UTC](https://forum.realdash.net/t/accelerometer-via-serial/1562/5 "2023-03-06T20:12:23Z")

</div>

> [@](#):
>
> You can send any data to RealDash with RealDash CAN protocol. For Accelerometer, send X, Y and Z acceleration (in G) to inputs 6, 7, and 8. See complete list:
> 
> [RealDash | Manuals | Target Identifiers](http://realdash.net/manuals/targetid.php)

Lovely, will check this out and update the community about the progress.

Thanks, @realdashdev, you are the man!

---

<div class="post-metadata">

**Author:** ![dmakhkamov](https://forum.realdash.net/user_avatar/forum.realdash.net/dmakhkamov/32/22_2.png) [@dmakhkamov](https://forum.realdash.net/u/dmakhkamov)\
**Post date:** [August 24, 2023, 3:04pm UTC](https://forum.realdash.net/t/accelerometer-via-serial/1562/6 "2023-08-24T15:04:53Z")

</div>

I’ve managed to read data and send it via Serial CAN, but however, the numbers are read as Integers. Whenever G is not 0, its read as 1. what am I doing wrong?

I am using FrameID 3200.

---

<div class="post-metadata">

**Author:** ![dmakhkamov](https://forum.realdash.net/user_avatar/forum.realdash.net/dmakhkamov/32/22_2.png) [@dmakhkamov](https://forum.realdash.net/u/dmakhkamov)\
**Post date:** [August 24, 2023, 9:33pm UTC](https://forum.realdash.net/t/accelerometer-via-serial/1562/7 "2023-08-24T21:33:21Z")

</div>

Nevermind, it seems like the data was not sent properly. However, there is an issue with Initiating the Serial Communication on start.

---

<div class="post-metadata">

**Author:** ![dmakhkamov](https://forum.realdash.net/user_avatar/forum.realdash.net/dmakhkamov/32/22_2.png) [@dmakhkamov](https://forum.realdash.net/u/dmakhkamov)\
**Post date:** [September 3, 2023, 2:16pm UTC](https://forum.realdash.net/t/accelerometer-via-serial/1562/8 "2023-09-03T14:16:26Z")

</div>

@realdashdev,

as mentioned earlier, I’ve managed to send data from my sensor to RD via RDCAN, however, the data I have is apparently Acceleration RAW. What is the difference between Raw and G data? How to convert RAW to G?

---

<div class="post-metadata">

**Author:** ![realdashdev](https://forum.realdash.net/user_avatar/forum.realdash.net/realdashdev/32/6_2.png) [@realdashdev](https://forum.realdash.net/u/realdashdev)\
**Post date:** [September 4, 2023, 7:29am UTC](https://forum.realdash.net/t/accelerometer-via-serial/1562/9 "2023-09-04T07:29:06Z")

</div>

> [@dmakhkamov](#):
>
> What is the difference between Raw and G data? How to convert RAW to G?

Raw accelerometer values have a constant 1G pointing to (about) center of the earth. So if device is not moving at all, the length of X,Y and Z components of raw data is close to 1.0.

G data is derived from this by using math to remove the 1G from the data to get current acceleration along the the axis.

---

<div class="post-metadata">

**Author:** ![dmakhkamov](https://forum.realdash.net/user_avatar/forum.realdash.net/dmakhkamov/32/22_2.png) [@dmakhkamov](https://forum.realdash.net/u/dmakhkamov)\
**Post date:** [September 4, 2023, 11:24am UTC](https://forum.realdash.net/t/accelerometer-via-serial/1562/10 "2023-09-04T11:24:14Z")

</div>

Thanks @realdashdev !

With your seed and little help from GPT, I have managed to convert the data and send it to targets of 6, 7, and 8.

**1. Convert Raw Values to g Values** : Typically, raw values from an accelerometer are in ADC units. The datasheet or manual of your accelerometer will provide details on converting these to ‘g’ units. However, I’ll assume in this example that your accelerometer already provides readings in ‘g’ units.

**2. Calculate Magnitude of the Acceleration** : To determine the amount of static gravitational force on the accelerometer, you can calculate the magnitude of the total acceleration vector:

_magnitude = sqrt(x^2 + y^2 + z^2)_

**3. Normalize the Acceleration Vector** : This will give you the direction of the gravitational force:

_x\_norm = x / magnitude; y\_norm = y / magnitude; z\_norm = z / magnitude;_

**4. Remove Gravity** : Subtract the normalized gravity vector scaled by 1g from the original readings:

_x\_dynamic = x - x\_norm \* 1g; y\_dynamic = y - y\_norm \* 1g; z\_dynamic = z - z\_norm \* 1g_

The rest is to send the numbers via RealDashCAN with the right CAN Description file

---

<div class="post-metadata">

**Author:** ![SandHillsHillbilly](https://forum.realdash.net/letter_avatar_proxy/v4/letter/s/db5fbb/32.png) [@SandHillsHillbilly](https://forum.realdash.net/u/SandHillsHillbilly)\
**Post date:** [September 15, 2023, 11:55am UTC](https://forum.realdash.net/t/accelerometer-via-serial/1562/11 "2023-09-15T11:55:43Z")

</div>

Which model accelerometer are you using?

I see they have a CAN Bus Accelerometer on Amazon US.  
[https://www.amazon.com/WITMOTION-Temperature-Compensation-Accelerometer-geomagnetic/dp/B09Q8TVY7D](https://www.amazon.com/WITMOTION-Temperature-Compensation-Accelerometer-geomagnetic/dp/B09Q8TVY7D)

Data Sheet and Manual links at bottom of page.

---

<div class="post-metadata">

**Author:** ![dmakhkamov](https://forum.realdash.net/user_avatar/forum.realdash.net/dmakhkamov/32/22_2.png) [@dmakhkamov](https://forum.realdash.net/u/dmakhkamov)\
**Post date:** [September 15, 2023, 1:59pm UTC](https://forum.realdash.net/t/accelerometer-via-serial/1562/12 "2023-09-15T13:59:56Z")

</div>

im using a slimilar one, but its a serial sensor. So I use Arduino to read serial data, and send the processed data via RealDash-CAN

---

<div class="post-metadata">

**Author:** ![SandHillsHillbilly](https://forum.realdash.net/letter_avatar_proxy/v4/letter/s/db5fbb/32.png) [@SandHillsHillbilly](https://forum.realdash.net/u/SandHillsHillbilly)\
**Post date:** [September 15, 2023, 2:41pm UTC](https://forum.realdash.net/t/accelerometer-via-serial/1562/13 "2023-09-15T14:41:20Z")

</div>

Thanks for the information. These look better and cost less than the Plimpton Module I was looking at.
