How to use the FMR10 Radar Sensor with an ESP32 PLC 14?

A complete guide to measuring liquid levels with ESP32 PLC
August 30, 2024 by
Boot & Work Corp. S.L., Arnau Tena

The Micropilot FMR10 radar sensor by Endress+Hauser is a small radar that offers continuous distance measurement, perfect for measuring liquid levels in tanks. In this blog, we'll explain how to use the FMR10 radar sensor with an ESP32 PLC 14, a powerful tool for industrial automation with ESP32.


Getting started with ESP32 PLC and required Software

To follow this blog, you'll need the Arduino IDE with Industrial Shields' libraries installed and Node-RED for data visualization. If you still don't have the Arduino IDE properly configured, we suggest you follow the steps starting at page 17 of the ESP32 PLC 14 manual.

Download ESP32 PLC 14 manual

If you don't have Node-RED installed yet, follow the first lesson of this free course:

Develop your SCADA Application based on Node-RED

How to connect the FMR10 Radar Sensor to an ESP32 PLC?

The FMR10 radar sensor can output measurement results in two ways: via Bluetooth or a 4-20mA analog input. To connect the FMR10 to an ESP32 PLC, you can use Bluetooth or directly read the mA from the output circuit. If you choose to connect via Bluetooth, you'll need the Endress+Hauser SmartBlue app for Android, which allows you to configure various aspects of the radar sensor, such as sensitivity and calibration. More information can be found here:

SmartBlue app

If you prefer to operate the radar by reading the analog signal, we have used an ESP32 PLC 14 with its analog inputs configured to 4-20mA. This configuration allows you to read the radar measurements directly into the PLC. This is how the circuit looks:


This is how circuits looks

You can use any other of our PLCs with analog inputs, but then you will need to convert the radar output to 0-10V.

Creating a Node_RED flow to display Radar Sensor measurements

Before we code the program for the PLC, we'll create a Node-RED flow to display the measurements. This flow will have a "mqtt in" node, three "function" nodes, two "text" nodes and two "chart" nodes. Then add the "fmr10" topic to the "mqtt  in" node. Set the one of the "chart" nodes' X axis to display the last 5 minutes, and set the other "chart" to be a bar chart. For two of the "function" nodes, add this code:

msg.payload = parseFloat(msg.payload).toFixed(2) + "m";
return msg;

And for the remaining "function" node, this code:

msg.payload = 8-msg.payload;
return msg;

The flow should look like this:

The flow to display Radar Sensor measurements on Node-RED

You'll also have to create a dashboard group for the "text" and "chart" nodes.

MQTT server setup and coding for ESP32 PLC with FMR10

We've made a simple code that converts and outputs the recieved signal to the serial port and to the MQTT server. It reads from I0_7 because that's where we've connected the circuit to the PLC. The results are converted to metres and sent to both the serial monitor and the Node-RED flow through MQTT.

You can download the code from here:

Or copy it from here:

#include <SPI.h>
#include <String.h>
#include <Ethernet.h>
#include <PubSubClient.h>

// Update these with values suitable for your network.
byte mac[]    = {  0xDE, 0xED, 0xBA, 0xFE, 0xFE, 0xED };
IPAddress ip(10, 10, 10, 70);
IPAddress server(10, 10, 10, 60);

EthernetClient ethClient;
PubSubClient client(ethClient);


void reconnect() {
  // Loop until we're reconnected
  while (!client.connected()) {
    Serial.print("Attempting MQTT connection...");
    // Attempt to connect
    if (client.connect("arduinoClient")) {
      Serial.println("connected");
    } else {
      Serial.print("failed, rc=");
      Serial.print(client.state());
      Serial.println(" try again in 5 seconds");
      // Wait 5 seconds before retrying
      delay(5000);
    }
  }
}

void setup() {
  Serial.begin(9600);
  pinMode(I0_7, INPUT);
  client.setServer(server, 1883);
  Ethernet.begin(mac, ip);
  // Allow the hardware to sort itself out
  delay(1500);
}

float distance;

void loop() {
  // put your main code here, to run repeatedly:
  distance = (-0.002347)*analogRead(I0_7)+9.88478;
  if(distance < 0)
    distance=0;
  if(distance >8)
    distance=8;
  Serial.print(distance);
  Serial.println("m");
  if (!client.connected()) {
    reconnect();
  }
  client.publish("fmr10", String(distance).c_str());
  client.loop();
  delay(100);
}

If your PLC has a 0-10V analog input, you'll use this formula for the distance:

  distance = ((float)analogRead(I0_7) / 2047.0) * 8.0;

Results: Monitoring FMR10 Radar measurements with Node-RED dashboards

After deploying the Node-RED flow and uploading the program to the PLC, you should see the resulting measured distance in the Node-RED dashboard:

How you should see the resulting measured distance in the Node-RED

And in the Serial Monitor:

How appears dada in the Serial Monitor


 Maximizing efficiency with the FMR10 Radar and ESP32 PLC

Using the FMR10 radar sensor with an ESP32 PLC 14 allows for precise liquid level measurements in tanks, making it an excellent choice for various industrial automation applications. With the help of tools like Arduino IDE, Node-RED, and the SmartBlue app, configuring and managing the sensor becomes straightforward. This setup provides flexibility in how data is captured and displayed, ensuring that users can tailor the system to meet their specific needs.


By leveraging these components, industries can achieve efficient, accurate, and reliable data collection and monitoring, enhancing overall operational efficiency and safety.


​Search in our Blog

Boot & Work Corp. S.L., Arnau Tena August 30, 2024
Share this post

Looking for your ideal Programmable Logic Controller?

Take a look at this product comparison with other industrial controllers Arduino-based. 

We are comparing inputs, outputs, communications and other features with the ones of the relevant brands.


Industrial PLC comparison >>>