Beginner
10 min

Achieve exceptional load control and monitoring with four CRR05-1A and PIC32MX470F512H

Project with four reed relays for precise load control and monitoring

Relay 7 Click with 6LoWPAN clicker

Published Jun 18, 2024

Click board™

Relay 7 Click

Dev Board

6LoWPAN clicker

Compiler

NECTO Studio

MCU

PIC32MX470F512H

Turn ON and OFF devices or circuits using a low-power control signal from a microcontroller

A

A

Hardware Overview

How does it work?

Relay 7 Click is based on the CRR05-1A, a CRR series reed relay from Standex Electronics, a component known for its ultra-miniature SMD design and high insulation resistance. This Click board™ features four relays, each equipped with four terminals for load connections that are controlled via these relays. Beneath each relay is an orange LED indicator that illuminates to signal when the relay is active, serving as an operational status indicator. This setup provides clear and immediate feedback on the status of each relay, enhancing user control and system monitoring. This Click board™ is ideal for test and measurement (ATE) equipment, instrumentation, and telecommunications applications, highlighting high reliability and long life due to the relays' fully sealed

contacts. The CRR05-1As also feature a high insulation resistance of a typical 1013Ω. Its electrical specifications include a coil voltage of 5VDC, a coil resistance of 150Ω, a single-pole single-throw normally open (SPST-NO, 1 Form A) contact form, and maximum rated power of 10W/170VDC/0.5A. Control and communication between the relays and the host MCU are managed via the PCA9538A port expander, which uses an I2C communication interface. This device supports both Standard and Fast modes, with frequencies up to 400kHz. The PCA9538A's I2C address can be configured through the ADDR SEL jumpers, allowing flexible integration with various MCU systems. The PCA9538A also uses an RST pin and INT pins of the mikroBUS™ socket. The RST pin

ensures the registers and I2C-bus state machine remain in their default settings until this pin is set to a HIGH logic state, where the device returns to normal operational status. The INT is an interrupt pin, enabling the host MCU to detect user-specified events through the I2C interface. This Click board™ can operate with either 3.3V or 5V logic voltage levels selected via the VCC SEL jumper. This way, both 3.3V and 5V capable MCUs can use the communication lines properly. Also, this Click board™ comes equipped with a library containing easy-to-use functions and an example code that can be used as a reference for further development.

Relay 7 Click hardware overview image

Features overview

Development board

6LoWPAN Clicker is a compact starter development board that brings the flexibility of add-on Click boards™ to your favorite microcontroller, making it a perfect starter kit for implementing your ideas. It comes with an onboard 32-bit PIC microcontroller, the PIC32MX470F512H from Microchip, a USB connector, LED indicators, buttons, a mikroProg connector, and a header for interfacing with external electronics. Along with this microcontroller, the board also contains a 2.4GHz ISM band transceiver, allowing you to add wireless communication to your target application. Its compact design provides a fluid and immersive working experience, allowing access anywhere

and under any circumstances. Each part of the 6LoWPAN Clicker development kit contains the components necessary for the most efficient operation of the same board. In addition to the possibility of choosing the 6LoWPAN Clicker programming method, using USB HID mikroBootloader, or through an external mikroProg connector for PIC, dsPIC, or PIC32 programmer, the Clicker board also includes a clean and regulated power supply module for the development kit. The USB Micro-B connection can provide up to 500mA of current for the Clicker board, which is more than enough to operate all onboard and additional modules, or it can power

over two standard AA batteries. All communication methods that mikroBUS™ itself supports are on this board, including the well-established mikroBUS™ socket, reset button, and several buttons and LED indicators. 6LoWPAN Clicker is an integral part of the Mikroe ecosystem, allowing you to create a new application in minutes. Natively supported by Mikroe software tools, it covers many aspects of prototyping thanks to a considerable number of different Click boards™ (over a thousand boards), the number of which is growing every day.

6LoWPAN clicker double side image

Microcontroller Overview

MCU Card / MCU

default

Architecture

PIC32

MCU Memory (KB)

512

Silicon Vendor

Microchip

Pin count

64

RAM (Bytes)

131072

Used MCU Pins

mikroBUS™ mapper

NC
NC
AN
Reset
RD6
RST
ID COMM
RE5
CS
NC
NC
SCK
NC
NC
MISO
NC
NC
MOSI
Power Supply
3.3V
3.3V
Ground
GND
GND
NC
NC
PWM
Interrupt
RD0
INT
NC
NC
TX
NC
NC
RX
I2C Clock
RD10
SCL
I2C Data
RD9
SDA
Power Supply
5V
5V
Ground
GND
GND
1

Take a closer look

Schematic

Relay 7 Click Schematic schematic

Step by step

Project assembly

PIC32MZ clicker front image hardware assembly

Start by selecting your development board and Click board™. Begin with the 6LoWPAN clicker as your development board.

PIC32MZ clicker front image hardware assembly
GNSS2 Click front image hardware assembly
Prog-cut hardware assembly
GNSS2 Click complete accessories setup image hardware assembly
Micro B Connector Clicker Access - upright/background hardware assembly
Necto image step 2 hardware assembly
Necto image step 3 hardware assembly
Necto image step 4 hardware assembly
Necto image step 5 hardware assembly
Necto image step 6 hardware assembly
Flip&Click PIC32MZ MCU step hardware assembly
Necto No Display image step 8 hardware assembly
Necto image step 9 hardware assembly
Necto image step 10 hardware assembly
Debug Image Necto Step hardware assembly

Track your results in real time

Application Output via Debug Mode

1. Once the code example is loaded, pressing the "DEBUG" button initiates the build process, programs it on the created setup, and enters Debug mode.

2. After the programming is completed, a header with buttons for various actions within the IDE becomes visible. Clicking the green "PLAY" button starts reading the results achieved with the Click board™. The achieved results are displayed in the Application Output tab.

DEBUG_Application_Output

Software Support

Library Description

This library contains API for Relay 7 Click driver.

Key functions:

  • relay7_set_relay - This function sets the desired state of the selected relay.

  • relay7_reset_device - This function performs a hardware reset of the device.

  • relay7_get_interrupt - This function returns the interrupt pin logic state.

Open Source

Code example

This example can be found in NECTO Studio. Feel free to download the code, or you can copy the code below.

/*!
 * @file main.c
 * @brief Relay 7 Click example
 *
 * # Description
 * This example demonstrates the use of the Relay 7 click board by toggling the relay state.
 *
 * The demo application is composed of two sections :
 *
 * ## Application Init
 * Initialization of I2C module and log UART.
 * After driver initialization, the app executes a default configuration.
 *
 * ## Application Task
 * The demo application toggles the state of all relays every 5 seconds. 
 * The results are sent to the UART terminal, where you can monitor their changes.
 *
 * @author Nenad Filipovic
 *
 */

#include "board.h"
#include "log.h"
#include "relay7.h"

static relay7_t relay7;
static log_t logger;
static relay7_relay_state_t relay_state = RELAY7_STATE_CLOSE;

void application_init ( void ) 
{
    log_cfg_t log_cfg;  /**< Logger config object. */
    relay7_cfg_t relay7_cfg;  /**< Click config object. */

    /** 
     * Logger initialization.
     * Default baud rate: 115200
     * Default log level: LOG_LEVEL_DEBUG
     * @note If USB_UART_RX and USB_UART_TX 
     * are defined as HAL_PIN_NC, you will 
     * need to define them manually for log to work. 
     * See @b LOG_MAP_USB_UART macro definition for detailed explanation.
     */
    LOG_MAP_USB_UART( log_cfg );
    log_init( &logger, &log_cfg );
    log_info( &logger, " Application Init " );

    // Click initialization.
    relay7_cfg_setup( &relay7_cfg );
    RELAY7_MAP_MIKROBUS( relay7_cfg, MIKROBUS_1 );
    if ( I2C_MASTER_ERROR == relay7_init( &relay7, &relay7_cfg ) ) 
    {
        log_error( &logger, " Communication init." );
        for ( ; ; );
    }
    
    if ( RELAY7_ERROR == relay7_default_cfg ( &relay7 ) )
    {
        log_error( &logger, " Default configuration." );
        for ( ; ; );
    }
    
    log_info( &logger, " Application Task " );
}

void application_task ( void ) 
{
    for ( uint8_t relay_sel = RELAY7_SEL_REL1; relay_sel <= RELAY7_SEL_REL4; relay_sel++ )
    {
        if ( RELAY7_OK == relay7_set_relay( &relay7, relay_sel, relay_state ) )
        {
            log_printf( &logger, " Relay %d ", ( uint16_t ) relay_sel );
            if ( RELAY7_STATE_OPEN == relay_state )
            {
                log_printf( &logger, " normally open state\r\n" );
            }
            else
            {
                log_printf( &logger, " normally close state\r\n" );
            }
        }
        Delay_ms ( 1000 );
    }
    relay_state = ~relay_state;
    Delay_ms ( 1000 );
}

int main ( void ) 
{
    /* Do not remove this line or clock might not be set correctly. */
    #ifdef PREINIT_SUPPORTED
    preinit();
    #endif
    
    application_init( );
    
    for ( ; ; ) 
    {
        application_task( );
    }

    return 0;
}

// ------------------------------------------------------------------------ END

Additional Support

Resources

Love this project?

'Buy This Kit' button takes you directly to the shopping cart where you can easily add or remove products.