Skip to content
All guides

IoT in Smart Production

The introductory lesson: the four layers of an IoT system, sensors and actuators, MQTT, dashboards and predictive maintenance — explained with a production line.

How can a factory know that a machine is going to fail before it actually breaks down? Keep this question in mind — by the end of the module you will have built a system that answers it.

From automation to the Internet of Things

You may already know PLCs: they control machines on a production line — start the conveyor, stop the press, open the valve. The Internet of Things (IoT) goes one step further. It connects machines and makes their data visible: in the control room, on a tablet, in the maintenance office. This is one of the key technologies of Industry 4.0.

In short: PLCs control machines. IoT connects them and turns their data into decisions.

The four layers of an IoT system

Every IoT system — from a smart thermostat to a whole factory — can be described in four layers. Here they are with the machine monitor you will build in the exercises:

Layer What it does On our production line
1. Device Sensors measure, a microcontroller decides, actuators act An ESP32 reads the motor temperature and vibration, switches the cooling fan and the alarm lamp
2. Connectivity Carries the data from the device to the rest of the system Wi-Fi and the MQTT protocol send the values to a broker
3. Platform Receives, stores and forwards the data Adafruit IO keeps every value as a feed with its history
4. Application Shows the data to people and lets them act A dashboard with gauges, a chart, alarm levels and a fan switch

The three exercises follow exactly this path: Exercise 1 builds the device, Exercise 2 adds connectivity, Exercise 3 adds the platform and the application.

Sensors and actuators

A sensor turns a physical quantity into an electrical signal — it is an input. An actuator turns a signal into an action in the physical world — it is an output.

Sensors (inputs) Typical use in production
Temperature / humidity Motors, ovens, paint booths, storage
Vibration Bearings, pumps, fans — early sign of wear
Proximity / light barrier Counting parts, detecting a jam on a conveyor
Current Energy use of a machine, overload
Sound, light, pressure Leaks, lighting, pneumatics
Actuators (outputs) Typical use in production
Relay Switches a fan, a pump or a heater
Motor / servo Moves a conveyor, a valve or a gate
Lamp, buzzer, display Warns the operator

Signals come in two kinds:

  • Digital — the sensor sends numbers as a sequence of bits. The DHT22 temperature sensor works this way.
  • Analogue — the sensor delivers a voltage that changes continuously. The ESP32 measures it as a number between 0 and 4095. Our potentiometer works this way.

The simplest decision a device can make is threshold logic: if the temperature is above 35 °C, switch the fan on. Exercise 1 is built on this idea.

MQTT: publish and subscribe

Machines on a network do not talk to each other directly. With MQTT, every device talks to one central server, the broker:

  • a publisher sends a message to a topic on the broker,
  • every subscriber of that topic receives the message.

The sensor does not need to know who is listening, and the dashboard does not need to know where the sensor is. That makes the system easy to extend — a new screen simply subscribes.

Topics are organised like folders in a topic tree:

factory/line1/press3/temperature
factory/line1/press3/vibration
factory/line1/press3/fan          ← commands to the machine
factory/line2/oven1/temperature

Two wildcards help when subscribing:

  • + replaces one level: factory/+/+/temperature receives every temperature in the factory.
  • # means everything below: factory/line1/# receives every message from line 1.

Topics are case-sensitive: Factory/… and factory/… are two different topics.

Dashboards and predictive maintenance

An IoT platform stores each data stream as a feed with its history. A dashboard turns these feeds into something people can understand in seconds: gauges, charts, status texts and switches.

Good dashboards use alarm levels instead of raw numbers, for example:

  • OK — everything normal,
  • WARNING — above 30 °C: keep an eye on it,
  • ALARM — above 35 °C or above 70 % vibration: act now.

The real value of the data lies in its history. Compare three ways of looking after a machine:

Strategy When do we act? Drawback
Reactive maintenance After the machine has broken down Unplanned stops, expensive repairs
Preventive maintenance On a fixed schedule (e.g. every 3 months) Parts are replaced even when they are still fine
Predictive maintenance When the data shows a trend towards failure Needs sensors, data and someone who reads it

If the vibration of a fan rises slowly over two weeks, maintenance can be planned for the next weekend — instead of an emergency on Monday morning. That is the answer to the question at the top of this page.

Examples from the SmartVET industry visits

During the project, the SmartVET partners visited manufacturers in Balıkesir — among them a cabin manufacturer and a transformer manufacturer. Use them to think about IoT in real production:

  • Cabin manufacturing involves cutting, welding, painting and assembly. Where could temperature and humidity sensors help the quality of a paint finish? How could part counters on the assembly line show where work piles up?
  • Transformer manufacturing involves winding, drying, assembly and electrical testing. Which values would you monitor during a long drying process? How could test results from every unit be collected automatically and compared over time?

For each idea, name the sensor, the topic you would publish it on, and who would look at the dashboard.

Practice: before the first exercise

Work in pairs:

  1. Assign the layers. In a smart factory there is a temperature sensor, a Wi-Fi access point, a cloud database, a tablet with a dashboard and a cooling fan. Which layer does each one belong to?
  2. Choose sensors and actuators for three problems: an overheating motor, a jam on a conveyor belt, energy wasted by machines left running.
  3. Write topics for a new machine, “drill2” on line 2, that publishes temperature and current and receives start/stop commands.
  4. Read a dashboard. The temperature of a motor was 28 °C every morning last week and is 33 °C this morning. Is maintenance needed? What would you check?

Ready? Start with the Wokwi quick start and then Exercise 1.

Key terms

Term Meaning
IoT Internet of Things: devices that measure, communicate and act over a network
Sensor / actuator Input that measures / output that acts
Microcontroller Small computer on one chip that runs the device program (here: ESP32)
MQTT Lightweight messaging protocol based on publish/subscribe
Broker Server that receives MQTT messages and forwards them to subscribers
Topic Address of a message, e.g. factory/line1/press3/temperature
Feed A data stream with its history on an IoT platform
Dashboard Screen that shows live data, history and controls
Predictive maintenance Planning maintenance from data trends before a failure happens