Temperature Sensor with Stone-HMI Display


Description

Stone Technologies is a professional Manufacturer of HMI Intelligent TFT LCD modules.  Depending on the application the Stone Technologies offers Industrial Type, Advanced type, and Civil Type Intelligent TFT LCD modules available in different sizes. Visit Here .

In this project we are going to measure the temperature of an Object and temperature of Ambient with the help of MLX90614 Sensor and this project has a interface for the displaying of temperature readings.

Here we are going to use MLX90614 sensor because this temperature sensor has high accuracy as compare to others sensors. This sensor reading will be sent to the Stone-HMI display and this data will be send in the form of frame because this Display receive data in the form of frame and send in the frame of HEX code. We are going to use STWI056WT/N-01 model for our in this project, if you want to understand data frame and how it is working? you can download the Datasheet from here .


Component List

[1] STONE-HMI Display [STWI056WT/N-01]

[2] Raspberry-Pi

[3] TTL to USB converter

[4] 9v-12v Power Supply

[5] USB cables

[6] MLX90614 sensor


GUI Designing

Let’s start first with interface designing but before that you have to install Stone Designer and the Driver for USB so let see how to install these software.

Step-1 :- Go to this website and download these software and then install them in your computer.

Website Link :- https://www.stoneitech.com/support/download/software

After installed , go to to Stone-Designer icon and click on that after that designer software will open and you will get this type of interface as shown in image.

After opened you have to create a new project for this select ‘Project’ from top and from that select ‘new’ and you will ask for the some details as shown in the below figure , now give the name of project and select screen size as per your display size, here I’m using 640X480 size display , and select project path also after done with filling all the details click on ‘Create’ .

After done with above part select the background image for the project for this follow steps as shown in the figure.

step-1 :- Select ‘image’ from Resources to upload the image.

Step-2:- Click on Add button to add a new image in it , so I added an image as you can see in the above image as name ‘background’.

Step-3:- Note down that image name for further steps.

Step-4:- Now drag image widget from top and put it in the edit section.

Step-5:- Now go to at properties and select image as ‘backgoung’ and click on enter.

After completed this part let’s add respective label in this project to display the sensor reading. For this first go to top and select label from there and put it at first Object temperature place and then Ambient temperature place as shown in below image.

Follow above steps to add widget on screen.

Steps-1,2 & 3 :- First select label from top then drag it on object place and then select label again and drag it on ambient place.

Step-4:- Select font size as per your choice.

Step-5:- This step is important because you have to remember some data from there and this data we will use for further steps or I can say for coding part.

Note:- Here we have selected widget as ‘label1’ & ‘label2’ and it type is ‘label .

name :- label1 & for Ambient temperature name:- label2

type:– label

Now we have done with Design part now let’s move to coding and working part.


Working & Raspberry-Pi coding

Code:- Let’s first understand how code is working ?

from smbus2 import SMBus
from mlx90614 import MLX90614
bus = SMBus(1)
sensor = MLX90614(bus, address=0x5A)
import serial
serialcomm = serial.Serial('/dev/ttyUSB0', 115200)
while True:
    x=int(sensor.get_ambient())
    y=int(sensor.get_object_1())
    amb='ST<{"cmd_code":"set_value","type":"label","widget":"label1","value":'+str(y)+'}>ET'      
    obj='ST<{"cmd_code":"set_value","type":"label","widget":"label2","value":'+str(x)+'}>ET' 
    serialcomm.write(str(amb).encode())
    serialcomm.write(str(obj).encode())
bus.close()

In above code as you can see I added two libraries these libraries are using for MLX90614 sensor to receive the data and for I2C communication. And after that I declare two frames these frames are for Object and Ambient temperature and this frame have a specific format to send the data to Stone-HMI display. You can find this frame specification below.

As you can see in the above image , this frame we will send to Stone-Display and display will show the temperature reading.

These are the frame which we are sending through Raspberry-Pi. First is for Ambient temperature and second for Object temperature reading.

amb=’ST<{“cmd_code”:”set_value”,”type”:”label”,”widget”:”label1″,”value”:’+str(y)+’}>ET’


obj=’ST<{“cmd_code”:”set_value”,”type”:”label”,”widget”:”label2″,”value”:’+str(x)+’}>ET’

And here are the two variable through which we are sending the values, first one is ‘y ‘ and second one is ‘x ‘ . And these two frames sending with the help of serial communication between raspberry-Pi and Stone-HMI display .

Let’s first enable the I2C and Serial communication in the Raspberry-Pi , for this go and click on Configuration and then enable these two communication protocols.

Now let’s setup libraries in the Raspberry-Pi , for this follow these step to install libraries in Raspberry-Pi.

  1. https://files.pythonhosted.org/packages/67/8a/443af31ff99cca1e30304dba28a60d3f07d247c8d410822411054e170c9c/PyMLX90614-0.0.3.tar.gz
  2. sudo apt-get install python-setuptools
  3. sudo apt-get install -y i2c-tools
  4. sudo python setup.py install

Now open the Raspberry-Pi browser and paste first link which is given above, after that a file will download and then extract it. Now open the terminal in Raspberry-Pi and run second command in this after this run third command, then before run the fourth command go to that location where you have extracted that file which you have downloaded. And after done all the command terminal will look like this image which is given below.

Now we have completed all installation part let’s connect the sensor and the Raspberry-Pi together. Follow the circuit which given below and do the connection.

Connect MLX90614 sensor with Raspberry-Pi I2C pin and also connect USB as shown in the circuit diagram. After connection ,run the code for that open ‘Thonny‘ which is present in the Raspberry-pi and paste the code here which is given above.

Now we have we have completed with this project let’s see the output video, find video below.


Output Video

YouTube Video

Thankyou so much to read the article till now there is YouTube video on this project so please go through that video to understand the whole procedure in a better manner there is link for video go and check it out.

Click Here

Leave a Reply

Your email address will not be published. Required fields are marked *