Devices & Components
WROOMBEE - ESP32 WROOM Xbee form factor
Battery, 9 V
SparkFun XBee Explorer Dongle
SparkFun XBee Shield
Jumper wires (generic)
Temperature Sensor
Hardware & Tools
Solder Wire, Lead Free
Soldering iron (generic)
Software & Tools
Arduino IDE
Project description
Code
Wireless Thermometer Code
arduino
1//Project 49 - Building a Remote Control Thermometer 2 3char a; 4float voltage=0; 5float sensor=0; 6float celsius=0; 7float fahrenheit=0; 8float photocell=0; 9 10void setup() { 11 Serial.begin(9600); 12} 13 14void sendC() 15{ 16 sensor=analogRead(0); 17 voltage=((sensor*5000)/1024); 18 voltage=voltage-500; 19 celsius=voltage/10; 20 Serial.println(" "); 21 Serial.print("Temperature: "); 22 Serial.print(celsius,2); 23 Serial.println(" degrees C"); 24} 25 26void sendF() 27{ 28 sensor=analogRead(0); 29 voltage=((sensor*5000)/1024); 30 voltage=voltage-500; 31 celsius=voltage/10; 32 fahrenheit=((celsius*1.8)+32); 33 Serial.println(" "); 34 Serial.print("Temperature: "); 35 Serial.print(fahrenheit,2); 36 Serial.println(" degrees F"); 37} 38 39void getCommand() 40{ 41 Serial.flush(); 42 while (Serial.available() == 0) 43 { 44 //do nothing 45 } 46 while (Serial.available() > 0) 47 { 48 a = Serial.read(); //read the number in the serial buffer 49 } 50} 51 52void loop() { 53 getCommand(); //listen for command from PC 54 switch (a) 55 { 56 case 'c': 57 //send temperature in Celsius 58 sendC(); 59 break; 60 case 'f': 61 //send temperature in Fahrenheit 62 sendF(); 63 break; 64 } 65}
Wireless Thermometer Code
arduino
1//Project 49 - Building a Remote Control Thermometer 2 3char a; 4float voltage=0; 5float sensor=0; 6float celsius=0; 7float fahrenheit=0; 8float photocell=0; 9 10void setup() { 11 Serial.begin(9600); 12} 13 14void sendC() 15{ 16 sensor=analogRead(0); 17 voltage=((sensor*5000)/1024); 18 voltage=voltage-500; 19 celsius=voltage/10; 20 Serial.println(" "); 21 Serial.print("Temperature: "); 22 Serial.print(celsius,2); 23 Serial.println(" degrees C"); 24} 25 26void sendF() 27{ 28 sensor=analogRead(0); 29 voltage=((sensor*5000)/1024); 30 voltage=voltage-500; 31 celsius=voltage/10; 32 fahrenheit=((celsius*1.8)+32); 33 Serial.println(" "); 34 Serial.print("Temperature: "); 35 Serial.print(fahrenheit,2); 36 Serial.println(" degrees F"); 37} 38 39void getCommand() 40{ 41 Serial.flush(); 42 while (Serial.available() == 0) 43 { 44 //do nothing 45 } 46 while (Serial.available() > 0) 47 { 48 a = Serial.read(); //read the number in the serial buffer 49 } 50} 51 52void loop() { 53 getCommand(); //listen for command from PC 54 switch (a) 55 { 56 case 'c': 57 //send temperature in Celsius 58 sendC(); 59 break; 60 case 'f': 61 //send temperature in Fahrenheit 62 sendF(); 63 break; 64 } 65}
Downloadable files
untitled
untitled

Comments
Only logged in users can leave comments