Programming Karyni

Program Karyni in the language of your choice
 

Karyni can be programmed in a variety of programming languages, ranging from simple and easy to use graphical languages (based on Scratch), to more advanced and developer-friendly ones. Below are some of the programming languages for use with Karyni, along with a simple WiFi “Hello World” program. Many more languages are supported by the ESP32 SoC on Karyni Core board, and many are still under development.

  • Arduino
  • Platformio
  • Bare Metal C++ with ESP-IDF
  • MicroPython
  • Lua RTOS
  • Espruino (Javascript Interpreter)
  • Visuino

“Hello World” Program

The “Hello World” program demonstrated in the languages below initializes the Serial port at 115200 baud, and prints “Hello World” while blinking the red part of the RGB LED. This is a very basic getting started program.

Check out our “Application Samples” for more useful and involved programs, or have a look at the examples on “arduino-esp32” github repository!

[ Screenshot of webpage served by demo application ]

Arduino

Arduino core for the ESP32 SoC used in Karyni is a derivative of the main ESP-IDF (bare metal coding framework) to make programming easier for beginners (and seasoned alike). It abstracts much of the underlying code-base into functions and libraries that are easy to use and understand.

Installation:

  • Download Arduino IDE from https://www.arduino.cc/en/Main/Software
  • Install ESP32 core by following instructions at https://github.com/espressif/arduino-esp32#installation-instructions
  • Try out the example below!

“Hello World” example program:

  • Open a blank Arduino IDE window.
  • In ‘Tools’ menu, go to ‘Board’ and select ‘ESP32 Dev Module’
  • In the same menu, go to ‘Port’, and select the correct port for your Karyni board. (see ‘Identifying Karyni Port’)
  • Copy and paste the code below into the Arduino IDE, replacing whatever is already there.
  • Alternatively, download the source file here, extract it into your Arduino sketchbook (usually located in ‘Documents/Arduino’), and open it in Arduino IDE. (You may need to set the ‘Board’ and ‘Port’ again.)
  • Finally press the “upload” button (arrow pointing to the right)

Source Code:

Platformio

Platformio is an open source ecosystem for developing IoT programs. It runs on Atom (a hackable text editor, by GitHub) and is usable cross-platform. Platformio eases the development flow by providing many useful features like GitHub integration, Code completion, Code navigation, Code formattin, File manager, Terminal, etc. on the IDE itself. platformio has full support for Espressif ESP32 development and provides the following frameworks.

Frameworks supported by Platformio for Karyni (ESP32):

  • Arduino
  • ESP-IDF
  • Pumbaa
  • Simba

Installation:

“Hello World” example program:

The example project given below is based on the Arduino framework for ‘espressif32’ platform in platformio.

  • Download and unzip the project file below in your PlatformIO projects directory (Documents/Platformio on Windows)
  • In the file manager on PlatformIO IDE, right click and select “Add project folder”
  • Select the folder that you just unzipped.
  • Connect Karyni via USB
  • Press the Upload button (arrow pointing towards right)
  • PlatformIO will download ‘espressif32’ platform, and ‘Arduino’ framework if these hadn’t been downloaded earlier, so hold tight, this may take a while!
  • After compiling the program, PlatformIO will try to automatically locate the COM port of your Karyni and begin uploading!

Source Code:

Download the PlatformIO project here.

ESP-IDF

ESP-IDF is the IoT Development Framework developed by Espressif (the company that designed ESP32 SoC used on Karyni!). This is the official developent framework for ESP32 chip. ESP-IDF provides a bare-metal development based on C, suitable to professionals, and those requiring a low-level control of the ESP32.

Installation:

Follow the installation instructions for ESP-IDF at the GitHub repository:
https://github.com/espressif/esp-idf#setting-up-esp-idf

“Hello World” example program:

  • Download and unzip the project file below in a build directory of your choice
  • Open terminal and navigate to the directory you just unzipped
  • Run ‘make menuconfig’ to select the correct serial port for Karyni
  • Run ‘make flash’ to compile and flash the project to Karyni

Source Code:

Download the ESP-IDF project here.

MicroPython

MicroPython is a python 3 implementation for microcontrollers. The ESP32 MicroPython port is based on the main MicroPython project authored by Damien George. Micropython provides a runtime environment for running and testing your programs on-the-fly on Karyni, since it is an ‘interpreted language’. What this means, is that you don’t need to wait for your programs to compile and upload each time you make a change. Just run it!

Installation:

  • Download the MicroPython ESP32 firmware from here: http://micropython.org/download#esp32
    Or download the firmware hosted by us (this might be outdated!): MicroPython ESP32 Firmware
  • Use the Karyni uploader (or alternatively use the ESP32 Flash Download Tool) to upload the downloaded .bin file to address: ‘0x1000’

Built-in ‘help()’ command:

  • Open the serial terminal of your choice (we recommend ‘PuTTY‘), and connect to Karyni’s Serial port at 115200 baud.
  • Hit the reset button on Karyni, and you should see some messages on the Serial terminal
  • Type ‘help()’ and enter to see a minimal help screen along with some examples.
  • More resources can be found at http://docs.micropython.org/.

Downloads:

Example “Hello World!” program:

  • Type in the code below onto the Serial terminal, paying special note to the indentation.
  • Once the code has been typed completely, the Red LED will start to blink. But since the blinking is coded in a while loop that will run forever, the terminal will be unusable untill it is stopped. Press ctrl+c to stop the program.
  • Alternatively, you can use the uPyCraft IDE to save the code below in a file called blink.py, and upload it to Karyni. Have a look at the documentation for uPyCraft here.

blink.py

MicroPython

MicroPython is a python 3 implementation for microcontrollers. The ESP32 MicroPython port is based on the main MicroPython project authored by Damien George. Micropython provides a runtime environment for running and testing your programs on-the-fly on Karyni, since it is an ‘interpreted language’. What this means, is that you don’t need to wait for your programs to compile and upload each time you make a change. Just run it!

Installation:

Download the MicroPython ESP32 firmware from here: https://github.com/micropython/micropython-esp32
Or download the firmware hosted by us (this might be outdated!): MicroPython ESP32 Firmware

Upload the firmware to your Karyni using our Karyni uploader to address: 0x1000

Built-in ‘help()’ command:

  • Open the serial terminal of your choice, and connect to Karyni
  • Hit the reset button on Karyni
  • You should see some messages on the Serial terminal
  • Type ‘help()’ followed by enter (CR+LF) to see a minimal help screen. There are some examples here that you can follow.

Example “Hello World!” program:

Source Code:

Copyright © Karyni 2017 - 2023 Intelener Srl