Accelerometer via Serial?

Hi @realdashdev,

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

I’ve got a 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?

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

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.

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

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

Thanks, @realdashdev, you are the man!

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.



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

@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?

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.

1 Like

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

1 Like

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

Data Sheet and Manual links at bottom of page.

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

1 Like

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