Hydraulic moving floor (BLE app)ESP32 PLC 38RBLECommunication
Control an industrial ESP32 PLC from a mobile app via BLE
Mobile machines — trailers, skids, portable hydraulic units — often have no network at all, yet operators expect to control them from a phone. The ESP32's built-in Bluetooth Low Energy turns the PLC itself into the HMI: this example exposes a Nordic UART service so any app (or nRF Connect for testing) can drive the hydraulic valves and read pressure and temperature live.
A tiny ASCII protocol over BLE UART
Commands arrive as
[M]1* frames (load / unload / stop) and telemetry is notified once per second as [T]23.5[P]120[C1]42. Human-readable frames make field debugging trivial: you can operate the machine from a generic BLE terminal before the app exists.4-20 mA sensors to engineering units
Pressure (0-250 bar) and temperature (5-90 °C) transmitters are read on analog inputs and converted with a two-line map. Out-of-range readings reveal a broken loop — a free wire-break detector that 4-20 mA gives you and 0-10 V does not.
Safety first
An overpressure check runs in every loop iteration regardless of what the app says: above 230 bar everything stops and the app receives an [E]SOBREPRESION event. Never let the UI be the safety layer.
A snippet from the implementation
Straight from the example as deployed on the ESP32 PLC 38R — copy it freely:
void setup() {
Serial.begin(115200);
pinMode(I_TEMP, INPUT); pinMode(I_PRES, INPUT);
pinMode(R_EVG, OUTPUT); pinMode(R_EVD, OUTPUT); pinMode(R_EVC, OUTPUT);
setMotion(MOTION_NONE);
BLEDevice::init("PLC-HIDRAULICO");
BLEServer *server = BLEDevice::createServer();
server->setCallbacks(new ServerCB());
BLEService *svc = server->createService(SERVICE_UUID);
txChar = svc->createCharacteristic(CHAR_TX_UUID, BLECharacteristic::PROPERTY_NOTIFY);
txChar->addDescriptor(new BLE2902());
BLECharacteristic *rxChar =
svc->createCharacteristic(CHAR_RX_UUID, BLECharacteristic::PROPERTY_WRITE);
rxChar->setCallbacks(new RxCB());
svc->start();
server->getAdvertising()->start();
Serial.println("BLE advertising as PLC-HIDRAULICO");
}The full example is a complete program — wiring header, setup and main loop — ready to adapt to your application.
Frequently asked questions
Do I need to write a mobile app?
Not to start: any BLE UART terminal (nRF Connect, Serial Bluetooth Terminal) can send the command frames. A dedicated app is a UX upgrade, not a requirement.
What is the BLE range?
Typically 10-30 m in the field. For longer distances consider WiFi AP mode or LoRaWAN — see the related tutorials.
Can I secure the connection?
Yes, BLE pairing with passkey can be enabled in the ESP32 BLE stack; for machines in public spaces it is recommended.