Is there any good Raspberry Pi tutorials for making a temperature monitor that can be used to monitor the temperature of a rifle barrel? So far, I can only find tutorials for contact-less temperature sensor for Arduino, but not for Raspberry Pi.

  • What sensor do you plan to use? The rpi uses 3.3V logic so your sensor would need to be compatible with that or you would need to convert voltages. What do you plan to do with the temperature data? You might be better off using an arduino.
    – T. M.
    Apr 24, 2019 at 7:45
  • I was thinking of using the MLX90614, just because I can't find any that are specifically meant to be used with a Rapsberry Pi. I plan to compare muzzle velocities with respect to barrel temperature. It seems that using an Arduino would be easier, but I was hoping to avoid having to add extra bulk to my system. Apr 24, 2019 at 8:04
  • Sparkfun carries the 3V version of that sensor. If you got that you would be fine from a voltage standpoint.
    – T. M.
    Apr 24, 2019 at 8:08

1 Answer 1


Not trying to talk you out of your choice to use a contact-less temperature sensor, but perhaps you should consider a sensor that was directly mounted to the gun barrel (e.g. a thermistor). Why?

  1. "The measured value [with the MLX90614] is the average temperature of all objects in the Field Of View of the sensor."
  2. Thermistors are more accurate; 0.1°C - 0.2°C. OTOH, "the MLX90614 offers a standard accuracy of 0.5°C around room temperatures." And of course this assumes the MLX90614 is "focused" on the region of interest on the gun barrel.
  3. Cost: $0.75 vs $19.95

In summary, you may get better (more accurate, more reliable, more repeatable) results with a thermistor. For mounting the thermistor to the gun barrel, you should also consider a dab of silicone grease to reduce the thermal resistance between the barrel and the sensor.

You asked about tutorials. There are many that cover using thermistors with Raspberry Pi, and you can also find some that use the contact-less MLX90614... this one includes some code

One final point: Without trying to be pedantic, you mentioned in your comment that "adding bulk" was a concern. You've not described your entire system, but the RPi has no analog input. Unlike the Arduino then, the sensor-to-RPi interface will be digital instead of analog, and (if you're using a thermistor) this will require added components. The RPi also will require a heftier power supply than an Arduino. All of that said, the MLX90614 does have an I2C serial interface which makes it a good choice if you're fixed on using the RPi.

  • Thanks Seamus! This is great info! Could you recommend a way to temporarily mount the thermistor to a rifle barrel? I thought about using an o-ring, but I'm concerned about the o-ring acting as a heat sink and expanding. Apr 24, 2019 at 20:13
  • @CarlosRobinAlvarenga: If it were me, I'd likely try a simple rubber band first. It seems to me that the most important aspect of this is to make an effort to optimize the heat transfer from the barrel to the sensor. Toward that objective, I'd try a wide rubber band, and a generous dollop of the silicone grease ref'd in my answer. And as usual with these things, you'll need some experiments to validate the setup (i.e. make sure you're reading different temperatures with reasonable accuracy).
    – Seamus
    Apr 25, 2019 at 11:14
  • I agree with starting simple, but a rubber band may be too simple. Depending on the type of gun, I'd be concerned that will melt to the barrel.
    – Brick
    Sep 23, 2019 at 17:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.