EasyManuals Logo

Freenove Ultimate Starter Kit User Manual

Freenove Ultimate Starter Kit
286 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Page #131 background imageLoading...
Page #131 background image
131
Chapter 11 Thermistor
www.freenove.com
support@freenove.com
Code
In this project code, the ADC value is still needed to be read, and the difference is that a specific formula is
used to calculate the temperature value.
C Code 11.1.1 Thermometer
First observe the project result, and then analyze the code.
Use cd command to enter 11.1.1_Thermometer directory of C code.
cd ~/Freenove_Ultimate_Starter_Kit_for_Raspberry_Pi/Code/C_Code/11.1.1_Thermometer
1. Use following command to compile Thermometer.c” and generate executable file “Thermometer”. -lm
option is needed.
gcc Thermometer.c -o Thermometer -lwiringPi -lm
2. Then run the generated file “Thermometer”.
sudo ./Thermometer
After the program is executed, the terminal window will print out the current ADC value, voltage value and
temperature value. Try to pinch the thermistor (do not touch pin) with hand lasting for a while, then the
temperature value will be increased.
The following is the code:
1
2
3
4
5
6
7
8
9
10
11
12
13
#include <wiringPi.h>
#include <pcf8591.h>
#include <stdio.h>
#include <math.h>
#define address 0x48 //pcf8591 default address
#define pinbase 64 //any number above 64
#define A0 pinbase + 0
#define A1 pinbase + 1
#define A2 pinbase + 2
#define A3 pinbase + 3
int main(void){

Table of Contents

Questions and Answers:

Question and Answer IconNeed help?

Do you have a question about the Freenove Ultimate Starter Kit and is the answer not in the manual?

Freenove Ultimate Starter Kit Specifications

General IconGeneral
BrandFreenove
ModelUltimate Starter Kit
CategorySingle board computers
LanguageEnglish