/MuHack-Badge

Official repository for MuHack Badge

Primary LanguagePythonGNU Affero General Public License v3.0AGPL-3.0

MuHack-Badge

Official repository for MuHack Badge.

Badge startup

The board features an RP2040 as main microcontroller running micropython. Its job is to setup and stream data from the Bosh Sensor Hub BHI106(B), as well as controlling the LEDs.

Hardware/ folder contains the KiCad project

Software/ folder contains the BOSS system and the sketches for the ESP32 (WIP)

NOTE: The software is still in development, so expect A LOT OF bugs and missing features.

Features

  • RP2040 MCU
  • ESP32 MCU
  • BHI160B sensor hub
  • 14 WS2812B RGB LEDs
  • USB, I2C and UART interfaces
  • WiFi/BT connectivity
  • Two buttons and one buzzer

BHI Sensor Hub

The BHI160B is a 6-axis sensor hub with a 3-axis gyroscope and a 3-axis accelerometer. It automagically fuses the data from the two sensors and it provides a quaternion and a rotation matrix as output. The BHI160B is also able to detect some gestures and it can be used to detect the orientation of the board. The BHI160B is connected to the RP2040 through I2C and it is used to stream data from the gyroscope and accelerometer.

Basic block diagram

We can divide the board in three main subsystems: the RP2040, the ESP32 and the BHI160B. The RP2040 is the main microcontroller of the board and it is used to control all the hardware stuff, like the LEDs, the buttons and the buzzer. It is also used to communicate with the BHI160B and the NFC.

The BHI160B takes care of the BMM150 and eventually optional sensors.

Optionally, it is possible to add an ESP32 and communicate with it through 5 GPIO pins (e.i. setting up an UART and interrupts lines).

Here a simplified block diagram of the board:

Block Diagram

Getting started

One you have obtained a board, the first thing to do is to upload the MicroPython firmware.

Since it is used the same chip of the Raspberry Pi Pico, you can use the official firmware from the MicroPython website and follow the official guide to upload it: https://micropython.org/download/RPI_PICO/

Once you have uploaded the firmware, you can connect to the board using a serial terminal (e.g. screen, minicom, etc) and start playing with it: now you have a fully functional MicroPython board!

The next step is to upload the BOSS system: the BOSS system is a small firmware written in MicroPython that runs on the RP2040 and it is used to setup the BHI160B and stream data from it. It also provides a simple CLI system to use the badge.

To upload the BOSS system, simply copy all the file within the Software/BOSS/ folder to the board and reboot it. Don't forget to copy the BHY folder too! It contains the BHI160B driver and comes from another repository.

You should now have a fully functional badge! You can use the serial console to interact with the BOSS system or you can use the headless mode to run some simple example applications.

Badge rotate

Chagelog v2

  • Added USB connector for the ESP32
  • Added NFC subsystem
  • Completely reworked the power system
  • Added more LEDs for battery status and esp32
  • Added a button for the ESP32
  • WIP: firmware update for better BHI support

Chagelog v1

  • Initial release

TODOs:

  • Connect the interrupt line of BHI to the RP2040
  • Invert TX/RX of UART between ESP32 and RP2040
  • Change to a bigger footprint of ESP32 debug port
  • Maybe add two button for boot sel and reset for the ESP32
  • Change Remove battery switch
  • Improve silkscreen text size
  • Add silkscreen label for many things (pinout, battery polarity, etc)
  • Expose BHI's internal I2C and interrupt line (for future sensors)
  • Move I2C pull-up resistor
  • Add leds and diods polarity
  • Remove power inductor (or change to an available one)
  • Maybe add a way to switch LEDs data line to the ESP32 instead of the RP2040
  • Docs and code comments
  • Remove the D16 Schottky Diode from the battery line
  • Maybe add some more cap to prevent brown-out when disconnecting USB power
  • Add a method within BHY library to stop every sensor
  • Add NFC subsystem
  • Add USB connector for the ESP32

Special Thanks to: @gcammisa and Paolino