Open ThinhNguyen168 opened 4 years ago
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?
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.
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 = [ ]
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.