Skip to main content

A small Ethernet modules example package

Project description

Python API for Numato Ethernet Relay/GPIO Modules

This Python API can be used to control Numato Ethernet Relay expanders, Numato Ethernet GPIO expanders and Numato PoE Relay expanders.

  • Controlling the Relays "On" or "Off" state
  • Configure ports as input or output port
  • Write to output ports
  • Read from input ports
  • Read integer values from ADC input ports

numato-eth allows to control relay modules (ON or OFF states) and gpio states. This module is compatible with all Numato ethernet-relay and gpio, PoE - relay and gpio series.

Requirement

The module requires the minimum configuration :

  • Windows-10(64 bits) and later
  • Linux 64-bits
  • Python3.6 and later

License

This API is licensed under the GNU Lesser General Public License v3.0. See LICENSE for full license text.

Installation

Install the latest release:

pip install numato_eth

Usage CLI

Expected output:

Linux :

❯ python3 -m numato_eth.eth --deviceIP=<ip> --username=<username> --password=<password>
Device IP: 192.168.10.5 | id: 00000000 | ver: 00000005 | ports: 16 | eol: '\r\n'

Windows :

❯ python -m numato_eth.eth --deviceIP=<ip> --username=<username> --password=<password>
Device IP: 192.168.10.5 | id: 00000000 | ver: A0M06.01 | ports: 16 | eol: '\r\n'

How to use it

The command line to drive relays are :

Windows :

python -m numato_eth.eth --deviceIP=<ip> --username=<username> --password=<password> --cmd=<string to drive relays> --relays=8 

Linux :

python3 -m numato_eth.eth --deviceIP=<ip> --username=<username> --password=<password> --cmd=<string to drive relays> --relays=8  

Note : For all CLI commands use python3 when using in Linux Systems and python in Windows Systems.


Parameters are :

--deviceIP : the ip (default is 192.168.1.0) to connect the module

--username : the username (default is admin)

--password : the password (default is admin)

--cmd : the command to drive individual relays (default is "x")

--relays : the number of relays to drive (default is 4)

--gpios : the number of gpios (default is 8, if the module is gpio module)


A relay can receive two types of orders (OFF or ON). The order in the module is encoding by an ASCII character such as :

"c" : close the relay (OFF state)

"o" : open the relay (ON state)

"x" : do not change the current state of the relay


For example consider a 8 channel PoE Relay module :

  • 8 available relays : 0, 1, 2, 3, 4, 5, 6, 7 and 8
  • ip is 192.168.10.5
  • username and password is admin


command pattern examples for 8 channel Ethernet Relay module is given here,

To turn on all relays, string command is oooooooo and the command line is :

python -m numato_eth.eth --deviceIP=192.168.10.5 --username=admin --password=admin --cmd="oooooooo" --relays=8

To turn off all relays, string command is cccccccc and the command line is :

python -m numato_eth.eth --deviceIP=192.168.10.5 --username=admin --password=admin --cmd="cccccccc" --relays=8

To turn on the relay 0,1,2,3 and it does not matter about other ones, string command is ooooxxxx and the command line is :

python -m numato_eth.eth --deviceIP=192.168.10.5 --username=admin --password=admin --cmd="ooooxxxx" --relays=8

To turn on the relays 1, 3, 5 and 7 and it does not matter about other ones, string command is xoxoxoxo and the command line is :

python -m numato_eth.eth --deviceIP=192.168.10.5 --username=admin --password=admin --cmd="xoxoxoxo" --relays=8

Note : There is no command line interface command to control gpio modules.

List of Commands

  1. ver()
  2. info()
  3. id_get()
  4. id_set("x")
  5. usr_get()
  6. usr_set("x")
  7. pass_get()
  8. pass_set("x")
  9. reset()
  10. relay_on("x")
  11. relay_off("x")
  12. relay_read("x")
  13. relay_readall()
  14. relay_writeall("x")
  15. gpio_set("x")
  16. gpio_clear("x")
  17. gpio_read("x")
  18. gpio_status("x")
  19. gpio_iomask("x")
  20. gpio_iodir("x")
  21. gpio_writeall("x")
  22. gpio_readall()
  23. adc_read()
  24. notify_get()
  25. notify_set("x")
  26. reboot()
  27. gpio_setup("x","x")

Note:

  1. "x" is the parameter to be passed in the commands, please refer the "Sending Commnads" section in the user manual of the module for sending the right arguement and to understand the functioning of each command. Relay commands and some of the gpio commands are module specific.
  2. gpio_setup("x","x") command is only available for GPIO modules.

Usage API

The API can be used like:

Note : Refer the "Sending Commnads" document of the module to be controlled and pass the proper commands.

from numato_eth.eth import Eth_Module 

# Please change the number of Relays/Gpios and credentials (ipaddress, username, password) accordingly.
Device = Eth_Module(deviceIP="192.168.10.5", username="admin", password="admin", numberRelays=16)  //For gpio modules numberGpios=8

# To get the version of the module
Device.ver()

# To get the Device Id 
Device.id_get()

# To turn on all relays
Device.relay_writeall("ffff")

# To set a single Gpio & read the status
Device.gpio_set("0") 
Device.gpio_read("0")

#To turn on a single relay
Device.relay_on("F")
#Device.relay_off("014")  //For PoE module

#To Setup the gpio pin as In/Out in gpio modules
# To change the direction of any port
Device.gpio_setup([0],"OUT")       // [ ports ] and IN/OUT : direction
Device.gpio_setup([1,3,8],"OUT")

# Enable notify
Device.notify_set(1)  // 0 - Disable and 1 - Enable notify feature

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

numato_eth-0.0.1.tar.gz (7.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

numato_eth-0.0.1-py3-none-any.whl (6.9 kB view details)

Uploaded Python 3

File details

Details for the file numato_eth-0.0.1.tar.gz.

File metadata

  • Download URL: numato_eth-0.0.1.tar.gz
  • Upload date:
  • Size: 7.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.4

File hashes

Hashes for numato_eth-0.0.1.tar.gz
Algorithm Hash digest
SHA256 c2a49fe0d620641a6f2de5eb8e99525a8fb941763e79f0ceb7687127c8a8bed9
MD5 779e1d8948a4cf7aad8a428f98189b06
BLAKE2b-256 1cf0d19570670fb0cf4620550012946a1e274fe4cd74646f425e7617a5a34dbd

See more details on using hashes here.

File details

Details for the file numato_eth-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: numato_eth-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 6.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.4

File hashes

Hashes for numato_eth-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 6157275598112d6d6c6096dd69972235d3171b87a298e34053b0fac021dbf69c
MD5 2e7f458ff3b83a8f4da1000cd14ac2c8
BLAKE2b-256 04fbb5f8e98dab7f50ebf5e2e82e1dad51dd3bf85dc0f35a8a2269a4a23da374

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page