PYCO-WIFI-MINI-AO

AO

mp_obj_t AO_writeAllChannels(mp_obj_t value_list)

Write voltages to all analog output (AO) channels.

Parameters:

value_list – (list of float) List of 8 voltages (-10.0 to 10.0 V each).

Returns:

int: WPC error code. Returns 0 on success, or a negative value on failure.

mp_obj_t AO_writeOneChannel(mp_obj_t channel, mp_obj_t value)

Write voltage to a single analog output (AO) channel.

Parameters:
  • channel – (int) AO channel index (0-7).

  • value – (float) Voltage to set (-10.0 to 10.0 V).

Returns:

int: WPC error code. Returns 0 on success, or a negative value on failure.

AHRS

mp_obj_t AHRS_getAcceleration()

Get 3-axis acceleration from AHRS.

Returns:

list of 3 float values: [x, y, z] acceleration in m/s^2.

mp_obj_t AHRS_getAngularVelocity()

Get 3-axis angular velocity from AHRS.

Returns:

list of 3 float values: [x, y, z] angular velocity in deg/s.

mp_obj_t AHRS_getOrientation()

Get 3-axis orientation (Roll, Pitch, Yaw) from the AHRS.

Retrieves the current estimated orientation angles from the Attitude and Heading Reference System (AHRS) and returns them in degrees.

Returns:

mp_obj_t: A tuple of 3 float values: [roll, pitch, yaw]. The values are in degrees, with the following typical ranges:

  • Roll: [-180° to +180°]

  • Pitch: [-90° to +90°]

  • Yaw: [-180° to +180°]

mp_obj_t AHRS_getOrientation_rad()

Get 3-axis orientation (Roll, Pitch, Yaw) from the AHRS system in radians.

Retrieves the current estimated orientation angles from the Attitude and Heading Reference System (AHRS) and returns them using the base unit of radians.

Returns:

mp_obj_t: A MicroPython tuple of 3 float values: [roll, pitch, yaw]. The values are in radians, with the following typical ranges:

  • Roll: [-pi to pi rad]

  • Pitch: [-pi/2 to pi/2 rad]

  • Yaw: [-pi to pi rad]

mp_obj_t AHRS_start()

Start AHRS data acquisition.

Returns:

int: WPC error code. Returns 0 on success, or a negative value on failure.

mp_obj_t AHRS_stop()

Stop AHRS data acquisition.

Returns:

int: WPC error code. Returns 0 on success, or a negative value on failure.

BATTERY

mp_obj_t Batt_read()

Read the current battery voltage.

Returns:

float: Battery voltage in volts.

LED

mp_obj_t LED_reset()

Turn off all LEDs.

Returns:

int: WPC error code. Returns 0 on success, or a negative value on failure.

mp_obj_t LED_setBlue()

Set the blue LED on.

Returns:

int: WPC error code. Returns 0 on success, or a negative value on failure.

mp_obj_t LED_setGreen()

Set the green LED on.

Returns:

int: WPC error code. Returns 0 on success, or a negative value on failure.

mp_obj_t LED_setRed()

Set the red LED on.

Returns:

int: WPC error code. Returns 0 on success, or a negative value on failure.

OLED

mp_obj_t OLED_networkInfo()

Show SSID, IP, serial number, and firmware version on the screen.

Returns:

int: WPC error code. Returns 0 on success, or a negative value on failure.

mp_obj_t OLED_fwVersion()

Show firmware version on the screen.

Returns:

int: WPC error code. Returns 0 on success, or a negative value on failure.

mp_obj_t OLED_erase()

Clear all content from the OLED display screen.

Returns:

int: WPC error code. Returns 0 on success, or a negative value on failure.

mp_obj_t OLED_writeLine(mp_obj_t write_data, mp_obj_t write_line)

Write text message to a specific line on the OLED display screen.

Parameters:
  • write_data – (str) Text to write on the screen.

  • write_line – (int) Line number on the screen (1 to 4).

Returns:

int: WPC error code. Returns 0 on success, or a negative value on failure.

mp_obj_t OLED_writeXY(mp_obj_t x_position, mp_obj_t y_position, mp_obj_t write_data)

Write message on the screen at a specific location.

Parameters:
  • x_position – (int) The x-axis position (0-127).

  • y_position – (int) The y-axis position (0-63).

  • write_data – (str) The message to display.

Returns:

int: WPC error code. Returns 0 on success, or a negative value on failure.

MODBUS MASTER

mp_obj_t ModbusMaster_open(mp_obj_t host, mp_obj_t slave)

Open the Modbus master TCP client and connect to a slave.

Parameters:
  • host – (str) Host IP address or host name.

  • slave – (int) Modbus slave ID.

Returns:

int: WPC error code. Returns 0 on success, or a negative value on failure.

mp_obj_t ModbusMaster_close()

Close the Modbus master TCP client.

Returns:

int: WPC error code. Returns 0 on success, or a negative value on failure.

mp_obj_t ModbusMaster_readCoils(mp_obj_t address, mp_obj_t count)

Read coils from the slave.

Parameters:
  • address – (int) Coil starting address.

  • count – (int) Number of coils to read.

Returns:

list of int: List of coil states (0 or 1), or error code if failed.

mp_obj_t ModbusMaster_readDiscreteInputs(mp_obj_t address, mp_obj_t count)

Read discrete inputs from the slave.

Parameters:
  • address – (int) Discrete input starting address.

  • count – (int) Number of inputs to read.

Returns:

list of int: List of input states (0 or 1), or error code if failed.

mp_obj_t ModbusMaster_readHoldingRegister(mp_obj_t address, mp_obj_t count)

Read holding registers from the slave.

Parameters:
  • address – (int) Holding register starting address.

  • count – (int) Number of registers to read.

Returns:

list of int: List of register values, or error code if failed.

mp_obj_t ModbusMaster_readInputRegister(mp_obj_t address, mp_obj_t count)

Read input registers from the slave.

Parameters:
  • address – (int) Input register starting address.

  • count – (int) Number of registers requested.

Returns:

list of int: List of registers or error code if failed.

mp_obj_t ModbusMaster_writeCoil(mp_obj_t address, mp_obj_t value)

Update a single coil.

Parameters:
  • address – (int) The output address.

  • value – (int) The status to write.

Returns:

int: WPC error code. Returns 0 on success, or a negative value on failure.

mp_obj_t ModbusMaster_writeRegister(mp_obj_t address, mp_obj_t value)

Update a single register.

Parameters:
  • address – (int) The register address.

  • value – (int) The value to write.

Returns:

int: WPC error code. Returns 0 on success, or a negative value on failure.

mp_obj_t ModbusMaster_writeMultiCoils(mp_obj_t address, mp_obj_t value_list)

Update multiple coils.

Parameters:
  • address – (int) The address of the first coil.

  • value_list – (list) List of bit value.

Returns:

int: WPC error code. Returns 0 on success, or a negative value on failure.

mp_obj_t ModbusMaster_writeMultiRegisters(mp_obj_t address, mp_obj_t value_list)

Update multiple registers.

Parameters:
  • address – (int) The starting address.

  • value_list – (list) List of bytes to write.

Returns:

int: WPC error code. Returns 0 on success, or a negative value on failure.

MODBUS SLAVE

mp_obj_t ModbusSlave_open()

Open the Modbus Slave TCP server.

Initializes and starts the Modbus Slave TCP server to begin listening for incoming Master connection requests.

Returns:

int: WPC error code.

  • 0: Service started successfully (Success).

  • Negative value: Failed to start the service or an error occurred (Failure).

mp_obj_t ModbusSlave_close()

Close the Modbus Slave TCP server.

Shuts down the Modbus Slave TCP server, stopping all incoming connection handling and freeing associated network resources.

Returns:

int: WPC error code.

  • 0: Server was closed successfully (Success).

  • Negative value: Failed to close the server or an error occurred (Failure).

mp_obj_t ModbusSlave_getConnectStatus()

Get Modbus Slave TCP service connection status.

This function retrieves the active status of the internal TCP server handling the Modbus Slave communications.

Returns:

int: Service status code (WPC error code).

  • 0: Service is inactive or disconnected.

  • 1: Service is active or connected.

mp_obj_t ModbusSlave_getHoldingRegisterMap(mp_obj_t address_obj, mp_obj_t register_num_obj)

Get data from the Modbus Slave Holding Registers memory map.

Reads a specified number of 16-bit register values starting from the given Modbus 4xxxx address in the internal map structure.

Parameters:
  • address_obj – (int) Modbus starting register address, range is 40001-40500.

  • register_num_obj – (int) Quantity of registers to read.

Returns:

mp_obj_t: The u8 list containing the requested register values on success.

mp_obj_t ModbusSlave_setHoldingRegisterMap(mp_obj_t address_obj, mp_obj_t value_obj)

Set a single value in the Modbus Slave Holding Register map.

Writes a 16-bit integer value into the internal memory map structure corresponding to the specified Modbus 4xxxx register address. Since the internal map stores uint8_t, the value is split into two bytes.

Parameters:
  • address_obj – (mp_obj_t/int) The Modbus starting register address (e.g., 40001-40500).

  • value_obj – (mp_obj_t/int) The 16-bit integer value to be written to the register.

Returns:

mp_obj_t: WPC error code (int). Returns 0 on success, or an error code (e.g., 0xFF) on failure.

SYSTEM

mp_obj_t Sys_APMode()

Set the device to access point (AP) mode after reboot.

Returns:

int: WPC error code. Returns 0 on success, or a negative value on failure.

mp_obj_t Sys_convertF32To4U8(mp_obj_t value)

Convert a 32-bit float to a list of 4 unsigned 8-bit integers.

Parameters:

value – (float) Value to convert.

Returns:

list of int: List of 4 unsigned 8-bit integers.

mp_obj_t Sys_disableMain()

Prevent main.py from running automatically after reboot.

Returns:

int: WPC error code. Returns 0 on success, or a negative value on failure.

mp_obj_t Sys_enableMain()

Allow main.py to run automatically after reboot.

Returns:

int: WPC error code. Returns 0 on success, or a negative value on failure.

mp_obj_t Sys_getDAQHeapSize()

Get the current free heap size in bytes.

Returns:

int: Heap size in bytes.

mp_obj_t Sys_getDriverName()

Get the name string of the stand-alone Python driver.

Returns:

str: Driver name string.

mp_obj_t Sys_getDriverVersion()

Get the version string of the stand-alone Python driver.

Returns:

str: Version string.

mp_obj_t Sys_getGateway()

Get the device’s gateway address.

Returns:

list of 4 int values: [x, x, x, x] representing gateway address.

mp_obj_t Sys_getIP()

Get the device’s IP address.

Returns:

list of 4 int values: [x, x, x, x] representing IPv4 address.

mp_obj_t Sys_getMAC()

Get the device’s MAC address.

Returns:

list of 6 int values: [x, x, x, x, x, x] representing MAC address.

mp_obj_t Sys_getRTC()

Get the current real-time clock (RTC) time as a list.

Returns:

list of int: RTC time values.

mp_obj_t Sys_getSerialNumber()

Get the device serial number.

Returns:

str: Serial number string (8 characters).

mp_obj_t Sys_getSubmask()

Get the device’s subnet mask.

Returns:

list of 4 int values: [x, x, x, x] representing subnet mask.

mp_obj_t Sys_readFuncButton()

Read the current status of the function button.

Returns:

int: 0 if the button is pressed, 1 if released. Returns a negative value if not supported.

mp_obj_t Sys_reboot()

Reboot the device system.

Returns:

int: WPC error code. Returns 0 on success, or a negative value on failure.

mp_obj_t Sys_setIP(mp_obj_t value)

Set the device’s IP address.

Parameters:

value – (str) IP address string.

Returns:

int: WPC error code. Returns 0 on success, or a negative value on failure.

mp_obj_t Sys_setWifiPassword(mp_obj_t value)

Set the Wi-Fi password for the device.

Parameters:

value – (str) Password string.

Returns:

int: WPC error code. Returns 0 on success, or a negative value on failure.

mp_obj_t Sys_setWifiSSID(mp_obj_t value)

Set the Wi-Fi SSID for the device.

Parameters:

value – (str) SSID string.

Returns:

int: WPC error code. Returns 0 on success, or a negative value on failure.

TCP CLIENT

mp_obj_t TCPClient_close()

Close the TCP client connection.

Returns:

int: WPC error code. Returns 0 on success, or a negative value on failure.

mp_obj_t TCPClient_open(mp_obj_t host_ip, mp_obj_t port)

Open a TCP client connection to a specified address and port.

Parameters:
  • host – (str) Host IP address or host name.

  • port – (int) Port number to connect to.

Returns:

int: WPC error code. Returns 0 on success, or a negative value on failure.

mp_obj_t TCPClient_read(mp_obj_t read_len)

Read bytes from the server.

Parameters:

size – (int) Maximum number of bytes to read.

Returns:

list of int: List of bytes read from the buffer.

mp_obj_t TCPClient_writeString(mp_obj_t write_data)

Write a string to the server.

Parameters:

value – (str) String to write.

Returns:

int: Number of bytes written.

mp_obj_t TCPClient_writeU8List(mp_obj_t u8_list)

Write a list of unsigned 8-bit integers to the server.

Parameters:

u8_list – (list of int) List of unsigned 8-bit integers to write.

Returns:

int: Number of bytes written.

TEMPERATURE

mp_obj_t Temperature_read()

Read the current temperature from the thermal sensor.

Returns:

float: Temperature in Celsius.