This repository contains Arduino sketches and supporting files for a predictive maintenance platform
that reads multiple sensors and (optionally) transmits data via LoRa. The original project combined
multiple sensors in a single sketch; this repo splits each sensor/module into standalone sketches in
sensor_modules/ so you can test and deploy them independently.
sensor_modules/— Individual Arduino sketches for each sensor/module (PT100 MAX31865, analog pressure, MQ135 gas, energy meter, vibration sensor, LoRa comm, etc.).final_code/— The original merged sketch (kept for reference).communication_modules/— Example LoRa communication sketches/modules.datasheets/,images/— Supporting documents and wiring diagrams.
- Open the sketch you want in the Arduino IDE (for example
sensor_modules/temperature_sensor.ino). - Make sure the required libraries are installed (see "Dependencies" below).
- Configure wiring and pins in the sketch if your hardware differs from the defaults.
- Upload the sketch and open the Serial Monitor at 9600 baud to view sensor output.
- Adafruit MAX31865 library (for PT100):
Adafruit_MAX31865 - ModbusMaster library (for RS485 Modbus devices):
ModbusMaster - SoftwareSerial (built into Arduino core)
Install missing libraries using the Arduino Library Manager or via PlatformIO.
Use this section to list the exact hardware you're using for this deployment. Copy/paste and fill the items below so it's easier to reproduce or document later.
- Arduino board: Arduino Nano Every
- LoRa module: RYLR993 Lite
- Temperature Sensor: PT100 RTD + MAX31865 module
- Pressure Sensor: PYROTECH Piezoresistive Pressure Sensor
- Gas Sensor: MQ135
- Energy Sensor: Multispan MFM 13-M1 with in-built RS485
- Vibration Sensor: Wit WVB01485
- RS485 driver module: MAX485
- Power supply: Three Phase (415V), Single Phase (210V), DC (12-24V)
- Any level shifters or gates: Resistors (220 ohm, 250 ohm)
- LoRa Module (serial-AT style): TX -> Board RX (Serial1), RX -> Board TX (Serial1). Configure baud
in
lora_communication.ino. - MAX31865 (PT100): CS -> D10, DI -> D11, DO -> D12, CLK -> D13 (
temperature_sensor.ino). - Analog Pressure Sensor: OUT -> A0 (see
pressure_sensor.ino). - MQ135 Gas Sensor: AOUT -> A1 (see
gas_sensor.ino). Set RL_VALUE in code to match module. - MAX485 RS485 adapter: RO -> D2 (Software RX), DI -> D3 (Software TX), DE & RE -> D4 (direction control). A/B -> RS485 bus.
sensor_modules/temperature_sensor.ino— Reads PT100 temperature via Adafruit MAX31865. Includes fault detection and RTD resistance output.sensor_modules/pressure_sensor.ino— Reads analog pressure on A0 and maps ADC to pressure (placeholder mapping 0–10 bar). Calibrate for your sensor.sensor_modules/gas_sensor.ino— Reads MQ135 on A1. Prints ADC, voltage and computed Rs (kΩ). Optional auto-calibration to determine R0 in clean air.sensor_modules/energy_sensor.ino(orpower_meter_modbus.inoif present) — UsesSoftwareSerialModbusMasterto query the MFM 13-M1 power meter registers. Check modbus register addresses and slave ID in the sketch.sensor_modules/vibration_sensor.ino— Reads vibration sensor registers over Modbus (slave ID 0x50 by default), applies scaling multipliers for accel/speed/displacement, and prints values.communication_modules/lora_communication.inoorsensor_modules/lora_comm_from_unified.ino— Helper functions to send AT commands and transmit payloads via LoRa (AT-mode modules). Update serial pins/baud as required.
- PT100: tune
RREFandRNOMINALto match your PT100 and reference resistor. Use known temperature points to verify. - Pressure sensor: perform a two-point calibration using known pressures (0 and full scale) and compute a linear mapping.
- MQ135: requires sensor-specific curve to convert Rs/R0 to PPM for specific gases. Common approach: measure R0 in clean air, then use curve parameters from MQ135 datasheet or community libraries. Consider storing R0 in EEPROM after calibration.
- Modbus devices: verify register addresses and byte order. The
ModbusMasterlibrary used assumes register order used in the original sketch; adjust if you see incorrect values.