Samuel KornmayerUriel Regalado
Published

MEGR 3171 IOT Project: Temperature Sensor with LCD Display

An easy particle argon setup that allows you to see the temperature of a room from any location, as well as receive notifications

IntermediateWork in progress5 hours106
MEGR 3171 IOT Project: Temperature Sensor with LCD Display

Things used in this project

Hardware components

Argon
Particle Argon
×2
Breadboard (generic)
Breadboard (generic)
×2
USB-A to Micro-USB Cable
USB-A to Micro-USB Cable
×2
Jumper wires (generic)
Jumper wires (generic)
×1
Single Turn Potentiometer- 10k ohms
Single Turn Potentiometer- 10k ohms
×1
RGB Backlight LCD - 16x2
Adafruit RGB Backlight LCD - 16x2
×1
Temperature Sensor
Temperature Sensor
×1

Software apps and online services

Maker service
IFTTT Maker service
Particle Build Web IDE
Particle Build Web IDE
Google Sheets
Google Sheets

Story

Read more

Schematics

If This Then That

A similar IFTTT can be set up to alert you when the temperature drops below 70 degrees, so you can turn the heat on

Phone Notifications

Temperature Sensor Circuit Diagram

LCD Display Circuit Diagram

LCD Circuit (side view)

LCD Circuit (top view)

Temperature Sensor Circuit (top view)

Temperature Sensor Circuit (side view)

Code

Temperature Code

C/C++
// Define the Pin the Temperature sensor is on
int tempPin = A0;

// Create a variable that will store the temperature value
double temperature = 0.0;
double temperatureF = 0.0;

void setup()
{
  // Register a Particle variable here
  Particle.variable("temperature", &temperature, DOUBLE);
  Particle.variable("temperatureF", &temperatureF, DOUBLE);  

  // Connect the temperature sensor to A0 and configure it
  // to be an input
  pinMode(tempPin, OUTPUT);
}

void loop()
{
  // Keep reading the sensor value so when we make an API
  // call to read its value, we have the latest one
  int reading = analogRead(tempPin);

  // The returned value from the device is going to be in the range from 0 to 4095
  // Calculate the voltage from the sensor reading
  double voltage = (reading * 3.3) / 4095.0;

  // Calculate the temperature and update our static variable
  temperature = (voltage - 0.5) * 100;

  // Now convert to Farenheight
  temperatureF = ((temperature * 9.0) / 5.0) + 32.0;
  // Sends the data to the other argon
 String sensorValues = "{Temp:" + String(temperatureF) + "}";
	digitalWrite(A0, HIGH);
	Particle.publish("SensorValues" , String(sensorValues));
    Particle.publish("SensorValues", PRIVATE);
    
	delay(10000);
	digitalWrite(A0, LOW);
	
	delay(10000);
}

LCD Code

C/C++
#include <LiquidCrystal.h>
LiquidCrystal lcd(5, 4, 3, 2, 1, 0);
const int sensorPin = A0;

void setup() {
pinMode(A0, OUTPUT);

Particle.subscribe("SensorValues", toggleLed, MY_DEVICES);

Serial.begin(9600);
  lcd.begin(16, 2);

}

void loop() {
    int sensorVal = analogRead(sensorPin);
    float voltage = (sensorVal / 1024) * 5;
    float temperature = (voltage - 0.5) * 100;
    
    lcd.setCursor(0,0);
    lcd.print("Temp:         F  ");
    lcd.setCursor(6,0);
    lcd.print(temperature);
    delay(5000);

}

void toggleLed(const char *event, const char *data) {
    digitalWrite(A0, HIGH);
    delay(5000);
    digitalWrite(A0, LOW);
    delay(5000);
}

Credits

Samuel Kornmayer

Samuel Kornmayer

1 project • 0 followers
Uriel Regalado

Uriel Regalado

1 project • 0 followers

Comments

Add projectSign up / Login