Hackster is hosting Hackster Holidays, Ep. 6: Livestream & Giveaway Drawing. Watch previous episodes or stream live on Monday!Stream Hackster Holidays, Ep. 6 on Monday!
greg
Published © GPL3+

An IoT controlled temperature monitor (S1.3)

Use the Arduino IOT Cloud to set a temperature goal and switch a red and green LED on /off to represent

BeginnerFull instructions provided5,886
An IoT controlled temperature monitor (S1.3)

Things used in this project

Hardware components

Arduino MKR1000
Arduino MKR1000
×1
Breadboard (generic)
Breadboard (generic)
×1
Temperature Sensor
Temperature Sensor
×1
5 mm LED: Red
5 mm LED: Red
×1
5 mm LED: Green
5 mm LED: Green
×1
Resistor 220 ohm
Resistor 220 ohm
×2

Software apps and online services

Arduino IoT Cloud
Arduino IoT Cloud
Arduino Web Editor
Arduino Web Editor
Arduino Create Agent (plugin)

Story

Read more

Schematics

Wiring diagram

Code

Snippet 1

Arduino
Temperature Sensor variables
// Temperature Sensor variables
int sensorPin = A0;       // Sets A0 as the input pin for the sensor
int sensorValue = 0;      // initialise a variable to store the value coming from the sensor
int Dres = 1024;          // set max 10-bit digital value
int VCC = 3300;           // set VCC voltage milliVolts
int offset = 500;         // set tolerance of 500 milliVolts
int scaling = 10;         // set the voltage scaling at 10mM / deg C
float voltage = 0.0;      // set the initial voltage to 0
int redPin = 0;           // set the output pin for the Red LED
int grnPin = 1;           // set the output pin for the Green LED 

Snippet 2

Arduino
Board setup instructions
  // Set 10bit read resolution
  analogReadResolution(10);
  
  // Set the outputPins for the LEDs
  pinMode(redPin, OUTPUT);
  pinMode(grnPin, OUTPUT);

Snippet 3

Arduino
Main program code
  // Read the value from the sensor:
  sensorValue = analogRead(sensorPin);
  Serial.print("sensorValue = ");
  Serial.print(sensorValue);

  // Calculate the voltage
  voltage = sensorValue * (VCC/Dres); // milliVolts
  Serial.print(" voltage = ");
  Serial.print(voltage);

  Serial.print(" VCC = ");
  Serial.print(VCC);
  
  // Calculate the temperature
  temperature = (voltage - offset ) / scaling;
  Serial.print(" temperature(C) = ");
  Serial.println(temperature);

  // If the temperature is < than the goal temperature then
  // Turn the Green LED on!
  if (temperature < setTemp) {
    digitalWrite(grnPin, HIGH);
    digitalWrite(redPin, LOW);
    }
    
  // If the temperature is >= than the goal temperature then
  // Turn the Red LED on!    
  else {
    digitalWrite(grnPin, LOW);
    digitalWrite(redPin, HIGH);
  } 

  Serial.print(" Set temperature(C) = ");
  Serial.println(setTemp);

Project Repository

All project code

Credits

greg

greg

0 projects • 2 followers

Comments