ITT Relay module

This laboratory is located in the office of ITT Group in Tallinn, Estonia.

Introduction

This laboratory can be used to practice controlling the relay module attached to the controller.

Prerequisites

For this laboratory, the student should understand basic MQTT concepts like topics, broker, subscribing and publishing. Also the basics of relays and where they can be used.

Technical details

This laboratory consists of a relay module attached to the ITT IoT controller module. The relay module is an electrically operated switch of the mains voltage. It means that it can be turned on or off, letting the current go through or not. Many relays use an electromagnet to mechanically operate the switch and provide electrical isolation between two circuits.

Sensors

This laboratory does not have any sensors.

Specifications

  • 5V 1-Channel Relay interface board
  • Relay: SRD-05VDC-SL-C (AC 250V 10A, DC 30V 10A NO/NC)

Electrical connection

The signal lead of the servo is connected to GPIO5 pin of the controller.

Software, libraries and externals

  • ITTIoT libary - used to program the controller module.

Communication

The user can connect and program this controller using the Distancelab environment.

Limits

At the same time, only one user can program the controller. But all users connected to the Distancelab MQTT broker can subscribe and publish to topics specified.

Hands-on labs

Example code

#include <Arduino.h>
#include <ittiot.h>
 
#define RELAY_PIN 5
 
// If the message received switch relay
void iot_received(String topic, String msg)
{
  Serial.print("MSG FROM USER callback, topic: ");
  Serial.print(topic);
  Serial.print(" payload: ");
  Serial.println(msg);
  if(msg == "1")
  {
    digitalWrite(RELAY_PIN, HIGH);
  }
 
  if(msg == "0")
  {
    digitalWrite(RELAY_PIN, LOW);
  }
}
 
void iot_connected()
{
  Serial.println("MQTT connected callback");
  iot.subscribe("relay");
  iot.log("IoT relay example!");
}
 
void setup()
{
  Serial.begin(115200);
  Serial.println("Booting");
 
  iot.printConfig(); // print json config to serial
  iot.setup();
  pinMode(RELAY_PIN, OUTPUT);
}
 
void loop()
{
  iot.handle();  
  delay(200);
}

Support

info@ittgroup.ee

en/iot-open/remotelab/itt/relay.txt · Last modified: 2020/07/20 09:00 by 127.0.0.1
CC Attribution-Share Alike 4.0 International
www.chimeric.de Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0