Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
COM6005M IOT PROJECT
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
elijah vasquez
COM6005M IOT PROJECT
Commits
e8d5d660
Commit
e8d5d660
authored
Jan 15, 2024
by
elijah vasquez
🦍
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
push
parents
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
108 additions
and
0 deletions
+108
-0
ARDUINO TEMPERATURE CODE
ARDUINO TEMPERATURE CODE
+108
-0
No files found.
ARDUINO TEMPERATURE CODE
0 → 100644
View file @
e8d5d660
#include <SPI.h>
#include <WiFiNINA.h>
#include <ThingSpeak.h>
#include <math.h>
// Internet capability
WiFiClient client;
char ssid[] = "VM0729577";
char pass[] = "fch2sfdgCrS9";
int status = WL_IDLE_STATUS;
// ThingSpeak connectivity
unsigned long channelNo = 2401967;
const char * writeAPI = "Y4XA01Y4PZSJXXJB";
// Definitions
const int B = 4275; // B value of the thermistor
const int R0 = 100000; // R0 = 100k resistance
const int pinTempSensor = A0; // Sensor connected at A0
const int buzzerPin = 4; // Buzzer pin
const int ledPin = 3; // LED pin
// Debug for Serial
#if defined(ARDUINO_ARCH_AVR)
#define debug Serial
#elif defined(ARDUINO_ARCH_SAMD) || defined(ARDUINO_ARCH_SAM)
#define debug SerialUSB
#else
#define debug Serial
#endif
// Buzzer sound
#define TONE_1 100
void setup()
{
Serial.begin(9600);
WiFi.begin(ssid, pass);
ThingSpeak.begin(client);
}
void loop()
{
int a = analogRead(pinTempSensor);
float R = 1023.0 / a - 1.0;
R = R0 * R;
// Kelvin to Celsius
// Due to undervolting of 5V pin (4.95V), actual temperature is
// 5 degrees Celsius higher than normal, so a calibration
// of -5 was made
float temp = 1.0 / (log(R / R0) / B + 1 / 293.15) - 273.15;
Serial.println(F("TEMPERATURE "));
Serial.println(temp);
delay(3000);
// main device function
if (temp > 24 || temp < 15)
{
// 2 quick flashes and beeps every 3 seconds
digitalWrite(ledPin, HIGH);
digitalWrite(buzzerPin, HIGH);
tone(buzzerPin, TONE_1);
delay(100);
noTone(buzzerPin);
digitalWrite(ledPin, LOW);
digitalWrite(buzzerPin, LOW);
delay(100);
digitalWrite(ledPin, HIGH);
digitalWrite(buzzerPin, HIGH);
tone(buzzerPin, TONE_1);
delay(100);
noTone(buzzerPin);
digitalWrite(ledPin, LOW);
digitalWrite(buzzerPin, LOW);
delay(3000);
}
// LED will flash but no sound when under comfort level
else if (temp < 19)
{
digitalWrite(ledPin, LOW);
delay(100);
digitalWrite(ledPin, HIGH);
delay(100);
digitalWrite(ledPin, LOW);
delay(100);
digitalWrite(ledPin, HIGH);
delay(100);
digitalWrite(ledPin, LOW);
delay(100);
digitalWrite(ledPin, HIGH);
delay(3000);
}
// LED will stay on when idle
else
{
digitalWrite(ledPin, HIGH);
}
ThingSpeak.setField(1,temp);
ThingSpeak.writeFields(channelNo, writeAPI);
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment