os

os.log(text)

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

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.

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

os.reboot()

Triggers an immediate reboot of the device.

os.reboot();

os.getVersion()

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

os.getVersion();

os.getHW()

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

os.getHW();

os.getTick()

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

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

os.getUnix()

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.

os.getUnix();

os.resetOnDisconnect(boolean)

Prevents the device from automatically resetting when it goes offline.

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.

-- 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);