Acceleration of Gravity Tilt Module for Arduino
#1
Hi together!

I'm searching for a way to use the automatic orientation on Android.
So, which accelerometers will work with the Pine64?

I found a very cheap module, original for Arduino. It works via GPIO.
- ADXL345 3-Axes Digital Acceleration of Gravity Tilt Module for Arduino GY-291 EV
For just 1.08 Euro!

Best regards
Julian
My forum topics:
• Create a WiFi hotspot on Debian 8
• Turn your Pine64 into a music server with mpd
• Adjust brightness of LCD on Armbian Desktop with 1 click
• My cases for Pine64 (acryl, lego & wood)

• Pine 64 - DACH - Facebook page for german-speaking Pine64-fans.
  Reply
#2
I just extracted a device tree from the Android image for LCD, to look at the LCD config... but I found also the following: some acc, gyro, light and compass sensors seem to be defined for the I2C bus... maybe try one of those?


Code:
       gsensor {
           device_type = "gsensor";
           compatible = "allwinner,sun50i-gsensor-para";
           status = "okay";
           gsensor_twi_id = <0x00000001>;
           gsensor_twi_addr = <0x0000001d>;
           gsensor_vcc_io = "vcc-deviceio";
           gsensor_vcc_io_val = <0x00000ce4>;
           gsensor_int1 = <0x00000030 0x00000007 0x00000005 0x00000006 0x00000001 0xffffffff 0xffffffff>;
           gsensor_int2 = <0x00000030 0x00000007 0x00000006 0x00000006 0x00000001 0xffffffff 0xffffffff>;
       };
       gsensor_list {
           device_type = "gsensor_list";
           compatible = "allwinner,sun50i-gsensor-list-para";
           gsensor_list__used = <0x00000001>;
           lsm9ds0_acc_mag = <0x00000001>;
           bma250 = <0x00000001>;
           mma8452 = <0x00000001>;
           mma7660 = <0x00000001>;
           mma865x = <0x00000001>;
           afa750 = <0x00000001>;
           lis3de_acc = <0x00000001>;
           lis3dh_acc = <0x00000001>;
           kxtik = <0x00000001>;
           dmard10 = <0x00000000>;
           dmard06 = <0x00000001>;
           mxc622x = <0x00000001>;
           fxos8700 = <0x00000001>;
           lsm303d = <0x00000000>;
           sc7a30 = <0x00000001>;
};
       gyroscopesensor {
           device_type = "gyroscopesensor";
           compatible = "allwinner,sun50i-gyr_sensors-para";
           status = "disabled";
           gy_twi_id = <0x00000002>;
           gy_twi_addr = <0x0000006a>;
           gy_int1 = <0x00000030 0x00000000 0x0000000a 0x00000006 0x00000001 0xffffffff 0xffffffff>;
           gy_int2;
       };
       gy_list {
           device_type = "gy_list";
           compatible = "allwinner,sun50i-gyr_sensors-list-para";
           status = "disabled";
           lsm9ds0_gyr = <0x00000001>;
           l3gd20_gyr = <0x00000000>;
           bmg160_gyr = <0x00000001>;
};
   lightsensor {
           device_type = "lightsensor";
           compatible = "allwinner,sun50i-lsensors-para";
           status = "disabled";
           ls_twi_id = <0x00000002>;
           ls_twi_addr = <0x00000023>;
           ls_int = <0x00000030 0x00000000 0x0000000c 0x00000006 0x00000001 0xffffffff 0xffffffff>;
       };
       ls_list {
           device_type = "ls_list";
           compatible = "allwinner,sun50i-lsensors-list-para";
           status = "disabled";
           ltr_501als = <0x00000001>;
           jsa1212 = <0x00000000>;
           jsa1127 = <0x00000001>;
           stk3x1x = <0x00000000>;
       };
       compasssensor {
           device_type = "compasssensor";
           compatible = "allwinner,sun50i-compass-para";
           status = "disabled";
           compass_twi_id = <0x00000002>;
           compass_twi_addr = <0x0000000d>;
           compass_int = <0x00000030 0x00000000 0x0000000b 0x00000006 0x00000001 0xffffffff 0xffffffff>;
       };
       compass_list {
           device_type = "compass_list";
           compatible = "allwinner,sun50i-compass-list-para";
           status = "disabled";
           lsm9ds0 = <0x00000001>;
           lsm303d = <0x00000000>;
};
Come have a chat in the Pine A64 IRC channel >>
  Reply
#3
i think that sensor might actually work...
that device tree says for gsensor:
gsensor_twi_addr = <0x0000001d>;

and the datasheet for the ADXL345 says

Quote:I2C

With CS tied high to VDD I/O, the ADXL345 is in I2C mode, requiring a simple 2-wire connection as shown in . The ADXL345 conforms to the UM10204 I2C-Bus Specification and User Manual, Rev. 03—19 June 2007, available from NXP Semiconductor. It supports standard (100 kHz) and fast (400 kHz) data transfer modes if the timing parameters given in and are met. Single- or multiple-byte reads/writes are supported, as shown in . With the SDO/ALT ADDRESS pin high, the 7-bit I2C address for the device is 0x1D, followed by the R/Figure 8Table 11Figure 10Figure 9W bit. This translates to 0x3A for a write and 0x3B for a read. An alternate I2C address of 0x53 (followed by the R/W bit) can be chosen by grounding the SDO/ALT ADDRESS pin (Pin 12). This translates to 0xA6 for a write and 0xA7 for a read.
notice the address 0x1D part.
if you get one, let us know if it works.
  Reply
#4
This is what I'm planning to use one of my pyboards (MicroPython) for... it has a built-in accelerometer that can be programmed in python. Your PineA64 board can talk to the pyboard at the high level (serial, GPIO, bluetooth) and the pyboard can handle the accelerometer stuff.

marcus
  Reply
#5
i bought two of those adxl345's from ebay
http://www.ebay.ca/itm/191674294902

i plugged into the i2c-1 connection on the pi bus, pins 3 and 5
it does work under linux (on both my pine64 and my CHIP)
i made this script read it:
https://github.com/jodybrown/adxl345/blo...adxl345.sh

it also works on arduino (used code from https://learn.adafruit.com/adxl345-digit...r/overview)

sadly, it does not seem to do anything under android, either in the hdmi image or the lcd image.
maybe it has to be connected to different pins or something. i notice in the code above it says TWI but i had it connected to I2C.
i did try to connect to 27/28 but that did nothing.

using i2cdetect nothing shows up for 0x1d, just 0x53...
  Reply


Possibly Related Threads...
Thread Author Replies Views Last Post
  RPi.GPIO python module for Pine A64/A64+ aquilegia 93 21,121 01-23-2019, 06:46 AM
Last Post: cathenna10
  Porting Arduino project advice primeminister 1 475 07-14-2016, 05:16 PM
Last Post: MarkHaysHarris777

Forum Jump:


Users browsing this thread: 1 Guest(s)