Awesome
flipper-zero-sao
Description
This project is for using the Flipper Zero to debug SAO devices. We use JavaScript on the Flipper Zero to interact with the various SAO devices. JavaScript is 500-800 times slower than C, but it has the advantage that we can update our script without needing a computer to compile our code!
You can update scripts using a bluetooth connected mobile phone (run the Flipper Zero mobile app and choose Options/File Manager/ext/apps/Scripts/SAO
), or using a text editor directly on the Flipper Zero. This is especially useful for quickly iterating or making minor tweaks to existing scripts.
You can use BadgeLife SAO Debug Tool from Thomas Flummer! I recommend adding a jumper between pins 3 and 5 so that SPI output can be used. I validated that SK9822 LEDs can be controlled when pin 3 and 5 are connected together.
Features
- I2C
- Connect SDA to Flipper pin 15
- Connect SCL to Flipper pin 16
- SPI OUTPUT
- Connect USER1 (aka GPIO1) to Flipper pin 2 (aka MOSI)
- Connect USER2 (aka GPIO2) to Flipper pin 5 (aka SCK)
- GPIO
- Connect USER1 (aka GPIO1) to Flipper pin 2
- Connect USER2 (aka GPIO2) to Flipper pin 5
Supported modules:
- AS1115 - I2C display driver for Spiral Matrix Petal
- AT24C32 - 32K I2C EEPROM
- ATtiny816 - As configured in Touchwheel app. :)
- LIS2DH12 - Accelerometer
- MCP23017 - 16-bit GPIO expander
- NXP NT3H2211W0FT1 - NFC module
- SK9822 - Addressable RGB LEDs
- WS2812B - Addressable RGB LEDs (required rebuulding the firmware)
Future modules:
- SSD1306 - OLED display (under development)
- LPUART
- Not encouraged, multiple SAO may have issue.
- Uses same pins as I2C
Installation
- Install the latest dev branch of Momentum firmware.
- Copy the SAO folder to your Flipper Zero (e.g.
SD Card/apps/Scripts
folder). - NOTE: For controlling WS2812B you will need to build custom Momentum firmware. I hope to submit a PR to Momentum in late November 2024, so that you won't have to do this step. Please see the custom firmware section below!
Running Samples
- sao_at24_w_sao69.js - Program the AT24C32 EEPROM with a SAO.69 formatted message.
- sao_at24_w_life.js - Program the AT24C32 EEPROM with a Badge.team LIFE formatted message.
- sao_at24_read.js - Read the AT24C32 EEPROM.
- sao_badge_tag_nfc.js - Programs URL to NFC tag and then reads UID and URL from tag.
- sao_blinky_loop.js - Blinks the 12 WS2812B LEDs on the Blinky Loop SAO by Thomas Flummer based on the angle of the SAO. Currently requires custom firmware.
- sao_sk9822.js - Control SK9822 RGB LEDs.
- sao_lis2dh12.js - Read the LIS2DH12 accelerometer.
- sao_mcp_out.js - Control a MCP23017 GPIO expander (Blinks GPIOA0-GPIOA5).
- sao_mcp_matrix.js - Control a MCP23017 GPIO expander (Input using a 4x4 button matrix on GPIOB0-7).
- sao_spiral_matrix_petal.js - Control the Sprial Matrix Petal SAO, sets the inner RGB LED and creates a spiral pattern from outer LEDs.
- sao_touchwheel.js - Sets RGB LED and reads touchwheel position from the Touchwheel SAO.
- sao_ws2812b.js - Control WS2812B RGB LEDs. Currently requires custom firmware.
Custom Firmware
NOTE: These steps are only required if you want to control WS2812B RGB LEDs!
First clone and build the Momentum firmware:
(NOTE: If you are running a Windows Command Prompt, use fbt
instead of ./fbt
)
git clone --recursive https://github.com/next-Flip/Momentum-Firmware.git
cd Momentum-Firmware
./fbt vscode_dist
./fbt updater_package
Next, overlay the files from the js_app folder in this repository to the Momentum firmware files in the applications/system/js_app
folder.
Make sure your Flipper Zero is plugged in to your computer, and that qFlipper and lab.flipper.net are not running. Then the following command to build and deploy the firmware to your Flipper Zero:
./fbt COMPACT=1 DEBUG=0 FORCE=1 flash_usb_full
Support
Feel free to reach out to me on Discord. My username is @codeallnight
and you can also tag me on any of the Flipper Firmware servers.
Support my work by buying me a coffee!