Commit 6317d220 authored by cameron.rayfield's avatar cameron.rayfield 🎨

Delete IoT_Project.ino

parent d50c81bb
#include <Wire.h>
#include <LiquidCrystal.h>
#include "rgb_lcd.h"
#include <SPI.h>
#include <WiFiNINA.h>
#include <ThingSpeak.h>
#include <Pushsafer.h>
rgb_lcd lcd;
const int pinTemp = A0;
const int B = 3975;
//wifi setup
const char ssid[] = "BT-65CWRF";
const char password[] = "Y6MXcpC7LMqKbX";
#define PushsaferKey "tCP14do8Oc6C0eKXyiZP"
//thingspeak setup
const unsigned long channel_id = 1907432;
const char write_api_key[] = "LH1FINQ6IO2F3DT3";
WiFiClient client;
Pushsafer pushsafer(PushsaferKey, client);
void setup()
{
Serial.begin(9600);
Serial.print("Connecting to ");
Serial.print(ssid);
WiFi.begin(ssid, password);
Serial.println();
Serial.println("Connected to your WiFi!");
delay(60);
ThingSpeak.begin(client);
lcd.begin(16, 2);
lcd.print("Temperature:");
delay(1000);
}
void loop()
{
lcd.setCursor(0, 1);
int val = analogRead(pinTemp);
float resistance = (float)(1023-val)*10000/val;
float temperature = 1/(log(resistance/10000)/B+1/298.15)-273.15;
lcd.print(temperature);
Serial.println("Your current room temperature is: " + String(temperature) + ".");
ThingSpeak.setField(1, String(temperature, 2));
ThingSpeak.writeFields(channel_id, write_api_key);
delay(60);
pushsafer.debug = true;
delay(60);
if (temperature > 20.00 && temperature < 25.00){
const int colorR = 0;
const int colorG = 255;
const int colorB = 0;
lcd.setRGB(colorR, colorG, colorB);
}
if (temperature > 25.00){
const int colorR = 255;
const int colorG = 0;
const int colorB = 0;
lcd.setRGB(colorR, colorG, colorB);
delay(60);
Serial.println("Your room temperature is currently too high!");
delay(60);
struct PushSaferInput input;
input.message = "Your room is currently too hot.";
input.title = "Temperature Alert!";
input.sound = "8";
input.vibration = "1";
input.icon = "1";
input.iconcolor = "#FFCCCC";
input.priority = "1";
input.device = "a";
input.url = "https://www.pushsafer.com/api";
input.urlTitle = "Open Pushsafer.com";
delay(60);
Serial.println(pushsafer.sendEvent(input));
Serial.println("Notification Sent");
delay(60);
}
if (temperature < 20.00){
const int colorR = 0;
const int colorG = 0;
const int colorB = 255;
lcd.setRGB(colorR, colorG, colorB);
delay(60);
Serial.println("Your room temperature is currently too low!");
delay(60);
struct PushSaferInput input;
input.message = "Your room is currently too cold.";
input.title = "Temperature Alert!";
input.sound = "8";
input.vibration = "1";
input.icon = "1";
input.iconcolor = "#FFCCCC";
input.priority = "1";
input.device = "a";
input.url = "https://www.pushsafer.com/api";
input.urlTitle = "Open Pushsafer.com";
delay(60);
Serial.println(pushsafer.sendEvent(input));
Serial.println("Notification Sent");
delay(60);
}
delay(15000);
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment