Skip to Content
All case studies

Case study · Railway · ESP32 PLC 57R

Comfort on board. Energy data that waits for coverage.

Light, ventilation and A/C on board. Energy data over 4G LTE-M.

6parameters to control and monitor
3sensor types connected to the PLC
18 / 33inputs and outputs on the ESP32 PLC 57R
LTE-M4G link to the control unit, with a local buffer

The carriage stays comfortable. The PLC keeps the numbers.

When coverage drops, the data waits on board.

This case describes a railway operator that wanted to control and monitor its train carriages. It does not name the operator, the line or the trains. The original installation used an M-Duino 54ARA with an integrated GPRS module. This page shows the same system built today with an ESP32 PLC 57R and a 4G LTE-M (LTE Cat M1) board: what one controller does inside a carriage, not where the train is.

The challenge

Safe, efficient and comfortable carriages. And the energy in numbers.

The customer manages a railway network. Its main goal was a control and monitoring system for the train carriages of the company, for the safety, efficiency and comfort of passengers and staff on board. The case lists six parameters: lighting, ventilation, air conditioning, temperature, humidity and energy.

01

Light where it is needed

Ambient light in a carriage changes all the time. The lighting must follow the real light level, not a fixed schedule.

02

Climate in range

The values inside the carriage must stay within the established ranges. If they leave them, ventilation and air conditioning must react.

03

Energy you can measure

The operator wants to see the energy consumption of each wagon, find ways to reduce it, and plan maintenance with data.

04

A link that comes and goes

The data travels over a mobile network to a control unit. When coverage is lost, the data must not be lost with it.

Six parameters, one controller

Lighting, ventilation, air conditioning, temperature, humidity and energy on one ESP32 PLC 57R with a 4G LTE-M communication board.

How it works

Three loops: light, climate, energy.

Each loop shows one part of the system. Move the sliders and press the buttons. The panels are illustrative simulations: light levels, temperatures, ranges, limits and record times are examples, not data from the installation.

Loop 1 · Light

A light sensor tells the PLC when to switch the lighting.

A light sensor measures the ambient light level in the carriage. The PLC opens or closes the light circuit, so the lighting follows what the carriage needs. The case also says the lighting can be dimmed as required, without more detail. A typical way to do it: two light levels, one to close the circuit and one to open it, so the lights do not flicker at the limit. Move the light level in the panel.

  • Light sensor inside the carriage, connected to the PLC
  • The PLC opens or closes the light circuit
  • Example: on below 150 lx, off above 300 lx
Light sensorESP32 PLC 57RLight circuit
420 lx
Ambient light0
Light circuit0
Lighting0
DAYLIGHTLIGHTS ON

Illustrative simulation. Example values, no data from the installation. Example rule: the PLC closes the light circuit below 150 lx and opens it above 300 lx. The gap avoids switching on and off at the limit.

Loop 2 · Climate

Out of range, the PLC starts ventilation or air conditioning.

A temperature and humidity sensor monitors the values inside the carriage all the time. When the values go outside the established ranges, the PLC activates the ventilation and/or the air conditioning. The case also lists an alert to maintenance staff after a dangerous temperature rise. A typical way to do it: high humidity starts the ventilation, high temperature starts the air conditioning, and a higher limit sends an alert. Move the sliders.

  • One sensor for temperature and humidity
  • Ventilation and/or air conditioning when a value leaves its range
  • Alert to maintenance staff after a dangerous temperature rise
T/H sensorESP32 PLC 57RVentilationA/C
23 °C
45 %
Temperature0
Humidity0
Ventilation0
Air conditioning0
IN RANGEVENTILATIONAIR CONDITIONINGBELOW RANGEALERT TO MAINTENANCE

PLC decisions (example)

    Illustrative simulation. Example values, no data from the installation. Example ranges: 20 to 26 °C and 30 to 60 % humidity. Alert to maintenance above 35 °C. The real ranges are not published.

    Loop 3 · Energy

    Energy data goes out over 4G LTE-M. Without coverage, it waits on board.

    A voltage sensor connected to the PLC measures the energy consumption of the wagon. The PLC sends the data to a control unit over the mobile network: 4G LTE-M on the ESP32 PLC 57R, GPRS in the original installation. If coverage is lost, the PLC keeps the data on board until the connection is restored, and then sends it automatically. In the original installation, the buffer was the SD card of the controller. Press Lose coverage, wait, then restore it.

    • Voltage sensor on the wagon supply, connected to the PLC
    • Energy data to a control unit over 4G LTE-M
    • Local buffer during loss of coverage, automatic sending after
    Voltage sensorESP32 PLC 57RControl unitBuffer0
    4G LTE-M link0
    Records sent0
    Records in buffer0
    SENDINGNO COVERAGE: KEPT ON BOARDSENDING THE BUFFER

    Energy records (example)

      Illustrative simulation. Example values, no data from the installation. Example: one energy record per minute, time sped up. The case does not publish the record period or the data format.

      Code example: ESP32 PLC datalogging with a buffer when the network is down

      System architecture

      How does an ESP32 PLC with 4G LTE-M control and monitor a train carriage?

      Three sensors connect to the ESP32 PLC 57R: light, temperature and humidity, and voltage. The PLC drives the light circuit, the ventilation and the air conditioning of the carriage. It sends the energy data to a control unit over 4G LTE-M, and keeps it in a local buffer while there is no coverage.

      Railway carriage control and energy monitoring with an ESP32 PLC and 4G LTE-MControl unitenergy dataTrain carriage4G LTE-MLTE Cat M1 boardLight sensorambient lightT/H sensortemperature, humidityVoltage sensorenergy consumptionInputsESP32 PLC 57R4G LTE-M · program in the PLCLocal bufferdata without coverageLight circuitopens or closesVentilationout of rangeAir conditioningout of rangeOutputsOne possible layout. The case does not publish the signal types, the protocol or the set points.Control unitenergy data4G LTE-MLTE Cat M1 boardTrain carriageLight sensorambient lightT/H sensortemperature, humidityVoltage sensorenergy consumptionInputsESP32 PLC 57R4G LTE-M · program in the PLCLocal bufferdata without coverageLight circuitopens or closesVentilationout of rangeAir conditioningout of rangeOutputsOne possible layout. The case does not publishthe signal types, the protocol or the setpoints.
      Sensor inputsOutputs to the carriage loads4G LTE-M dataLocal buffer and example elements
      Signals and data
      SignalBetweenTypePurpose
      Ambient lightBetweenLight sensor → ESP32 PLC 57RTypeInputPurposeLight level in the carriage. Signal type not published
      Temperature and humidityBetweenT/H sensor → ESP32 PLC 57RTypeInputPurposeValues inside the carriage, compared with the established ranges
      VoltageBetweenVoltage sensor → ESP32 PLC 57RTypeInputPurposeEnergy consumption of the wagon
      Light circuitBetweenESP32 PLC 57R → lightingTypeOutputPurposeOpens or closes the light circuit
      Ventilation and A/CBetweenESP32 PLC 57R → ventilation, air conditioningTypeOutputPurposeStart when temperature or humidity leave their ranges
      Energy dataBetweenESP32 PLC 57R → control unitType4G LTE-MPurposeConsumption data of the wagon. Protocol not published. GPRS in the original installation
      Data bufferBetweenESP32 PLC 57R → local storageTypeOn boardPurposeKeeps the data during loss of coverage. Sent automatically when the link is back. SD card in the original installation
      Maintenance alertBetweenESP32 PLC 57R → maintenance staffTypeNot publishedPurposeDangerous temperature rise or a lighting problem

      Why it works

      One controller on board. Data that arrives late, not never.

      4G LTE-M on the PLC

      The ESP32 PLC 57R takes a 4G (M1)-NB1 IoT LTE communication board. No separate modem in the carriage. The original installation chose a controller with an integrated GPRS module for the same reason.

      Store and forward

      Without coverage, the data stays on board. When the link is back, the PLC sends it automatically. The control unit gets the data later, instead of losing it.

      Decisions on board

      Light and climate rules run in the PLC, next to the sensors and the loads. The mobile link carries data. It does not switch the lights.

      Mixed I/O on one unit

      18 inputs and 33 outputs on the ESP32 PLC 57R. One possible split: the 12 analog inputs for the sensors, the 24 relays for the loads, the 9 analog outputs if a load needs a reference.

      Data for maintenance

      Continuous values from every carriage help to find faults in lighting, ventilation and air conditioning, and to plan the work before a failure.

      Open and modular

      Programmed with the Arduino IDE, with no licence fees. The ESP32 PLC grows with up to 127 expansion modules over I2C.

      Hardware

      ESP32 PLC 57R with a 4G LTE-M board.

      ESP32 PLC 57R, industrial PLC based on ESP32 for DIN rail

      ESP32 PLC 57R with the 4G (M1)-NB1 IoT LTE board

      An ESP32 based industrial PLC for DIN rail, with analog inputs for the sensors, relays for the loads and an optional 4G LTE Cat M1 communication board for the data link to the control unit.

      Role
      Light and climate control, energy data over 4G LTE-M
      Inputs
      18: 12 analog/digital (0-10 V, 11-bit), 6 digital optoisolated
      Outputs
      33: 24 relays, 9 analog/digital/PWM (0-10 V)
      Mobile link
      Communication board 4G (M1)-NB1 IoT LTE (u-blox SARA-R412M), option
      Other comms
      Ethernet, Wi-Fi, Bluetooth LE, RS-485, RS-232, I2C, SPI
      Built in
      Real-time clock
      Power
      12 to 24 Vdc, DIN rail

      The original installation used an M-Duino 54ARA with an integrated GPRS module (26 inputs, 25 outputs), no longer in the web shop. On the product page, choose the 4G (M1)-NB1 IoT LTE board as communication board 1.

      Questions about this case

      How does an ESP32 PLC control lighting, ventilation and air conditioning in a train carriage?

      With sensors and simple rules on board. A light sensor tells the PLC when to open or close the light circuit, and a temperature and humidity sensor tells it when to start the ventilation and/or the air conditioning: when the values leave the established ranges. On the ESP32 PLC 57R, the sensors go to the 0-10 V analog inputs and the loads to the relays. The ranges of the installation are not published. The panels on this page use example values.

      What happens to the data when the train loses mobile coverage?

      The PLC keeps it on board until the connection is restored, and then sends it automatically. This is store and forward. In the original installation, the buffer was the SD card of the controller. A typical way to build it: add a timestamp from the real-time clock to each record, write it to local storage, send the oldest records first when the link returns, and delete or mark each record only after the control unit confirms it. See the ESP32 PLC datalogging example with a buffer and our SD card basics for an industrial PLC.

      Can a voltage sensor alone measure energy consumption?

      The case names a voltage sensor that measures the energy consumption of the wagons. Energy is power over time, and power is voltage times current (and power factor in AC). So the voltage needs a current measurement, or a fixed known load, to give energy. A common choice is an energy meter with a pulse output or Modbus RTU on RS-485, which the ESP32 PLC can read. The case does not publish the rest of the measuring chain.

      Why 4G LTE-M instead of GPRS for a new railway project?

      GPRS runs on 2G networks, and some mobile operators have switched off 2G or plan to do it. Before a new project, check coverage and end dates on your routes, in every country the trains cross. LTE Cat M1 (LTE-M) is made for IoT devices and supports handover between cells, so it suits a moving train. The ESP32 PLC 57R takes a 4G (M1)-NB1 IoT LTE board (u-blox SARA-R412M). The store and forward logic stays the same.

      Which standards apply to electronics on board a train?

      In Europe, electronic equipment on rolling stock usually follows EN 50155 (environment, power supply, tests) and EN 50121-3-2 (electromagnetic compatibility). Fire safety follows EN 45545-2. The case does not say how the installation was certified. Ask your operator for the requirements before you design. Our engineers can review them with you.

      Which parts of this case are facts, and which are examples?

      Facts of the original case: a railway network operator, a control and monitoring system for train carriages, an M-Duino 54ARA with an integrated GPRS module, a light sensor that makes the PLC open or close the light circuit, a temperature and humidity sensor that starts ventilation and/or air conditioning out of range, a voltage sensor for energy consumption, data sent to a control unit, and an SD card buffer during loss of coverage with automatic sending after. Current option on this page: the ESP32 PLC 57R with a 4G LTE-M board. Examples: light levels, temperature and humidity ranges, the alert limit, record times and the data format.

      Download the case study

      4-page PDF with the challenge, the logic, the architecture and the hardware. No form required.

      Similar project?

      Tell us about your vehicles and your data. An engineer will answer.

      Tell us what you need to control on board, which sensors you have, how the data must reach your control centre and where coverage drops on your routes. We will tell you which controller fits, how to wire it and how to keep the data safe while the link is down.

      • You get an answer from our technical team
      • I/O count and controller sizing for your carriage
      • ESP32, Arduino or Raspberry Pi based PLCs