0

Example for ML-R Thermal Array Sensor, analog (mrm-therm-b-an)

Prerequisites

If not already, install Arduino software and make basic connections, as described in page for MRMS ESP32: Arduino, IMU, eFuse, BT, WiFi, CAN Bus (mrm-esp32).

Task

We will read analog output of the sensor in order to determine temperature of an object.

Pins

Note the necessary pins.

Connections

Additionally to the basic hardware connection, as depicted in home page for MRMS ESP32: Arduino, IMU, eFuse, BT, WiFi, CAN Bus (mrm-esp32), we will connect the sensor, ML-R Thermal Array Sensor, analog (mrm-therm-b-an). The image here shows just this board and the sensor, not the other parts of the basic connection (power supply and battery), which are also necessary.

Connect 0 and 3.3 V voltage inputs of ML-R Thermal Array Sensor, analog (mrm-therm-b-an) to appropriate voltage Dupont pins. Connect sensor's "ANA" pin to ESP32 GPIO pin 36.

Program

Here is the simplest code.

void setup() {
  Serial.begin(115200);
}

void loop() {
  Serial.println(map(analogRead(36), 0, 3300, -20, 100));
}
setup() starts serial interface with PC so that Serial.print will work.

In loop() map() is an Arduino function that has 5 arguments: first is the value somewhere in the start segment (arguments 2 and 3), which we want to proportionally map into the target segment (arguments 4 and 5).

In our case, first argument will be analog value that the sensor sends to pin 36. Start segment will be all possible analog values. Therefore, the bounds are 0 and maximum Your ADC can deliver. As ESP32 uses 12-bit ADC, the values are in range 0 - 4095 (212). However, analog signal from the sensor doesn't reach maximum voltage, 3.3 V. This real maximum is not so easy to obtain as in the case of a distance sensor, but You could point the sensor towards a very hot object, like boiling water, and read the value. If You don't want to bother, take 3300, as in our example.

Now the target segment. As we want to map relative ADC value to relative temperature, the target segment will contain all the possible temperatures. The sensors firmware can adjust the bounds, but normally it is maximum range Panasonic AMG8833 supports: -20 to 100 ºC, and that limits will define our target segment in this example. So, Serial.println() will display temperatures.

We could use any other of the 16 analog pins, as long as no other device uses them, but read the next paragraph.

Limitations

Some pins are not available or are limited in usage. It is also important to note the ADC anomaly for ESP32 and select the right firmware as the sensor's output value should not start from 0. If it starts, ESP32 will report 0 mm for the first about up to 70 mm. Check this list.

Alternative connection

Temperatura se čita na analognom ulazu mikrokontrolera, npr. koristeći Arduino funkciju analogRead().