Components and supplies
Arduino MKR WiFi 1010
DHT11
jumper wires for arduino
DS18B20 temperature sensor
MAX6675 Module + K Type Thermocouple
Apps and platforms
Arduino IoT Cloud
ARDUINO IOT REMOTE
Project description
Code
Indoor_Temp
cpp
Arduino Sketch for the indoor DHT11 sensor
1#include "thingProperties.h" 2#include "DHT.h" 3 4#define DHTTYPE DHT11 // DHT 11 5#define DHTPIN 3 // Digital pin connected to the DHT sensor 6 7DHT dht(DHTPIN, DHTTYPE); 8 9void setup() { 10 // Initialize serial and wait for port to open: 11 Serial.begin(9600); 12 // This delay gives the chance to wait for a Serial Monitor without blocking if none is found 13 delay(1500); 14 15 // Defined in thingProperties.h 16 initProperties(); 17 18 // Connect to Arduino IoT Cloud 19 ArduinoCloud.begin(ArduinoIoTPreferredConnection); 20 21 /* 22 The following function allows you to obtain more information 23 related to the state of network and IoT Cloud connection and errors 24 the higher number the more granular information you’ll get. 25 The default is 0 (only errors). 26 Maximum is 4 27 */ 28 setDebugMessageLevel(2); 29 ArduinoCloud.printDebugInfo(); 30 31 dht.begin(); // initialize the DHT sensor 32} 33 34void loop() { 35 ArduinoCloud.update(); 36 37 // Wait a few seconds between measurements. 38 delay(2000); 39 40 // Reading temperature or humidity takes about 250 milliseconds! 41 // Sensor readings may also be up to 2 seconds 'old' (its a very slow sensor) 42 43 //Read humidity 44 float h = dht.readHumidity(); 45 46 // Read temperature as Celsius (the default) 47 float t = dht.readTemperature(); 48 49 // Read temperature as Fahrenheit (isFahrenheit = true) 50 float f = dht.readTemperature(true); 51 52 inHumid = h; 53 54 /*!!!!!!!! Uncomment Fahrenheit or Celsius depending on what you need !!!!!!!!!!*/ 55 indoorTemp = t; 56 //indoorTemp = f; 57 58 // Check if any reads failed and exit early (to try again). 59 if (isnan(h) || isnan(t) || isnan(f)) { 60 Serial.println(F("Failed to read from DHT sensor!")); 61 return; 62 } 63 64 // Compute heat index in Fahrenheit (the default) 65 float hif = dht.computeHeatIndex(f, h); 66 67 // Compute heat index in Celsius (isFahreheit = false) 68 float hic = dht.computeHeatIndex(t, h, false); 69 70 //Print Values in the Serial Monitor 71 Serial.print("indoor: "); 72 Serial.print(indoorTemp); 73 Serial.print(" C "); 74 75 Serial.print(" | "); 76 77 Serial.print("Humidity: "); 78 Serial.print(inHumid); 79 Serial.println(" % "); 80}
Water_Temp
cpp
Arduino Sketch for the water prope sensor
1#include "thingProperties.h" 2#include <OneWire.h> 3#include <DallasTemperature.h> 4 5const int SENSOR_PIN = 13; // Arduino pin connected to DS18B20 sensor's DQ pin 6OneWire oneWire(SENSOR_PIN); // setup a oneWire instance 7DallasTemperature tempSensor(&oneWire); // pass oneWire to DallasTemperature library 8 9float tempCelsius; // temperature in Celsius 10float tempFahrenheit; // temperature in Fahrenheit 11 12 13void setup() { 14 // Initialize serial and wait for port to open: 15 Serial.begin(9600); 16 // This delay gives the chance to wait for a Serial Monitor without blocking if none is found 17 delay(1500); 18 19 // Defined in thingProperties.h 20 initProperties(); 21 22 // Connect to Arduino IoT Cloud 23 ArduinoCloud.begin(ArduinoIoTPreferredConnection); 24 25 /* 26 The following function allows you to obtain more information 27 related to the state of network and IoT Cloud connection and errors 28 the higher number the more granular information you’ll get. 29 The default is 0 (only errors). 30 Maximum is 4 31 */ 32 setDebugMessageLevel(2); 33 ArduinoCloud.printDebugInfo(); 34 35 tempSensor.begin(); // initialize the Dallas sensor 36} 37 38void loop() { 39 ArduinoCloud.update(); 40 41 tempSensor.requestTemperatures(); // send the command to get temperatures 42 tempCelsius = tempSensor.getTempCByIndex(0); // read temperature in Celsius 43 44 /*!!!!!!!! Uncomment Fahrenheit or Celsius depending on what you need !!!!!!!!!!*/ 45 waterTemp = round(tempCelsius * 10.0) / 10; 46 //waterTemp = round(tempFahrenheit * 10.0) / 10; 47 48 tempFahrenheit = tempCelsius * 9 / 5 + 32; // convert Celsius to Fahrenheit 49 50 //Checks if sensor is connected 51 if (waterTemp < 0) { 52 Serial.println(F("Failed to read from DS18B20 TEMPERATURE PROBE!")); 53 } 54 55 Serial.print("Water: "); 56 Serial.print(waterTemp); 57 Serial.println(" C "); 58}
Outdoor_Temp
cpp
Arduino Sketch for the outdoor DHT11 sensor
1#include "thingProperties.h" 2#include "DHT.h" 3 4#define DHTTYPE DHT11 // DHT 11 5#define DHTPIN 2 // Digital pin connected to the DHT sensor 6 7DHT dht(DHTPIN, DHTTYPE); 8 9void setup() { 10 // Initialize serial and wait for port to open: 11 Serial.begin(9600); 12 // This delay gives the chance to wait for a Serial Monitor without blocking if none is found 13 delay(1500); 14 15 // Defined in thingProperties.h 16 initProperties(); 17 18 // Connect to Arduino IoT Cloud 19 ArduinoCloud.begin(ArduinoIoTPreferredConnection); 20 21 /* 22 The following function allows you to obtain more information 23 related to the state of network and IoT Cloud connection and errors 24 the higher number the more granular information you’ll get. 25 The default is 0 (only errors). 26 Maximum is 4 27 */ 28 setDebugMessageLevel(2); 29 ArduinoCloud.printDebugInfo(); 30 31 dht.begin(); // initialize the DHT sensor 32} 33 34void loop() { 35 ArduinoCloud.update(); 36 37 // Wait a few seconds between measurements. 38 delay(2000); 39 40 // Reading temperature or humidity takes about 250 milliseconds! 41 // Sensor readings may also be up to 2 seconds 'old' (its a very slow sensor) 42 43 //Read humidity 44 float h = dht.readHumidity(); 45 46 // Read temperature as Celsius (the default) 47 float t = dht.readTemperature(); 48 49 // Read temperature as Fahrenheit (isFahrenheit = true) 50 float f = dht.readTemperature(true); 51 52 outHumid = h; 53 54 /*!!!!!!!! Uncomment Fahrenheit or Celsius depending on what you need !!!!!!!!!!*/ 55 outdoorTemp = t; 56 //outdoorTemp = f; 57 58 // Check if any reads failed and exit early (to try again). 59 if (isnan(h) || isnan(t) || isnan(f)) { 60 Serial.println(F("Failed to read from DHT sensor!")); 61 return; 62 } 63 64 // Compute heat index in Fahrenheit (the default) 65 float hif = dht.computeHeatIndex(f, h); 66 67 // Compute heat index in Celsius (isFahreheit = false) 68 float hic = dht.computeHeatIndex(t, h, false); 69 70 //Print Values in the Serial Monitor 71 Serial.print("outdoor: "); 72 Serial.print(outdoorTemp); 73 Serial.print(" C "); 74 75 Serial.print(" | "); 76 77 Serial.print("Humidity: "); 78 Serial.print(outHumid); 79 Serial.println(" % "); 80}
BBQ_Temp
Arduino Sketch for the BBQ temperature sensor
1/* 2 Sketch generated by the Arduino IoT Cloud Thing "Untitled" 3 https://create.arduino.cc/cloud/things/aa9511d4-8f9d-4d10-81ac-50fde63d7bfb 4 5 Arduino IoT Cloud Variables description 6 7 The following variables are automatically generated and updated when changes are made to the Thing 8 9 float bbqTemp; 10 11 Variables which are marked as READ/WRITE in the Cloud Thing will also have functions 12 which are called when their values are changed from the Dashboard. 13 These functions are generated with the Thing and added at the end of this sketch. 14*/ 15 16#include "thingProperties.h" 17#include "max6675.h" 18 19int thermoDO = 4; 20int thermoCS = 5; 21int thermoCLK = 6; 22 23MAX6675 thermocouple(thermoCLK, thermoCS, thermoDO); 24 25void setup() { 26 // Initialize serial and wait for port to open: 27 Serial.begin(9600); 28 // This delay gives the chance to wait for a Serial Monitor without blocking if none is found 29 delay(1500); 30 31 // Defined in thingProperties.h 32 initProperties(); 33 34 // Connect to Arduino IoT Cloud 35 ArduinoCloud.begin(ArduinoIoTPreferredConnection); 36 37 /* 38 The following function allows you to obtain more information 39 related to the state of network and IoT Cloud connection and errors 40 the higher number the more granular information you’ll get. 41 The default is 0 (only errors). 42 Maximum is 4 43 */ 44 setDebugMessageLevel(2); 45 ArduinoCloud.printDebugInfo(); 46} 47 48void loop() { 49 ArduinoCloud.update(); 50 bbqTemp = thermocouple.readCelsius(); 51 52 Serial.print(bbqTemp); 53 Serial.println(" C"); 54}
Comments
Only logged in users can leave comments
Arduino_Genuino
0 Followers
•0 Projects
0