tinybasic
TinyBasic is a lightweight BASIC interpreter for MCU, enabling instant script-based control without recompiling firmware, with GPIO, files, display, and network
TinyBasic is a lightweight BASIC interpreter and runtime environment designed to run directly on microcontrollers (MCUs). It allows users to write, modify, and execute control logic instantly—without recompiling or re-uploading firmware. While preserving classic BASIC syntax, TinyBasic extends it with modern MCU features such as GPIO control, filesystems, displays, MQTT networking, and Ethernet connectivity.
At its core, TinyBasic transforms an MCU from a static firmware target into an interactive, script-driven runtime system.
What Problem Does TinyBasic Solve?
Traditional MCU development follows a rigid loop:
Edit C/C++ source code
Compile
Flash firmware
Reboot
Test
TinyBasic removes this cycle.
With TinyBasic, developers can:
Enter BASIC code directly on the device
Execute logic immediately
Adjust behavior in real time
Persist programs without reflashing firmware
This makes TinyBasic especially suitable for education, rapid prototyping, device control, and interactive IoT systems.
System Architecture
In this design, BASIC programs never access hardware directly.
All hardware interaction is abstracted through a precompiled runtime layer.
Why TinyBasic Is Suitable for Real-Time Control
Deterministic Execution Model
TinyBasic is explicitly designed to behave predictably:
No garbage collection
Variables and strings remain in fixed memory locations
No runtime memory relocation
This guarantees consistent execution timing, making TinyBasic suitable for real-time and control-oriented applications.
Compile-Time Feature Binding
Platform capabilities are defined at compile time using configuration headers such as hardware-arduino.h.
#define ARDUINOEEPROM
#define ARDUINOSD
#define ARDUINOMQTT
#define ARDUINOTFT
#define ARDUINOETH
These switches determine:
Which libraries are included
Which BASIC commands are available
Which hardware resources the runtime can access
BASIC scripts cannot alter this configuration, ensuring system stability and reproducibility.
Networking and MQTT Model
TinyBasic treats networking as a stream, equivalent to serial ports or files.
From the BASIC programmer’s perspective, networking requires no knowledge of sockets, TCP/IP, or MQTT internals. Communication is handled entirely through OPEN, PRINT, INPUT, and NETSTAT.
Ethernet and WIZnet Perspective
Architecturally, TinyBasic aligns well with WIZnet Ethernet controllers.
Stream-oriented I/O model
Hardware TCP/IP offloading reduces MCU load
Stable, deterministic wired communication
Natural fit for MQTT-style messaging
The runtime accesses Ethernet through the standard Arduino Ethernet library, which supports WIZnet W5100 and W5500 devices. While TinyBasic does not hardcode a specific chip, its design fully benefits from WIZnet’s hardware TCP/IP approach.
Example: MQTT-Based Sensor Publishing
This BASIC program reads an analog input, converts it to text, and publishes it over MQTT—without compiling or flashing new firmware.
Standalone TinyBasic Computer
TinyBasic can scale beyond embedded control into a fully standalone computer.
Typical configurations include:
ESP32
VGA output (FabGL)
PS/2 keyboard
SD card storage
Audio output
Boot Model
All coding, execution, and storage can be performed without a connected PC.
Limitations
No MQTT TLS or authentication
Network configuration fixed in C code
Polling-based I/O model
Not suitable for high-throughput data transfer
These trade-offs are intentional and consistent with TinyBasic’s deterministic design goals.
Key Takeaway
TinyBasic is not just a retro BASIC interpreter.
It is a lightweight, deterministic runtime environment for microcontrollers, enabling instant execution of control logic, interactive IoT behavior, and standalone embedded systems.
TinyBasic turns an MCU into a programmable, interactive runtime platform.
Original Source
GitHub: https://github.com/slviajero/tinybasic
Manual: https://github.com/slviajero/tinybasic/blob/main/MANUAL.md
