icon

Making a Temperature-Detecting 'Portal Gun' with Unihiker

3 3003 Easy

I. Introduction:

 

Have you watched "Rick and Morty"? Ever wondered how Rick is able to soar through the universe and traverse through time and space? Well, it's all thanks to that portal gun! Just enter the coordinates of a parallel universe and press the button, and a mysterious green circular portal will appear right in front of you, creating a real-time connection between different spaces. It's like being caught in the crevices of a virtual world. With a single leap, you can venture into a whole new universe.

 

Although this incredible technology is beyond the reach of our real world, I find myself daydreaming every day about where I would go if I could travel through time and space. Perhaps I would instantly visit a friend who lives miles away, or maybe I would turn around and find myself standing on London Bridge. The possibilities are endless, and these fantasies fill my mind with excitement.

 

 

 

Back to the real world, solving this super challenging problem may be beyond my capabilities. But wouldn't it be amazing to have a gadget that resembles a portal gun? It would fulfill a wish of mine, combining functionality and practicality with a fancy appearance.

 

 

 

 

First of all, I want to add a temperature measurement function to it. Additionally, I need it to be able to maintain power and have a screen to display its readings. I have found a breakout board and an infrared temperature sensor module that meet the requirements for fast and accurate measurement of the surface temperature of the target object. Whether it's measuring indoor temperature, food temperature, or even the temperature of mechanical equipment, it can easily collect the data I need. This setup fulfills my need for portable data collection and display.

 

 

HARDWARE LIST
1 UNIHIKER DFR0706-EN
1 MP2636 Power Booster & Charger Module
1 I2C Non-contact IR Temperature Sensor SEN0206
1 3.7V Polymer Lithium Ion Battery FIT0120

 

Unihiker is a single-board microcomputer that allows you to learn and program using Python. It not only integrates an LCD touchscreen display for intuitive data visualization but also features WiFi and Bluetooth capabilities for easy connectivity and interaction with other devices. Additionally, the Unihiker board comes with various commonly used sensors built-in and can connect to hardware interfaces such as IIC, UART, and USB serial ports to sense the surrounding environment.

 

Unlike conventional temperature sensors, the infrared temperature measurement module determines the temperature of an object based on its infrared radiation energy. It does not require direct contact with the object being measured, thus not affecting the temperature field of the object. It offers high-temperature resolution, fast response speed, and good stability. The module has a field of view (FOV) of 35°. Other temperature measurement sensors can be categorized as either contact or non-contact types. Contact temperature measurement can only measure the temperature of the object after it reaches thermal equilibrium with the sensor, resulting in longer response times and susceptibility to environmental temperature changes.

 

When using lithium batteries as our power source, the two main technical challenges to address are voltage boosting and charging. The MP2636 charging and boosting module can boost a 3.7V battery to 5V to support the power supply of the Unihiker board. Additionally, this boosting module supports charging functionality, making it perfect for DIY projects that require portable lithium battery power supply.

 

 

After selecting the hardware, I created a 3D-printable transmission gun model that can directly match the Unihiker board and other hardware. If you want to add other modules, you can modify it based on this foundation.

 

 

3D printing model link: https://www.thingiverse.com/thing:6234661

 

III. Code
 

When programming the hardware directly using Python, we need to use the Pinpong library. This is a Python library that allows us to control hundreds of open-source hardware mainboards, enabling us to control open-source hardware with Python.

 

 

Reading values from the infrared temperature sensor and printing them:
· Import the library for the infrared temperature sensor module:  from pinpong.libs.dfrobot_mlx90614 import MLX90614
· Import the Pinpong library for the Unihiker board: from pinpong.board import Board
· The infrared temperature sensor communicates using I2C, with the default address set to 0x5A: irt = MLX90614(0x5A)

CODE
from pinpong.libs.dfrobot_mlx90614 import MLX90614
from pinpong.board import Board

Board().begin()
irt = MLX90614(0x5A)

while True:
    print(irt.obj_temp_c())

We have successfully read the values, and now let's try to create a UI interface and display the values on the Unihiker board's screen.

 

Import the GUI module for the Unihiker board: from unihiker import GUI

CODE
from pinpong.libs.dfrobot_mlx90614 import MLX90614
from pinpong.board import Board
from unihiker import GUI
import time

We will use the background image "robot.png" and display it starting from the pixel position (0,0), with a width of 240 (full-screen display): img1 = u_gui.draw_image(image="robot.png", x=0, y=0, w=240)

 

For real-time temperature display, we will use a digital display with a font size of 120, positioned at coordinates (25, 85) on the screen: u_gui.draw_text(text="Real-time Temperature", x=25, y=85, font_size=120)

CODE
Board().begin()
u_gui=GUI()
irt = MLX90614(0x5A)
img1=u_gui.draw_image(image="robot.png",x=0,y=0,w=240)
txt=u_gui.draw_digit(text="0",x=25,y=85,font_size=120, color="#FF6666")

To run the program, set the condition to refresh the temperature display when the temperature is less than or equal to 38 degrees. When the temperature exceeds 38 degrees, not only should the display be refreshed, but the color should also change to bright red.

CODE
while True:
    my_variable = irt.obj_temp_c()
    if (my_variable <= 38):
        txt.config(text=my_variable, color="#FF6666")

    if (my_variable > 38):
        txt.config(text=my_variable, color="#FF0000")
    time.sleep(0.1)

Now we have completed a prototype of a temperature-measuring portal gun, and there are more DIY possibilities by adding other measurement modules. For example, we can use a spectrometer module to create a spectrometer or an NFC card reader module for card recognition.

 


The beauty of DIY projects is that they offer endless opportunities for customization and innovation. By incorporating different modules, we can transform our portal gun into a versatile tool capable of various measurements and interactions. Let your creativity and curiosity guide you as you explore the exciting world of DIY electronics!

License
All Rights
Reserved
licensBg
3