Modul 5 von 9 · 📖 4 min Lesezeit · ⏱ 30 min gesamt

FI-DV 05 IoT-Sensorik und Aktorik (EN)

Inhaltsverzeichnis (6 Abschnitte)
  1. Concepts and Background
  2. Architecture Diagram
  3. Practical Steps
  4. Common Pitfalls
  5. Further Resources
  6. Knowledge Check

FI-DV 05 IoT-Sensorik und Aktorik

In this module, you will learn the fundamentals of IoT sensors and actuators. You will understand the different sensor types, the process of analog-to-digital conversion, and the importance of bus systems such as CAN and RS-485 in practice. Additionally, you will acquire knowledge on configuring the appropriate drivers to efficiently read sensor data and control actuators.

The concepts conveyed form the basis for the construction and implementation of IoT solutions in industrial and commercial applications. You will be able to select suitable sensors and actuators for specific requirements and integrate them into existing infrastructures.

Concepts and Background

Sensor
A sensor is a component that converts physical or chemical quantities such as temperature, pressure, humidity, or motion into an electrical signal. In IoT systems, sensors serve as the input interface for capturing environmental data.
Actuator
Actuators are output components that convert electrical signals into physical actions. Examples include motors, valves, LEDs, or relays, which are used in IoT systems to control and influence the environment.
Analog-to-Digital Conversion (ADC)
The analog-to-digital conversion process converts continuous analog signals into discrete digital values. This step is essential because microprocessors and computers can only process digital data. The resolution is specified in bits (e.g., a 10-bit ADC can represent 1024 different values).
Bus Systems
Bus systems are communication protocols that allow multiple sensors and actuators to be connected via a common line. They reduce wiring complexity and enable standardized communication between components.
Drivers
Drivers are software components that serve as an interface between hardware (sensors/actuators) and the operating system or application. They translate system commands into signals understandable by the hardware and vice versa.

Architecture Diagram

flowchart TB
    subgraph IoT-Knoten
        A[Mikrocontroller] --> B[ADC]
        B --> C[Sensoren]
        A --> D[Digital I/O]
        D --> E[Aktoren]
        A --> F[Bus-Interface]
    end
    
    F --> G[CAN-Bus]
    F --> H[RS-485-Bus]
    
    G --> I[Gateway]
    H --> I
    
    I --> J[Cloud/Server]
    J --> K[Anwendung/Dashboard]

Practical Steps

  1. Install the necessary development tools for your microcontroller (e.g., Arduino IDE for ESP32/Arduino).
  2. Connect a temperature sensor (e.g., DS18B20) to the microcontroller according to the datasheet.
  3. Configure I2C communication for the sensor in the code:
    #include <Wire.h>
    #include <OneWire.h>
    
    OneWire oneWire(4);
    DallasTemperature sensors(&oneWire);
    
    void setup() {
      sensors.begin();
    }
    
    void loop() {
      sensors.requestTemperatures();
      float temp = sensors.getTempCByIndex(0);
      Serial.print("Temperatur: ");
      Serial.print(temp);
      Serial.println(" °C");
      delay(2000);
    }
  4. Implement CAN bus communication with a CAN controller (e.g., MCP2515):
    #include <mcp_can.h>
    #include <SPI.h>
    
    MCP_CAN CAN0(10);
    
    void setup() {
      Serial.begin(115200);
      while (CAN0.begin(MCP_ANY, CAN_500KBPS, MCP_PIN_8) != CAN_OK) {
        delay(100);
      }
      CAN0.setMode(MCP_NORMAL);
    }
    
    void loop() {
      if (CAN0.readMsgBuf(&len, &canId, buf)) {
        Serial.print("ID: ");
        Serial.print(canId);
        Serial.print(" Data: ");
        for (int i = 0; i < len; i++) {
          Serial.print(buf[i], HEX);
          Serial.print(" ");
        }
        Serial.println();
      }
    }
  5. Configure the RS-485 bus for communication with multiple devices:
    #include <SoftwareSerial.h>
    
    SoftwareSerial RS485(2, 3); // RX, TX
    
    void setup() {
      Serial.begin(9600);
      RS485.begin(9600);
    }
    
    void sendCommand(byte address, byte command) {
      RS485.write(address);
      RS485.write(command);
      RS485.write(0x0D); // CR
      RS485.write(0x0A); // LF
    }
    
    void loop() {
      sendCommand(0x01, 0x03); // Send request to device with address 1
      delay(1000);
    }
  6. Install and configure the driver for your specific sensor in the Linux system:
    sudo apt-get install i2c-tools
    sudo modprobe w1-gpio
    sudo modprobe w1-therm
    sudo i2cdetect -y 1
  7. Test the sensor output with a simple script:
    #!/bin/bash
    while true; do
      temp=$(cat /sys/bus/w1/devices/28-*/w1_slave | grep "t=" | cut -d'=' -f2)
      echo "Temperatur: $((temp/1000)).$((temp%1000/10)) °C"
      sleep 2
    done
  8. Integrate the collected data into an MQTT system for further processing:
    mosquitto_pub -t sensors/temperature -m "23.5"

Common Pitfalls

Further Resources

Knowledge Check

Four questions for self-assessment. Click on each question to see the correct answer and explanation.

What is the main function of an ADC in IoT systems?
  • A) Conversion of digital signals into analog signals
  • B) Conversion of analog sensor data into digital values
  • C) Amplification of weak electrical signals
  • D) Filtering of interference signals in communication

Correct Answer: B. An ADC converts analog sensor data into digital values because microprocessors can only process digital data.