Navigation

    M5Stack Community

    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    1. Home
    2. odemakov
    O
    • Continue chat with odemakov
    • Start new chat with odemakov
    • Flag Profile
    • Profile
    • Following
    • Followers
    • Blocks
    • Topics
    • Posts
    • Best
    • Groups
    Save
    Saving

    odemakov

    @odemakov

    0
    Reputation
    4
    Posts
    561
    Profile views
    0
    Followers
    0
    Following
    Joined Last Online

    odemakov Follow

    Posts made by odemakov

    • RE: M5Stack Unit2 switch mode by sending command in serial port

      Finally I managed to switch the mode from Raspberry PI using ReaderThread. Here is the code:

      import sys
      import traceback
      import argparse
      import json
      import serial
      from serial.threaded import LineReader, ReaderThread
      from time import sleep
      
      MODES = [
          'Audio FFT',
          'Code Detector',
          'Face Detector',
          'Lane Line Tracker',
          'Motion Tracker',
          'Shape Matching',
          'Camera Stream',
          'Online Classifier',
          'Color Tracker',
          'Face Recognition',
          'Target Tracker',
          'Shape Detector',
          'Object Recognition',
      ]
      
      ap = argparse.ArgumentParser()
      ap.add_argument('-m', '--mode', help = 'Switch to mode: {}'.format(MODES))
      ap.add_argument('-a', '--args', default = '', help = 'Some modes require extra args. For "Object Recognition" either "yolo_20class" or "nanodet_80class"')
      args = vars(ap.parse_args())
      
      if 'mode' not in args or args['mode'] not in MODES:
          ap.print_help()
          exit(1)
      
      OBJECT_RECOGNITION_ARGS = [
          'yolo_20class',
          'nanodet_80class'
      ]
      if args['mode'] == 'Object Recognition' and args['args'] not in OBJECT_RECOGNITION_ARGS:
          ap.print_help()
          exit(1)
      
      class PrintLines(LineReader):
          def connection_made(self, transport):
              super(PrintLines, self).connection_made(transport)
              sys.stdout.write('port opened\n')
      
          def handle_line(self, data):
              sys.stdout.write('line received: {}\n'.format(repr(data)))
      
          def connection_lost(self, exc):
              if exc:
                  traceback.print_exc(exc)
              sys.stdout.write('port closed\n')
      
      with serial.Serial() as s:
          s.port = '/dev/ttyAMA0'
          s.baudrate = 115200
          s.timeout = .5
          s.open()
      
          with ReaderThread(s, PrintLines) as protocol:
              js = {
                  'function': args['mode'],
                  'args': args['args']
              }
              protocol.write_line(json.dumps(js))
              sleep(2)
      

      And the output:

      pi@rpi0:~/serial$ ./serial_mode.py --mode 'Object Recognition' --args 'yolo_20class'
      port opened
      line received: '{"msg":"function switched to object_recognition."}'
      line received: '{"msg":"Running Object Recognition, Copyright 2021 M5Stack Technology Co., Ltd. All rights reserved.","running":"Object Recognition"}'
      port closed
      
      posted in SOFTWARE
      O
      odemakov
    • M5Stack Unit2 switch mode by sending command in serial port

      Hi there,

      I'm trying to manage UnitV2 device by Serial port. Reading data works just fine, for example in the "Object detection" mode Unit sends data:

      {'num': 1, 'obj': [{'prob': 0.697403133, 'x': 44, 'y': 8, 'w': 555, 'h': 466, 'type': 'person'}], 'running': 'Object Recognition'}
      {'num': 1, 'obj': [{'prob': 0.684900761, 'x': 49, 'y': 1, 'w': 543, 'h': 468, 'type': 'person'}], 'running': 'Object Recognition'}
      {'num': 1, 'obj': [{'prob': 0.686426222, 'x': 23, 'y': 2, 'w': 577, 'h': 472, 'type': 'person'}], 'running': 'Object Recognition'}
      

      Unfortunately I can't manage to send commands and actually switch the mode. Here is my code for Raspberry PI(connected with UnitV2 by serial ports):

      import serial, json
      
      with serial.Serial() as s:
          s.port = '/dev/ttyAMA0'
          s.baudrate = 115200
          s.timeout = .5
          s.open()
      
          js = {
              'function': 'Camera Stream',
              'args': ''
          }
          print("send", js)
          s.write(json.dumps(js).encode('utf-8'))
      
          response = s.readline()
          print("receive", response)
      

      And the output:

      send {'function': 'Camera Stream', 'args': ''}
      receive b''
      

      Am I missing something?

      posted in SOFTWARE
      O
      odemakov
    • RE: UnitV2 fan cable connection

      Hello @felmue ,

      In fact I received answer from M5 support in the morning. I managed to solder the cable to the right place and now fan works. Thank you for your help!

      Here is the place:

      0_1645533709197_unnamed.jpeg

      posted in PRODUCTS
      O
      odemakov
    • UnitV2 fan cable connection

      Hi there. Does anybody know where plus(red) wire from fan is connected to the plate? My unit was overheating in 3 minutes after start and after disassemble it I noticed that this wire isn't connected.

      0_1645458158466_photo_2022-02-21 16.37.00.jpeg

      posted in PRODUCTS
      O
      odemakov