Ahork
Published

Wireless Barcode Scanner

M5StickV and M5StickC with HID Bluetooth Wireless

BeginnerFull instructions provided1 hour499
Wireless Barcode Scanner

Things used in this project

Hardware components

M5StickC ESP32-PICO Mini IoT Development Board
M5Stack M5StickC ESP32-PICO Mini IoT Development Board
×1
M5StickV K210 AI Camera (Without Wifi)
M5Stack M5StickV K210 AI Camera (Without Wifi)
×1
Cable grove
×1

Software apps and online services

Sipeed Maixpy
Arduino IDE
Arduino IDE
Library ESP32-BLE-Keyboard

Story

Read more

Schematics

Grove StickC to StickV

Image to https://m5stack.hackster.io/anoken2017/mimamori-alert-for-your-home-security-098b12

Code

M5StickC

Arduino
Code for M5SticK
#include <M5StickC.h>
#include <BleKeyboard.h>


//reception M5StickV
HardwareSerial serial_ext(2);

//Connect HID Bluetooth
BleKeyboard bleKeyboard;

void setup() {

  M5.begin();
  M5.Lcd.setRotation(3);
  M5.Lcd.fillScreen(BLACK);
  M5.Lcd.setCursor(0, 0);
  M5.Lcd.setTextSize(2);
  M5.Lcd.println("GO");
  bleKeyboard.begin();

// Connect M5StickV
  pinMode(32, OUTPUT);
  pinMode(33, INPUT);
  serial_ext.begin(115200, SERIAL_8N1, 32, 33);
  
}

// for IBSN (Number)
void loop() {
   
    if(bleKeyboard.isConnected()) {
        
    if ( serial_ext.available() > 0 ) {
      bleKeyboard.press(KEY_LEFT_SHIFT );
      String str = serial_ext.readStringUntil('\n');
      bleKeyboard.print(str);
      bleKeyboard.releaseAll();    
      M5.Lcd.fillScreen(BLACK);
      M5.Lcd.setCursor(0, 0);
      M5.Lcd.println(str);
    }
    
}
}

M5StickV

Python
Code for M5stickV
import sensor
import image
import lcd
import time
from machine import I2C,UART

from fpioa_manager import fm

#uart initial
fm.register(35, fm.fpioa.UART2_TX, force=True)
fm.register(34, fm.fpioa.UART2_RX, force=True)

uart_Port = UART(UART.UART2, 115200,8,0,0, timeout=1000, read_buf_len= 4096)


clock = time.clock()
lcd.init()
sensor.reset()
sensor.set_pixformat(sensor.RGB565)
sensor.set_framesize(sensor.QVGA)
sensor.set_vflip(1)
sensor.set_hmirror(1)
sensor.run(1)
sensor.skip_frames(20)
while True:
    clock.tick()
    img = sensor.snapshot()
    res = img.find_barcodes()
    fps =clock.fps()
    if len(res) > 0:
        data = res[0].payload()
        print(data)
        uart_Port.write(data)
        time.sleep(2)
    lcd.display(img)

Credits

Ahork

Ahork

2 projects • 0 followers
Maker

Comments

Add projectSign up / Login