@bryam
The code above is for the maixpy (micropython) not arduino
staberas
@staberas
Posts made by staberas
-
RE: Any updates on the mpu6886?
-
RE: ImageWriter.add_frame(img) system crash
Hi, in order to help you , we need to see the code
-
RE: Use with a standard USB camera instead?
Not possible, i had problems with rasp pi since the firmware/drivers used on those cameras are finicky
-
RE: M5Stick-V microphono
uhm, the mic has a design flow
https://twitter.com/M5Stack/status/1164753358101463044- M5StickV will not have Microphone function, which doesn't affect the normal usage;
- For customers who do need this function, pls contact your purchased channel for after service, till Sep. 30;
- M5StickV+ will be released end of 2019, adding Wifi and Microphone function.
-
RE: Any updates on the mpu6886?
done, used party code from anoken who sourced it from the arduino version , i clean up and updated it
import image import lcd import sensor import sys import time import utime from board import board_info import KPU as kpu from Maix import GPIO from fpioa_manager import * from pmu import axp192 from machine import I2C #pmu = axp192() - breaks IMU data - #pmu.enablePMICSleepMode(True) - breaks IMU data - i2c = I2C(I2C.I2C0, freq=400000, scl=28, sda=29) #devices = i2c.scan() lcd.init() # IMU6866 define MPU6886_ADDRESS=0x68 MPU6886_WHOAMI=0x75 MPU6886_ACCEL_INTEL_CTRL=0x69 MPU6886_SMPLRT_DIV=0x19 MPU6886_INT_PIN_CFG=0x37 MPU6886_INT_ENABLE=0x38 MPU6886_ACCEL_XOUT_H=0x3B MPU6886_TEMP_OUT_H=0x41 MPU6886_GYRO_XOUT_H=0x43 MPU6886_USER_CTRL= 0x6A MPU6886_PWR_MGMT_1=0x6B MPU6886_PWR_MGMT_2=0x6C MPU6886_CONFIG=0x1A MPU6886_GYRO_CONFIG=0x1B MPU6886_ACCEL_CONFIG=0x1C MPU6886_ACCEL_CONFIG2=0x1D MPU6886_FIFO_EN=0x23 # IMU6866 Initialize def write_i2c(address, value): i2c.writeto_mem(MPU6886_ADDRESS, address, bytearray([value])) time.sleep_ms(10) write_i2c(MPU6886_PWR_MGMT_1, 0x00) write_i2c(MPU6886_PWR_MGMT_1, 0x01<<7) write_i2c(MPU6886_PWR_MGMT_1,0x01<<0) write_i2c(MPU6886_ACCEL_CONFIG,0x10) write_i2c(MPU6886_GYRO_CONFIG,0x18) write_i2c(MPU6886_CONFIG,0x01) write_i2c(MPU6886_SMPLRT_DIV,0x05) write_i2c(MPU6886_INT_ENABLE,0x00) write_i2c(MPU6886_ACCEL_CONFIG2,0x00) write_i2c(MPU6886_USER_CTRL,0x00) write_i2c(MPU6886_FIFO_EN,0x00) write_i2c(MPU6886_INT_PIN_CFG,0x22) write_i2c(MPU6886_INT_ENABLE,0x01) # Read IMU6866 and Scaling def read_imu(): aRes=255/4096/2 gRes = 2000.0/32768.0 offset=128 accel = i2c.readfrom_mem(MPU6886_ADDRESS, MPU6886_ACCEL_XOUT_H, 6) accel_x = (accel[0]<<8|accel[1]) accel_y = (accel[2]<<8|accel[3]) accel_z = (accel[4]<<8|accel[5]) if accel_x>32768: accel_x=accel_x-65536 if accel_y>32768: accel_y=accel_y-65536 if accel_z>32768: accel_z=accel_z-65536 ax=int(accel_x*aRes+offset) if ax<0: ax=0 if ax>255: ax=255 ay=int(accel_y*aRes+offset) if ay<0: ay=0 if ay>255: ay=255 az=int(accel_z*aRes+offset) if az<0: az=0 if az>255: az=255 accel_array = [ax,ay,az] gyro = i2c.readfrom_mem(MPU6886_ADDRESS, MPU6886_GYRO_XOUT_H, 6) gyro_x = (gyro[0]<<8|gyro[1]) gyro_y = (gyro[2]<<8|gyro[3]) gyro_z = (gyro[4]<<8|gyro[5]) if gyro_x>32768: gyro_x=gyro_x-65536 if gyro_y>32768: gyro_y=gyro_y-65536 if gyro_z>32768: gyro_z=gyro_z-65536 gx=int(gyro_x*gRes+offset) if gx<0: gx=0 if gx>255: gx=255 gy=int(gyro_y*gRes+offset) if gy<0: gy=0 if gy>255: gy=255 gz=int(gyro_x*gRes+offset) if gz<0: gz=0 if gz>255: gz=255 gyro_array = [gx,gy,gz] return accel_array, gyro_array lcd.rotation(2) task = kpu.load("/sd/7118109ae3ea570e_mbnet10_quant.kmodel")#change model labels=["seadog","Borbya","mermaid","Villo"] #change names. sensor.reset() sensor.set_pixformat(sensor.RGB565) sensor.set_framesize(sensor.QVGA) sensor.set_windowing((224, 224)) sensor.run(1) lcd.clear() while(True): accel_array,gyro_array = read_imu() img = sensor.snapshot() fmap = kpu.forward(task,img) plist=fmap[:] pmax=max(plist) #lcd.draw_string(40, 20, str(accel_array)) #lcd.draw_string(10, 40, str(gyro_array)) max_index=plist.index(pmax) if pmax > 0.95: #lcd.draw_string(40, 60, "Accu:%.2f Type:%s"%(pmax, labels[max_index].strip())) #20-59,130-136,55-30 [side view] 100-130,130-136,9-20 [top view] #the values are from 0 to 255 if accel_array[0] > 20 and accel_array[0] < 59 and accel_array[1] > 130 and accel_array[1] < 136 and accel_array[2] > 30 and accel_array[2] < 55: img.draw_image(image.Image("/sd/view2.jpg"), 50, 50,x_scale=0.5,y_scale=0.5,mask=image.Image("/sd/view2t.jpg")) if accel_array[0] > 60 and accel_array[0] < 130 and accel_array[1] > 130 and accel_array[1] < 137 and accel_array[2] > 8 and accel_array[2] < 20: img.draw_image(image.Image("/sd/view1.jpg"), 50, 50,x_scale=0.5,y_scale=0.5,mask=image.Image("/sd/view1t.jpg")) a = lcd.display(img) a = kpu.deinit(task) sys.exit()
-
RE: M5StickV Firmware_1017 Upgrade
im not sure i understand, can u provide an example ?
EDIT: it works now i have to comment out those two:
#pmu = axp192()
#pmu.enablePMICSleepMode(True)when added they the IMU locks up
-
RE: M5StickV Firmware_1017 Upgrade
new bug:
"pmu import axp192" interferes when i try to get gyro/accel data from the MPU6886 -
RE: M5stack V uart communication
https://m5stack.hackster.io/anoken2017/cheering-watch-of-m5stickc-v-34f0cc
Near the end , tell us if it helps
-
RE: Any updates on the mpu6886?
@xeon sorry for resurrecting old post, i had the same problem, i currently close getting data from the IMU