20 May, 2017

GY-MCU90614-BCC Serial IR Non-contact Module: Python code

It seems that this variant of the module, with serial interface, is not that popular or at least I could not find code that I can easily port to Raspberry Pi. One can find a Windows program that prints the values from the serial port but that is all.
Anyway, I found description of the protocol on several pages, and it looked doable. Later, I found an Arduino example code, which could have helped, but...  I start programming before I had the module, which explains the reason why I first convert the characters to hex and then decode... This way is easier to debug it... So, here is the Python code (at the end of the post) that tests the checksum, decodes and prints the values to the standard output. (by the way, I still do not know how to get negative values for the temperature...)

Example output:
$ ./IRserial.py
TO: 21.36   TA: 24.04
TO: 21.36   TA: 24.04
TO: 21.36   TA: 24.04
TO: 21.57   TA: 24.04
TO: 21.57   TA: 24.04
TO: 21.57   TA: 24.04
TO: 21.57   TA: 24.08
TO: 21.57   TA: 24.08
TO: 21.57   TA: 24.08