GithubHelp home page GithubHelp logo

lupin3000 / micropython-i2c-gr10_30 Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 89 KB

MicroPython I2C library and example for Gravity: GR10-30 Gesture Sensor

Home Page: https://softwaretester.info

Python 100.00%
dfrobot esp32 gesture-recognition gravity i2c micropython sensor

micropython-i2c-gr10_30's Introduction

MicroPython I2C library and example for Gravity: GR10-30 Gesture Sensor

This repository contains the MicroPython I2C library for the Gravity: GR10-30 Gesture Sensor from DFRobot, as well as a very simple example of how to use it. The original repository from DFRobot is located here (for Arduino and Raspberry Pi).

Why this repository?

The original version of DFRobot uses Python serial (UART) and Python SMBus (I2C), which are not compatible with MicroPython. Also, I was not so happy with the Python code style/quality. That's why I created this version.

Prerequisite

  • Gravity: GR10-30 Gesture Sensor
  • ESP32 (MicroPython compatible device)
  • MicroPython firmware installed (min. 1.20.0.*)
  • USB cable (for connection between ESP32 and sensor)
  • latest VCP driver installed

GR10_30.jpg

Installation

Clone this repository to your local computer.

# clone repository
$ git clone https://github.com/Lupin3000/Micropython-I2C-GR10_30.git

# change into local repository folder
$ cd Micropython-I2C-GR10_30/

You can optionally install other helpful Python packages.

  • esptool (to flash the MicroPython firmware to the ESP32)
  • rshell (to establish a serial connection between the local computer and the ESP32 and to transfer data)
  • micropython-esp32-stubs (to facilitate local development, for example: code completion)
# install python packages (optional)
$ pip install -r requirements.txt

Connect the sensor to the ESP32. Make sure that you have set the communication mode on the sensor to I2C and use the correct connections (ESP GPIO's/Sensor interface)! Only then connect the ESP32 to your local computer via USB.

In the example main.py, the GPIOs pins 21 (SDA) and 22 (SCL) are used. However, you can adapt these to your needs at any time.

Then start the serial connection and load the example and the library onto the ESP32 device.

# start rshell connection
$ rshell -p /dev/cu.usbserial-0001

# upload files and folder
/YOUR/LOCAL/PATH> cp main.py /pyboard/
/YOUR/LOCAL/PATH> cp -r lib/ /pyboard/

The example device/path /dev/cu.usbserial-0001 could be different for you! Please adapt before your execute the commands!

Usage

# start the Python REPL
/YOUR/LOCAL/PATH> repl

Now press the keys CTRL + d on your local device, to trigger the soft-reset of the ESP32. If there are no errors, you should see the string "Start hand gestures:" in the terminal after a very short time.

Entering REPL. Use Control-X to exit.
>
MicroPython v1.20.0 on 2023-04-26; ESP32 module with ESP32
Type "help()" for more information.
>>> 
>>> 
MPY: soft reboot
Sensor initialized
Start hand gestures:

Now move your hand or just fingers in front of the sensor. Here few examples:

Gesture: 4 left
Gesture: 8 right
Gesture: 1 up
Gesture: 2 down
Gesture: 32768 counter clockwise continues
Gesture: 32768 counter clockwise continues
Gesture: 16384 clockwise continues
Gesture: 16384 clockwise continues

Additional information:

micropython-i2c-gr10_30's People

Contributors

lupin3000 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.