:::info Sample code
A working example is available on GitHub — [nodejs/plugin/os_info](https://github.com/obniz/obniz/tree/master/examples/nodejs/plugin/os_info).
:::

## os.log(text)

Outputs a string (data) to the device's serial console.

```lua
os.log("hello world");

```

## os.wait(milliseconds)

Pauses the execution of the OS for a specified duration. Note that this does not put the device into a low-power sleep mode, so power consumption remains unchanged.

The internet connection is maintained during the wait. However, if a duration exceeding several tens of seconds is specified, it may be flagged as an anomaly, potentially resulting in a disconnection or a device reboot.

```lua
os.wait(1000); -- 1,000msec wait

```

## os.reboot()

Triggers an immediate reboot of the device.

```lua
os.reboot();

```

## os.getVersion()

Returns the OS version as a string (e.g., `"7.0.0"`).

```lua
os.getVersion();

```

## os.getHW()

Returns the hardware type identifier as a string (e.g., `"iekilo1"`).

```lua
os.getHW();

```

## os.getHeap()

Returns the memory status of the device as three numbers, in bytes.

> Available for OS7.1.0 and later

1. Current free heap size
2. Minimum free heap size since boot
3. Largest contiguous free block. An allocation larger than this fails even if the total free heap is enough.

```lua
local free, minFree, largest = os.getHeap();
os.log("free=" .. free .. " min=" .. minFree .. " largest=" .. largest);

```

## os.getTick()

Returns the number of milliseconds elapsed since the device started as a numeric value.

```lua
os.getTick(); -- system tick in msec 

```

## os.getUnixTime()

If the system clock has been synchronized via `obniz.setClock()` or `obniz.pingWait()` from JavaScript, this function returns the number of seconds elapsed since the Unix Epoch (January 1, 1970) as a numeric value.

### Important Note on Time Accuracy
* **Synchronized:** Returns the standard Unix timestamp (seconds).
* **Unsynchronized:** Returns the uptime in seconds (derived from `getTick()`).

To ensure accurate time-stamping for your data, please ensure the device has an active network connection for time synchronization or handle the relative tick value accordingly in your application logic.

```lua
os.getUnixTime();

```

## os.resetOnDisconnect(boolean)

Prevents the device from automatically resetting when it goes offline.

```lua
os.resetOnDisconnect(false); -- Disabling reset ensures the device won't reboot after disconnection, and queued data is preserved while offline.

```

## os.sleep(milliseconds, mode)

Transitions the device into a sleep state.

```lua
-- Mode 0: Deep sleep + External module sleep
os.sleep(5 * 1000, 0); 

-- Mode 1: Deep sleep + Without external module sleep
os.sleep(5 * 1000, 1); 

-- Mode 2: Light sleep + External module sleep
os.sleep(5 * 1000, 2); 

-- Mode 3: Light sleep + Without external module sleep
os.sleep(5 * 1000, 3); 

```
