Be the Best Sensors’ Manufacturer and One Stop Solution Service

Attn:Tara WhatsApp:+86 13951751584

Magnetostrictive sensor

raspberry pi temperature sensor

by:KJTDQ     2020-05-01
The introduction below will show you how to build and program the Raspberry Pi to measure the temperature of the room using a thermal resistor.
A thermal resistor is a resistor that is temperature-based.
There are two different types of thermal resistors: negative temperature coefficient (NTC)
Positive temperature coefficient (PTC).
The resistance of PTC decreases with the increase of temperature, while the resistance of PTC increases with the increase of temperature to prevent the current from being too high.
For this project, we will use the NTC thermal resistor manufactured by Therm-especially 10k OhmO-Disc.
Because our sensor uses a thermal resistor, an analog-to-digital converter must be used.
For this project, I chose to use Raspberry Pi High-
Work with tkinter to design a precision AD/DA expansion board for my graphical user interface, as well as Matplotlib to plot the current temperature and display it in real time.
Other functions in this project include Pi\'s ability to measure thermal time constants ,(
This is the time it takes for the thermal resistor to change 63.
2% of the total difference between its initial and final body temperature)
, And display the temperature in real time.
Finally, I programmed various LEDs using red, yellow and blue to light up according to the temperature to indicate the current temperature.
Originally I wanted to program the whole project in Python but Raspberry Pi High-
Precision AD/DA expansion board is compatible in C only
Someone wrote the Python wrapper for it, but I chose not to go along this route.
Instead, I write the information I need to a file and then read the file from my Python program.
I use and program the touch screen interface so that the project will be more portable under more permanent settings: the device to install Raspberry Pi software: assuming you have installed the Raspberry Pi operating system for this project, we now need to install the library with the interface of the GPIO pin, tkinter and Matplotlib.
We first need to install some python libraries to implement the interface with the GPOs.
It should also be noted that the Python program is running on version 2. 7. 9.
Enter these commands into your terminal: Now, in order to use the AD expansion board, we need to do this for bcm2835-1.
50, also wiring Pi.
The screenshot above was taken from this Raspberry Pi forum. Note: If you encounter a failure while running make check, try putting \"sudo\" in front of the command \".
You can also download the software on your computer and transfer it here with usb.
Before running the test code, you need to move the jumper on the board first.
The instructions for this are shown in the user manual of the board, but I also include them below: 1)
High connection-Precision AD-
DA Board for Raspberry Pi. (
Insert the board directly on the Raspberry Pi)2)
Jumper settings: set the power supply to 5 v: Connect pins 5v and VCC.
Set the reference input voltage to 5 v: connect pin 5v and VREF.
Set the potentiometer output to analog input: connect pin ADJ and ad0.
Make sure the sensor interface AD0 on the left is disconnected.
Set LDR output to analog input: Connect pins LDR and ad1.
Make sure the sensor interface AD1 on the left is disconnected.
Connect AINCOM to AGND.
When using AD for differential measurement, there is no need to connect the public input AINCOM to the ground. 3)
When using SSH for terminal control, please connect the network cable.
The software PuTTY should be installed.
See section 1. 2. 4)Power up. 5)Copy (
Use USB drive as carrier)
The Directory of the software, ADS1256, the operating system of Raspbian.
Note: The system will detect the USB drive directly under the GUI, otherwise if SSH connection is used, the USB drive will not be able to run until it is installed to Linux.
For more details, search for the keyword \"Linux mount \". 6)
Make File: Enter the directory ADS1256 and compile it by Make. 7)Execute sudo .
/Ads1256_test note: If the command cannot be found at the prompt, add execution permission using chmod x ads1256_test. 8)
Block the LDR from the light and then change the voltage of the channel AD1. 9)
Turn the potentiometer and change the voltage of the channel AD0. 10)
Finally Press Ctrl C to pause the current process.
To be more clear, I drew a piece of code above where the jumper should be placed: directly test the pi: install 7z packageapt-
Get install p7zip-
Full reboot get test cpdes: again, when you run the test program, you should output these instructions like the picture above: in order to get the output voltage from the thermal resistor, we include it in the voltage divider circuit shown below, Vdd goes to the Power pin on the Raspberry Pi, and Vout goes to the/d channel on the expansion board.
In this case, we use AD4 to connect the ground to a ground pin on the board.
The circuit then gives the following equation: Vout = (R1/(R(T)+R1)
* Then we can rewrite and solve for RT)
Let\'s say we know that R1 equals 3268 ohms (
I measured my resistance to get my equation as accurately as possible)
Or anything you decide to use):R(T)=((Vin/Vout)-1)
* R1 now that we know the resistance of the thermal resistor, we can insert it into Steinhart-
Hart equation of 1/T = A Bln (R)+C[ln(R)]
It should be noted that A, B and C are coefficients specific to each thermal resistor and are most likely to be found in the data sheet of the thermal resistor.
However, there is Steinhart
The Hart coefficient calculator is available online for you, although you may need to play with these values to get an accurate temperature reading.
If you use the thermal resistor specified above, then you should mess up the coefficient.
I used a warm bath at work to test the accuracy from 0 °c to 80 °c and it was accurate in the 0 range. 2 degrees.
The pins used for LEDs in the program are G16, G13, G12, G5, G4, G16 connected to the first blue LED and G4 connected to the last red LED.
Note that there are two kinds of GPIO modes with Raspberry Pi board mode and BCM.
Sparkfun wedge using BCM mode, so if you don\'t use it, you can connect them directly to the pins on the board, and then, you need to look for the corresponding pins, or change the mode to board mode \". ” (
Note: If you change to board mode, you need to edit the pin assignment in your code).
Below is a screenshot of a method in my adcon.
It is a modified version of ads1256_test.
C program runs earlier.
This method is responsible for writing the temperature to a temporary data file in order to read the temperature from ThermoProj. py program.
This code is used to calculate the resistance of R1 and to use Steinhart-Hart Equation.
Note that if different coefficients are used, they can be easily added by changing the values of a, B, or c.
I also chose to keep all analog to digital channels open so that more sensors can be easily added later.
Finally, if you use a different resistor for R2, then its value must be changed up in the main method of declaring all variables.
To run the program, you first need to open two terminals and navigate to the directory where each program is located.
You then want to run the C program first in order to create a temporary data file and read it by the Python program.
After you run, you can run the Python program.
You should know that the C program will run and then it looks like it will stop.
However, it is just waiting for the Python program to start.
I have included the command that needs to be entered below.
I also include a zip file with my Python and C code as well as a pdf description of the Waveshare High-
Precision advertising board.
I want to do something different after finishing this project, the first one is to use Matplotlib.
This app is good for drawing data, but not the best for animated graphics.
I am using this because of the network security I am working on and I am unable to connect my Raspberry Pi to Wi-
Restricted my app selection.
I would simply use it if I had Internet access and for me it looks like a better option as it allows to view the data online and it looks easier to set up.
In addition, there are also some temperature sensors that are easier to use with Raspberry Pi, the main reason I use this thermal resistor is the company I worked with as an intern in ThermO-
Disc manufactures a variety of sensors, including thermal resistors, and wants to show how some of their products are implemented.
Also, other temperature sensors may be easier to set up, but most will not be that accurate.
Finally, the analog-to-digital converter also has cheaper options like MCP 3008, but I chose this board because it makes it easy for me to connect all the components to the Pi Touch box to make the project more portable.
Custom message
Chat Online 编辑模式下无法使用
Leave Your Message inputting...