Skip to content

Instantly share code, notes, and snippets.

@map7
Created September 20, 2023 13:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save map7/04afbfe817ad0a0d71ec8515176c41d6 to your computer and use it in GitHub Desktop.
Save map7/04afbfe817ad0a0d71ec8515176c41d6 to your computer and use it in GitHub Desktop.
mruby + ESP32 notes
- References
https://github.com/mruby-esp32/mruby-esp32
1. Install ESP-IDF Manually
[[https://docs.espressif.com/projects/esp-idf/en/release-v5.1/esp32/get-started/linux-macos-setup.html][Standard Toolchain Setup for Linux and macOS - ESP32 - — ESP-IDF Programming ...]]
a. Install required packages
: sudo apt-get install git wget flex bison gperf python3 python3-pip python3-venv cmake ninja-build ccache libffi-dev libssl-dev dfu-util libusb-1.0-0
b. Check python version, should be:
: python --version
: python3 --version
| | Installed |
|---------+-----------|
| python | 2.7.18 |
| python3 | 3.11.4 |
c. Get ESP-IDF (Cmake wrapper)
: mkdir -p ~/esp
: cd ~/esp
: git clone -b release/v5.1 --recursive https://github.com/espressif/esp-idf.git
d. Setup up the tools
: cd ~/esp/esp-idf
: ./install.sh esp32
e. Install tools
: /usr/bin/python3 /home/map7/esp/esp-idf/tools/idf_tools.py install
: cd ~/esp/esp-idf
: python3 tools/idf_tools.py install-python-env
f. Set up the environment variables
: . $HOME/esp/esp-idf/export.sh
- Notes
: Done! You can now compile ESP-IDF projects.
: Go to the project directory and run:
:
: idf.py build
2. Connect a good cable
Check that device /dev/ttyUSB0 is showing when you connect
3. Test ESP through Arduino with blink example = works
a. Device details
| Device | ESP32 Dev |
| Serial | /dev/ttyUSB0 |
b. Blink example
#+begin_src arduino
#define ONBOARD_LED 2
void setup() {
pinMode(ONBOARD_LED,OUTPUT);
}
void loop() {
delay(1000);
digitalWrite(ONBOARD_LED,HIGH);
delay(100);
digitalWrite(ONBOARD_LED,LOW);
}
#+end_src
c. Flash
NOTE: When flashing hold the 'BOOT' button when it says Connecting.
4. Test ESP32 with blink example (Python)
a. Setup environment (If not in your environment already)
: . $HOME/esp/esp-idf/export.sh
b. Change to examples dir
: cd /home/map7/esp/esp-idf/examples/get-started/blink
c. Configure GPIO port
: idf.py menuconfig
In the `Example Configuration` menu:
1. Select the LED type in the `Blink LED type` option.
* Use `GPIO` for regular LED blink.
2. Set the GPIO number used for the signal in the `Blink GPIO number` option.
3. Set the blinking period in the `Blink period in ms` option.
d. Build
: idf.py build
e. Flash
: idf.py -p /dev/ttyUSB0 flash monitor
5. Test ESP32 with mruby
a. Clone the mruby-esp32 repo to a new project (like dragonruby)
: cd ~/code
: git clone --recursive https://github.com/mruby-esp32/mruby-esp32.git
: cd mruby-esp32
b. Copy example
: cp main/examples/simplest.rb main/storage/main.rb
c. Build
: idf.py build
d. Flash
: idf.py -p /dev/ttyUSB0 flash monitor
- mRuby
- https://hackmd.io/@pySgLnmoQRGCAHO4NFCFag/HkVNLyh54?type=view
- Reset device
https://randomnerdtutorials.com/esp32-erase-flash-memory/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment