This is an old revision of the document!


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. Relay module is an electrically operated switch of 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 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 //Peale Serial.begin ja enne iot.setup
  iot.setup();
  pinMode(RELAY_PIN, OUTPUT);
}
 
void loop()
{
  iot.handle();  
  delay(200);
}

Study scenarios

List study scenarios (hands-on labs), linking to the Dokuwiki pages with hands-on labs descriptions (there should be a separate page for each scenario). Classify each scenario and refer to the target group using starting keywords: * Beginners * Undergraduates * Masters * Professionals Note, assume that more professional group automatically contains less professional ones. Note - use language and as appropriate to the target group, i.e.:

  * Beginners: Elementary operations on the Arduino 2x16 LCD screen.
  * Undergraduates: Visualizing temperature and humidity on the remote screen.
  * Masters: Using power saving states to limit power consumption.

Support

Give some information on how to access help, how to get support in case of the trouble etc.

en/iot-open/remotelab/itt/relay.1545908022.txt.gz · Last modified: 2020/07/20 09:00 (external edit)
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