4개의 장비 4개의 id가 잘 뜨네!
0x1e - compass
0x53 - adxl345
0x68 - mpu6050
0x77 - bmp180
$ i2cdetect 1 WARNING! This program can confuse your I2C bus, cause data loss and worse! I will probe file /dev/i2c-1. I will probe address range 0x03-0x77. Continue? [Y/n] 0 1 2 3 4 5 6 7 8 9 a b c d e f 00: -- -- -- -- -- -- -- -- -- -- -- -- -- 10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- 1e -- 20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 50: -- -- -- 53 -- -- -- -- -- -- -- -- -- -- -- -- 60: -- -- -- -- -- -- -- -- 68 -- -- -- -- -- -- -- 70: -- -- -- -- -- -- -- 77 |
3.3v에 가까운 쪽에 대충 결선하다 보니, 운 좋게(!) i2c-1에 죄다 연결된 듯
$ gpio readall +-----+-----+---------+------+---+---Pi 2---+---+------+---------+-----+-----+ | BCM | wPi | Name | Mode | V | Physical | V | Mode | Name | wPi | BCM | +-----+-----+---------+------+---+----++----+---+------+---------+-----+-----+ | | | 3.3v | | | 1 || 2 | | | 5v | | | | 2 | 8 | SDA.1 | ALT0 | 1 | 3 || 4 | | | 5v | | | | 3 | 9 | SCL.1 | ALT0 | 1 | 5 || 6 | | | 0v | | | | 4 | 7 | GPIO. 7 | IN | 1 | 7 || 8 | 1 | ALT0 | TxD | 15 | 14 | | | | 0v | | | 9 || 10 | 1 | ALT0 | RxD | 16 | 15 | | 17 | 0 | GPIO. 0 | IN | 0 | 11 || 12 | 0 | IN | GPIO. 1 | 1 | 18 | | 27 | 2 | GPIO. 2 | IN | 0 | 13 || 14 | | | 0v | | | | 22 | 3 | GPIO. 3 | IN | 0 | 15 || 16 | 0 | IN | GPIO. 4 | 4 | 23 | | | | 3.3v | | | 17 || 18 | 0 | IN | GPIO. 5 | 5 | 24 | | 10 | 12 | MOSI | IN | 0 | 19 || 20 | | | 0v | | | | 9 | 13 | MISO | IN | 0 | 21 || 22 | 0 | IN | GPIO. 6 | 6 | 25 | | 11 | 14 | SCLK | IN | 0 | 23 || 24 | 1 | IN | CE0 | 10 | 8 | | | | 0v | | | 25 || 26 | 1 | IN | CE1 | 11 | 7 | | 0 | 30 | SDA.0 | IN | 1 | 27 || 28 | 1 | IN | SCL.0 | 31 | 1 | | 5 | 21 | GPIO.21 | IN | 1 | 29 || 30 | | | 0v | | | | 6 | 22 | GPIO.22 | IN | 1 | 31 || 32 | 0 | IN | GPIO.26 | 26 | 12 | | 13 | 23 | GPIO.23 | IN | 0 | 33 || 34 | | | 0v | | | | 19 | 24 | GPIO.24 | IN | 0 | 35 || 36 | 0 | IN | GPIO.27 | 27 | 16 | | 26 | 25 | GPIO.25 | IN | 0 | 37 || 38 | 0 | IN | GPIO.28 | 28 | 20 | | | | 0v | | | 39 || 40 | 0 | IN | GPIO.29 | 29 | 21 | +-----+-----+---------+------+---+----++----+---+------+---------+-----+-----+ | BCM | wPi | Name | Mode | V | Physical | V | Mode | Name | wPi | BCM | +-----+-----+---------+------+---+---Pi 2---+---+------+---------+-----+-----+ |
+
읭? 6축 외에 온도 값도 획득이 가능한가?
>>> from mpu6050 import mpu6050 >>> sensor = mpu6050(0x68) >>> sensor.get_ sensor.get_accel_data( sensor.get_all_data( sensor.get_gyro_data( sensor.get_temp( >>> sensor.get_all_data() [{'x': 9.897629663085937, 'y': 0.296881005859375, 'z': -1.1468225952148436}, {'x': -0.48854961832061067, 'y': -1.7251908396946565, 'z': -0.3053435114503817}, 27.541764705882354] |
[링크 : https://pypi.org/project/mpu6050-raspberrypi/]
+
기압계
마이너스 고도라.. -_-
얼핏 어디서 보기로는 해발기준 기압을 조정해야 고도가 정상적으로 나올텐데 cal 값이 그 항목이려나?
>>> import Adafruit_BMP.BMP085 as BMP085 >>> sensor = BMP085.BMP085() >>> sensor. sensor.cal_AC1 sensor.cal_AC6 sensor.cal_MD sensor.read_sealevel_pressure( sensor.cal_AC2 sensor.cal_B1 sensor.read_altitude( sensor.read_temperature( sensor.cal_AC3 sensor.cal_B2 sensor.read_pressure( sensor.cal_AC4 sensor.cal_MB sensor.read_raw_pressure( sensor.cal_AC5 sensor.cal_MC sensor.read_raw_temp( >>> sensor.read_altitude() -197.0233308539572 >>> sensor.read_pressure() 103706 >>> sensor.read_temperature() 31.9 |
[링크 : https://learn.adafruit.com/using-the-bmp085-with-raspberry-pi/using-the-adafruit-bmp-python-library]
온도와 고도가 이상해서 캘리브레이션 가능한가 찾아보는중.
AC1 = sensor.cal_AC1 AC2 = sensor.cal_AC2 AC3 = sensor.cal_AC3 AC4 = sensor.cal_AC4 AC5 = sensor.cal_AC5 AC6 = sensor.cal_AC6 B1 = sensor.cal_B1 B2 = sensor.cal_B2 MB = sensor.cal_MB MC = sensor.cal_MC MD = sensor.cal_MD X1 = (UT-AC6) * AC5 / pow(2,15) X2 = MC * pow(2,11) / (X1 + MD) B5 = X1 + X2 T = (B5 + 8) / pow(2,4) print(T) |
[링크 : https://cdn-shop.adafruit.com/datasheets/BST-BMP180-DS000-09.pdf]
+
지자기 센서도 오케이!
>>> from i2clibraries import i2c_hmc5883l >>> hmc5883l = i2c_hmc5883l.i2c_hmc5883l(1) >>> hmc5883l.setContinuousMode() >>> hmc5883l.setDeclination(2, 15) >>> print(hmc5883l) Axis X: -133.4 Axis Y: -411.24 Axis Z: -379.04 Declination: 2° 15' Heading: 254° 17' >>> hmc5883l. hmc5883l.AxisXDataRegisterLSB hmc5883l.IdentificationRegisterB hmc5883l.declination hmc5883l.scale hmc5883l.AxisXDataRegisterMSB hmc5883l.IdentificationRegisterC hmc5883l.declinationDeg hmc5883l.scale_reg hmc5883l.AxisYDataRegisterLSB hmc5883l.MeasurementContinuous hmc5883l.declinationMin hmc5883l.setContinuousMode( hmc5883l.AxisYDataRegisterMSB hmc5883l.MeasurementIdle hmc5883l.getAxes( hmc5883l.setDeclination( hmc5883l.AxisZDataRegisterLSB hmc5883l.MeasurementSingleShot hmc5883l.getDeclination( hmc5883l.setOption( hmc5883l.AxisZDataRegisterMSB hmc5883l.ModeRegister hmc5883l.getDeclinationString( hmc5883l.setScale( hmc5883l.ConfigurationRegisterA hmc5883l.StatusRegister hmc5883l.getHeading( hmc5883l.ConfigurationRegisterB hmc5883l.addOption( hmc5883l.getHeadingString( hmc5883l.IdentificationRegisterA hmc5883l.bus hmc5883l.removeOption( |
[링크 : https://tutorials-raspberrypi.com/build-your-own-raspberry-pi-compass-hmc5883l/]
+
가속도 센서도 오케이!
>>> from i2clibraries import i2c_adxl345 >>> adxl = i2c_adxl345.i2c_adxl345(1) >>> print(adxl) X: 0.0 Y: -0.125 Z: 0.75 |
[링크 : https://python.hotexamples.com/.../-/i2c_adxl345/python-i2c_adxl345-function-examples.html]
'embeded > raspberry pi' 카테고리의 다른 글
cm4 io board / rpiboot (2) | 2021.06.09 |
---|---|
라즈베리 Zero용 CSI FPCB 케이블 도착 (0) | 2021.06.08 |
센서 스펙 (0) | 2021.06.05 |
pinout (0) | 2021.06.05 |
딱 만들고 싶었던 그 프로그램 (0) | 2021.06.04 |