Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- MTI - Final-Project
- Remote Temperature e Humidity Sensor
- Daniel Freitas - [email protected]
- */
- int humidSensorPin = 1; // variable to store the the analog pin for the temperator sensor
- int tempSensorPin = 3; // variable to store the the analog pin for the humidity detector
- int tempSensorValue = 0; // variable to store the value coming from the temperature sensor
- int humidSensorValue = 0; // variable to store the value coming from the humidity detector
- int temperature=0;
- int hum=0;
- void setup() {
- Serial.begin(115200); //bluetooth only works at 115200
- }
- void loop()
- {
- int tempSensorValue = analogRead(tempSensorPin); //read temperature
- int humidSensorValue = analogRead(humidSensorPin); //read humity value
- if (humidSensorValue >15) { //if the value is higher than 15 (and highest value possible is 1024) it means that the cloth was wet
- hum=1;
- }
- int temperature = map(tempSensorValue, 0, 1023, 32, 212); // maps the values into Fahrenheit scale
- //in order to use the Serial.read() function in Processing the numbers sent have to be between 0 and 255.
- //Example: if humidity is detected and the temperature is 73F it sends: 173.
- int sentdata= temperature + hum*100;
- Serial.write(sentdata);
- delay(1000); //writes into serial every 1 sec
- }
Advertisement
Add Comment
Please, Sign In to add comment