PYCO-WIFI
AI
-
mp_obj_t AI_readNsample(mp_obj_t points, mp_obj_t delay)
Read a specified number of analog input (AI) samples from all 8 channels.
- Parameters:
points – (int) Total number of sample points to read.
delay – (int) Maximum time to wait (in seconds) for the data to be available.
- Returns:
list of lists: Each sublist contains 8 float values (voltages in volts) for one sample across all channels.
-
mp_obj_t AI_readOnDemand()
Read voltage values from all 8 analog input (AI) channels on demand.
- Returns:
list of 8 float values: Each value represents the voltage (in volts) of one AI channel.
-
mp_obj_t AI_start(mp_obj_t sampling_rate, mp_obj_t points)
Start analog input (AI) data streaming for a specified number of samples and sampling rate.
- Parameters:
sampling_rate – (float) Sampling rate in Hz.
points – (int) Number of sample points to acquire.
- Returns:
int: WPC error code. Returns 0 on success, or a negative value on failure.
-
mp_obj_t AI_stop()
Stop the ongoing analog input (AI) data streaming.
- Returns:
int: WPC error code. Returns 0 on success, or a negative value on failure.
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.
BATTERY
-
mp_obj_t Batt_read()
Read the current battery voltage.
- Returns:
float: Battery voltage in volts.
DIO
-
mp_obj_t DI_readAllChannels()
Read states from all digital input (DI) channels.
- Returns:
list of 8 int values: Each value is 0 or 1, representing the state of a DI channel.
-
mp_obj_t DO_writeAllChannels(mp_obj_t value_list)
Write states to all digital output (DO) channels.
- Parameters:
value_list – (list of int) List of 8 values (0 or 1) for each DO channel.
- Returns:
int: WPC error code. Returns 0 on success, or a negative value on failure.
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_basicInfo()
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_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_close()
Close the Modbus slave TCP server.
- Returns:
int: WPC error code. Returns 0 on success, or a negative value on failure.
-
mp_obj_t ModbusSlave_inputRegisterWriteFloat(mp_obj_t reg, mp_obj_t float_data)
Write a float value to the input register at the specified address.
- Parameters:
address – (int) Input register address (41000-41499).
value – (float) Value to write.
- Returns:
int: WPC error code. Returns 0 on success, or a negative value on failure.
-
mp_obj_t ModbusSlave_inputRegisterWriteInt(mp_obj_t reg, mp_obj_t int_data)
Write an int value to the input register at the specified address.
- Parameters:
address – (int) Input register address (41000-41499).
value – (int) Value to write.
- Returns:
int: WPC error code. Returns 0 on success, or a negative value on failure.
-
mp_obj_t ModbusSlave_open()
Open the Modbus slave TCP server.
- Returns:
int: WPC error code. Returns 0 on success, or a negative value 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.