XN01 - Digital Inputs

XN01 - Digital Inputs

X-NODE Digital Inputs is a module that allows reading up to 8 digital inputs. It can read signals generated by push buttons, switches, or sensors through a configurable digital interface (UART/I2C), enabling multiple X-NODE Digital Inputs to be connected simultaneously and expanding the number of inputs a system can read from 8 up to 1016.

If you need to read digital signals with a voltage range from 5 to 24VDC, NPN or PNP type, check out our X-NODE XN26 - 4 x24V Input. (Resource in Spanish, English version coming soon...)

TABLE OF CONTENTS

I. How does it work?

The X-NODE Digital Inputs module has an integrated microcontroller that allows you to read various digital inputs without advanced hardware knowledge. You only need to send a series of ASCII commands via the UART serial communication protocol or using the I2C protocol, making the X-NODE compatible with any system based on a microcontroller, microprocessor, or industrial equipment. The module integrates an 8 position slider with lever-type switches that can toggle between ON<>OFF states, a 9 pin terminal block connector for AWG 26 to 18 cables, ideal for desktop testing and connecting external controls.

X-NODE Digital Inputs is compatible with the mikroBUS™ standard from Mikroe® for easy use with a large hardware development ecosystem. It also has JST connectors compatible with the Qwiic® standard from SparkFun® for quick and easy I2C communication between various modules and development boards.

II. Hardware description

  1. 9 pin terminal block connector for AWG 26 to 18 cables

  2. Slide switch

  3. JST connectors compatible with Qwiic®

  4. Hardware controller

  5. UART <> I2C communication ports

  6. X-NODE model

  7. X-NODE type

  8. mikroBUS™ standard connectors

  9. Hardware version: R2

  10. Main component in the X-NODE

III. Specification

Applications

Integration with IoT projects and general purpose use, such as reading state changes, sequences, or configuration of indicators and actuators in an electronic circuit or project.

Features

8 position slider with lever-type switches, electrical life up to 2000 cycles, insulation resistance up to 100 MΩ, and can operate in a temperature range from -10 °C to 80 °C. Terminal block for 8 external inputs and GND.

Interface

UART, I2C

Compatibility

mikroBUS™ standard and Qwiic® standard

Size

67.13 x 25.4 x 22 mm

Voltage

3.3 V

Warning! Never connect voltage sources to the inputs of the X-NODE Digital Inputs, doing so may damage the device. Use open-drain signals to interface with the device.

IV. Pinout

The following table shows the pinout of the X-NODE Digital Inputs according to the mikroBUS™ standard (shown in the two center columns).

V. Usage

For easy and quick use of the X-NODE, you can use the ASCII commands provided by the integrated hardware controller via UART serial communication or more advanced use via the I2C protocol.

UART Protocol

Configuration

UART communication uses the following settings:

  • Baud rate: 115,200 bps

  • Parity: None

  • Data bits: 8

  • Stop bits: 1

Syntax

The UART protocol allows sending instructions in plain ASCII text, each instruction consists of the X-NODE identifier, a command, and an end-of-line.

Identifier

The ID identifier consists of the X-NODE model, which can be found at point 6 in the Hardware Description section, and is complemented by an index, which can be a letter from A to Z (default is A). To connect more than one module of the same model in a system, you must configure a unique identifier for each module, allowing up to 26 modules of the same model to be connected via UART.

Command List

XN01A?

Checks if communication was successfully established. Response: OK

XN01A+V

Gets the current firmware version integrated in the X-NODE. Response: XN01A=Version Example: XN01A=0.1

XN01A+ID=(A-Z)

Changes the ID index to a different uppercase letter from A to Z. Once changed, you must use the new ID to change it again. Response: OK Send example: XN01C+ID=H

XN01A+TW=(1-126)

Changes the factory I2C address to a different one. The new address is written in decimal, selecting a value from 1 to 126. Response: OK Send example: XN01A+TW=28

XN01A+GS

Gets the status of each of the 8 inputs, either from the switches or the port. Returns 1 (High) and 0 (Low) depending on the state of each input. Input 1 is the first value on the left, interpreting the value from left to right. Response: XN01A=int1, int2, int3, int4, int5, int6, int7, int8 Example: XN01A=11011011

Advanced Commands

XN01A+ETW=(0-1)

Enables (1) or disables (0) the device's I2C interface. Note: This setting is volatile, disconnecting the device from power or sending the reset command will restore the I2C interface. Response: OK Send example: XN01A+ETW=0

XN01A+SLP

Enables deep sleep mode to reduce power consumption, during deep sleep, the device will not respond to UART commands. To wake the device, send a logic low (0) to the WAKEUP/UPDI pin. Response: OK Send example: XN01A+SLP

XN01A+RST

Resets the device, non-volatile values (e.g., ID, I2C address) will be retained, and volatile values will return to their default settings. Response: OK

End of Line

The X-NODE will only respond to a command when a set of end-of-line characters is sent, each command must end with these characters: <CR+LF>

  • CR means carriage return.

  • LF means line feed.

The combination of both characters is a common way for computers to represent a new line, for example, in a word processor to separate paragraphs.

For the X-NODE, the <CR+LF> characters are used to identify when a command has finished being sent. If the identifier matches the node, the command exists, and it ends immediately with <CR+LF>, then the node will send a response.

Depending on your system, you must configure the sending of these characters in different ways.

UART Arduino Framework Example

Example code for XC01 - R5. Check the manual to use our XC01 - R5 in Arduino IDE/PlatformIO

// This example shows the status of the inputs
// of the X-NODE. Slide the switch position
// to observe state changes.

#include "Arduino.h"

void setup()
{
  // Initialize serial communication
  Serial.begin(115200);

  // Initialize UART communication on mikroBUS port
  Serial2.begin(115200, SERIAL_8N1, 9, 10);
}

void loop()
{
    // Clear the buffer before sending the command
    while( Serial2.available() ) {
        Serial2.read();
    }

    // Send the command to read the inputs:
    // ID+GS:
    // Where the default ID is XN01A
    // The \r\n characters represent the
    // <CR+LF> in C-like languages
    Serial2.print( "XN01A+GS\r\n" );

    // Wait until a response is received
    String inputs = Serial2.readStringUntil('\n');

    // If the response starts with the ID
    // then communication was successful
    if ( inputs.startsWith( "XN01A=" ) ) {
        Serial.println( inputs );
    } else {
        Serial.println( "Error" );
    }

    delay( 1000 );
}

I2C Protocol

To establish communication, you must know the I2C address of the X-NODE, the factory value consists of the last two digits of the model after "XN". I2C addresses are usually represented in hexadecimal, while the X-NODE model is in decimal; make sure to use the correct number system.

Configuration

  • Communication speed: 100 kHz

  • Address: 7 bits

Note: Make sure you do not have another device with the same address on the I2C BUS. If so, remember that the X-NODE can change its I2C address with the XN01A+TW=(1-126) command.

Writing

To write to a register of the X-NODE Digital Inputs, the I2C controller must perform the following operations:

  1. Send a start condition: The controller generates a logic low (0) on the SDA pin while SCL remains high (1).

  2. Send the X-NODE address: The controller sends the 7-bit address.

  3. Send the operation type: The controller indicates if the operation is read (0) or write (1).

  4. Wait for an acknowledge (ACK) signal: The controller waits to receive a logic low (0) as confirmation (Acknowledgment) that a target with the sent address exists on the I2C BUS. If no response (1) is received, there was a communication error or the address is incorrect.

  5. Write n bytes of data: The controller writes in 8-bit (1 byte) sequences, MSB first, as many bytes as needed. The target will send an ACK signal for each byte written.

  6. Send a stop condition: The controller must release the I2C BUS by generating a logic high (1) on SDA while SCL is high (1).

Reading

To read from a register of the X-NODE Digital Inputs, the I2C controller must perform the following operations:

  1. Send a start condition: The controller generates a logic low (0) on the SDA pin while SCL remains high (1).

  2. Send the X-NODE address: The controller sends the 7-bit address.

  3. Send the operation type: The controller indicates if the operation is read (0) or write (1).

  4. Wait for an acknowledge (ACK) signal: The controller waits to receive a logic low (0) as confirmation (Acknowledgment) that a target with the sent address exists on the I2C BUS. If no response (1) is received, there was a communication error or the address is incorrect.

  5. Read n bytes of data: The target will send 8-bit (1 byte) sequences, MSB first, as many bytes as needed. Upon receiving a byte, the controller must generate an ACK signal to request another byte, or a NACK signal to indicate the end of transmission and request the target to release the BUS.

  6. Send a stop condition: The controller must release the I2C BUS by generating a logic high (1) on SDA while SCL is high (1).

Register List

In an I2C target, registers are memory addresses that allow configuring or obtaining data from the target. There are two types of operations: read (R) and write (W).

Register
Address (hexadecimal)
Type
No. Bytes
Description

INPUT

0x01

R

1

Each bit represents a logical state of an input, where the most significant bit (received first) corresponds to the state of input I8, following an order from highest to lowest.

STAT

0x37

R

1

XNODE status, 0x00 if there are no errors, any other value means communication error.

FW

0x38

R

3

Firmware version, in major, minor, and patch: 0x02.0x00.0x00

UART_ID

0x39

R/W - NV

1

Allows reading and writing the ID index to a different uppercase letter from A (0x41) to Z (0x5A)

TW_ADD

0x3A

R/W - NV

1

Allows reading and writing the device's I2C address to a different value from 1 (0x01) to 126 (0x7D). A reset or power-on sequence must happen for this changes to be applied

UART_EN

0x3B

W

1

Enables (0x01) or disables (0x00) the device's UART interface.

SLEEP

0x3C

W

1

Enables (0x01) or disables (0x00) deep sleep mode, the device will wake up if the controller writes the device's I2C address on the BUS.

RESET

0x3D

W

1

Writing 0x01 resets the device.

WHO_AM_I

0x3E

R

2

The first byte is the XNODE model, the second byte is the hardware revision

Non-volatile Registers (NV)

Non-volatile registers are stored in the device's EEPROM memory, meaning they retain their values even if the device is powered off.

INPUT Register Structure:

I2C Arduino Framework Example

Example code for XC01 - R5. Check the manual to use our XC01 - R5 in Arduino IDE/PlatformIO

#include <Arduino.h>
#include <Wire.h>

void setup()
{
  // Initialize serial monitor
  Serial.begin(115200);

  // Configure I2C communication pins
  Wire.setPins( 12, 13 );
  // Initialize I2C communication
  Wire.begin();

  // Select the register
  Wire.beginTransmission( 0x01 ); // Device address
  Wire.write( 0x01 ); // INPUT register address
  Wire.endTransmission();
}

void loop()
{
    uint8_t bytes_recv = 0;
    uint8_t inputs = 0;
    // Send start condition + address
    // + operation type + number of bytes to read
    bytes_recv = Wire.requestFrom( 0x01, 1 );

    // Confirm that 1 byte was received
    if ( bytes_recv != 1 ) {
        Serial.println( "Error" );
        delay( 1000 );
        return;
    }

    inputs = Wire.read();

    // Show the status in binary format (omits
    // leading 0's)
    Serial.print( "XN01A=" );
    Serial.println( inputs, BIN );

    delay( 1000 );
}

VI. Downloads

Last updated