-
Notifications
You must be signed in to change notification settings - Fork 2
Home
BlueScript is a small and efficient programming language designed specifically for microcontrollers.
While it currently supports only the ESP32 board, future updates will include support for a wider range of boards.
To start using BlueScript, you'll need the following:
-
ESP32 board
- Currently, only the ESP32-WROOM-32 module is supported.
- A computer running Windows, Linux, or macOS.
- A USB cable (USB A / micro USB B) to connect your ESP32 to your computer.
First, clone the BlueScript repository using Git:
git clone https://github.com/csg-tokyo/bluescript.git
-
Set up Docker and Docker Compose:
- Install Docker: Docker installation guide
- Install Docker Compose: Docker Compose installation guide
-
Start the BlueScript Local Server
docker compose up -d
-
Verify that the server has started successfully Open Google Chrome browser and access http://localhost:3000/.
You can see BlueScript REPL page on the browser.You can also run a REPL that executes a program on a PC. You can use this REPL without a microcontroller connected to your PC.
docker exec -it bluescript_server npm run shell
- Build the BlueScript runtime:
cd ./microcontroller/port/esp32/
docker run --rm -v $PWD:/project -w /project -u $UID -e HOME=/tmp espressif/idf:release-v5.0 idf.py build
- Install esptool:
pip install esptool
-
Connect your microcontroller to the computer via USB and check the serial port.
Common serial port naming patterns:- Windows: Ports start with
COM
. - MacOS: Ports start with
/dev/tty
. - Linux: Ports start with
/dev/cu
.
- Windows: Ports start with
-
Flash the BlueScript runtime to the ESP32 device:
cd ./build
esptool.py --chip esp32 -p $PORT -b 460800 --before=default_reset --after=hard_reset write_flash --flash_mode dio --flash_freq 40m --flash_size 4MB 0x1000 bootloader/bootloader.bin 0x10000 bluescript.bin 0x8000 partition_table/partition-table.bin
After setting up BlueScript, follow these steps to write and run a "Hello World" program:
-
Open Google Chrome browser and access http://localhost:3000/.
BlueScript REPL communicates with the microcontroller via Bluetooth, so the browser should be Google Chrome browser which only supports Web Bluetooth. -
Click the Start button.
You’ll be prompted to select a Bluetooth device. ChooseBLUESCRIPT
. -
Write the following code in the cell:
print("Hello world!");
- Click the execution button on the left side of the cell to run your code in the cell.
You can see "Hello world!" in the log area on the right side of the page.