Mac SimontonKorey Perkins
Published

MEGR 3171 Detecting and Graphing Temperature Change

Temperature, the ever changing factor in electronics. Something that needs to be monitored and measured to ensure proper operation.

IntermediateFull instructions provided13
MEGR 3171 Detecting and Graphing Temperature Change

Things used in this project

Hardware components

Argon
Particle Argon
×2
Pushbutton switch 12mm
SparkFun Pushbutton switch 12mm
×1
Jumper wires (generic)
Jumper wires (generic)
×6
Breadboard (generic)
Breadboard (generic)
×2
Resistor 100 ohm
Resistor 100 ohm
×1
LED (generic)
LED (generic)
×1
KY-028 DIGITAL TEMPERATURE SENSOR MODULE
×1

Software apps and online services

Particle Build Web IDE
Particle Build Web IDE
ThingSpeak API
ThingSpeak API
adafruit.io

Story

Read more

Schematics

Korey's Schematic

Mac's Schematic

Code

Push Button Start

C/C++
// We will be using D2 to control our LED
int ledPin = D2;

// Our button wired to D0
int buttonPin = D3;
void setup()
{

  // For input, we define the
  // pushbutton as an input-pullup
  // this uses an internal pullup resistor
  // to manage consistent reads from the device

  pinMode( buttonPin , INPUT_PULLUP); // sets pin as input

  // We also want to use the LED

  pinMode( ledPin , OUTPUT ); // sets pin as output
// Subscribe to the integration response event
Particle.subscribe("Temp High", TempHigh , MY_DEVICES);
Particle.subscribe("Temp Low", TempLow, MY_DEVICES);
}
void TempHigh(const char *event, const char *data) {
  digitalWrite( ledPin , HIGH);
}

void TempLow(const char *event, const char *data) {
  digitalWrite( ledPin , LOW);
}

void loop()
{
   
   // find out if the button is pushed
   // or not by reading from it.
   int buttonState = digitalRead( buttonPin );

  // remember that we have wired the pushbutton to
  // ground and are using a pulldown resistor
  // that means, when the button is pushed,
  // we will get a LOW signal
  // when the button is not pushed we'll get a HIGH
if (buttonState == LOW){
  // Get some data
  String data = String(1);
  // Trigger the integration
  Particle.publish("PushButton", data, PUBLIC);
  // Wait 60 seconds
  delay(60000);
}
}  

Temperature Sensor

C/C++
double temperature = 0; // Initalize variable for the temperature data coming f 
int pinvalue = 0; //Initalize variable for the pin input from the temperature sensor



void setup()

{
  
  pinMode(A0, INPUT); // Get input from this pin
  pinMode(D7, OUTPUT); // Set D7 as output
   // Subscribe to the integration response event
 Particle.subscribe("PushButton", ButtonState, MY_DEVICES);

 }

void ButtonState(const char *event, const char *data) {
  // Handle the integration response
      delay(8000); // Delay the loop iterations for eight seconds
      pinvalue = analogRead(A0); // Get the value from the A0 pin
      
      temperature = (pinvalue*-.05+107); // Calibrate the input from the sensor 
      
      Particle.publish("Temperature Sensor", String(temperature), PUBLIC); // Publish Temperature data Thingspeak
      if (temperature > 60){
      Particle.publish("Temp High",String(temperature), PUBLIC);
      }
      else if (temperature < 60){
          Particle.publish("Temp Low", String(temperature), PUBLIC);
      }
      }

Credits

Mac Simonton

Mac Simonton

0 projects • 1 follower
Korey Perkins

Korey Perkins

0 projects • 0 followers

Comments

Add projectSign up / Login