Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ID of sensors inside Technic Plus Hub #18

Open
ThinhNguyen168 opened this issue Jun 20, 2020 · 3 comments
Open

ID of sensors inside Technic Plus Hub #18

ThinhNguyen168 opened this issue Jun 20, 2020 · 3 comments

Comments

@ThinhNguyen168
Copy link

Hello,

Thank you for this great project. I have tried your example technic_4x4.py which works well for me. Do you know the ID of the sensors inside the Technic Plus Hub (which also include an IMU)? I would like to get access to the orientation of the hub. Look forward to hearing from you.

@BuongiornoTexas
Copy link

I'm not at this point yet, so I'm guessing the constants in https://github.com/virantha/bricknil/blob/master/bricknil/const.py aren't what you are looking for? In that case, the constants at the bottom of https://github.com/nathankellenicki/node-poweredup/blob/master/src/hubs/technicmediumhub.ts may be what you need?

@ThinhNguyen168
Copy link
Author

Thank you very much. Now I can access to the voltage, current sensors and accelerometer of the hub. However the tilt sensor (port 99 according to https://github.com/nathankellenicki/node-poweredup/blob/master/src/hubs/technicmediumhub.ts) does not work. I don't know if the port 99 is incorrect or I don't have the right sensor id. Will continue investigating. Thank you again.

@ThinhNguyen168
Copy link
Author

For those who want to use the sensor of Technic Plus Hub, you can add the following lines of code at the end of file \bricknil\sensor\sensor.py:

class AccelerometerSensor(Peripheral):
"""
Access the internal accelerometer of the PowerUp+ hub
- sense_acceleration_3_axis - raw accelerometer data. (3 x 2 bytes)

    Examples::

        # Basic use
        @attach(AccelerometerSensor, name='accelerometer', capabilities=['sense_acceleration_3_axis'])
"""
_sensor_id = 0x0039
capability = Enum("capability",{'sense_acceleration_3_axis': 0})

datasets = { 
             capability.sense_acceleration_3_axis: (3, 2),
            }

allowed_combo = [ ]

class GyroSensor(Peripheral):
"""
Access the internal gyroscope of the PowerUp+ hub
- sense_angular_velocity - 3x2 bytes of raw angular velocity data.

    Examples::

        # Basic use
        @attach(AccelerometerSensor, name='accelerometer', capabilities=['sense_acceleration_3_axis'])
"""
_sensor_id = 0x003A
capability = Enum("capability",{'sense_angular_velocity': 0})

datasets = { 
             capability.sense_angular_velocity: (3, 2),
            }

allowed_combo = [ ]

class TiltSensor(Peripheral):
"""
Access the internal tilt sensor in the Technic Plus hub

    - **sense_angle** - angles around Z, Y, X axes in degree (3x2 bytes).  Equal to 0 if hub is lying flat with button up and yaw angle is the same as starting.

    Examples::

        # Basic tilt sensor
        @attach(TiltSensor, name='tilt', capabilities=['sense_angle'])
"""
_sensor_id = 0x003B
capability = Enum("capability", {'sense_angle': 0})

datasets = { 
             capability.sense_angle: (3, 2),
            }

allowed_combo = [ ]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants