Wiznet makers

TheoIm

Published December 02, 2025 ©

60 UCC

27 WCC

7 VAR

0 Contests

0 Followers

0 Following

Original Link

tinybasic

TinyBasic is a lightweight BASIC interpreter for MCU, enabling instant script-based control without recompiling firmware, with GPIO, files, display, and network

COMPONENTS
PROJECT DESCRIPTION

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

 
BASIC Program
(.bas user scripts)
PRINT, INPUT, OPEN, IF, FOR, NETSTAT
        │
        ▼
TinyBasic Interpreter Core
- Token parser
- Execution loop
- Variable and array management
- Expression evaluator
        │
        ▼
Runtime / Hardware Abstraction Layer
(C/C++ compiled firmware)
- GPIO / ADC / Delay
- Display / Keyboard
- Filesystem (SD / EEPROM / LittleFS)
- Network (MQTT / TCP/IP)
        │
        ▼
MCU + Peripheral Hardware
AVR / ESP32 / RP2040 / SAMD / ARM
Ethernet / Wi-Fi / VGA / SD / PS2
 

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.

BASIC Program
   │  PRINT / INPUT / OPEN
   ▼
TinyBasic Stream Interface
   ▼
Network Stack
   ├─ Ethernet.h  → WIZnet W5100 / W5500
   └─ WiFi.h      → ESP8266 / ESP32

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.

 
TinyBasic Runtime
   ↓
Ethernet.h
   ↓
WIZnet W5100 / W5500

Example: MQTT-Based Sensor Publishing

 
10 REM Simple MQTT writer
20 AP = AZERO
100 OPEN &9, "iotbasic/data", 1
200 FOR I
210 A$ = "analog:" + STR(AREAD(AP))
220 PRINT &9, A$
230 IF NETSTAT<>3 THEN PRINT "No connection"
240 DELAY 3000
250 NEXT

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

 
Power ON
  ↓
TinyBasic Interpreter Start
  ↓
autorun.bas executed (if present)
  ↓
User interaction or autonomous logic

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

Wiki: https://github.com/slviajero/tinybasic/wiki

Documents
Comments Write