[go: up one dir, main page]

0% found this document useful (0 votes)
8 views6 pages

Code

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views6 pages

Code

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

#include <Wire.

h>

#include <WiFi.h>

#include <HTTPClient.h>

#include <Adafruit_SSD1306.h>

#include "MAX30105.h"

#include "Adafruit_MLX90632.h"

#include "Adafruit_SHTC3.h"

#include "Adafruit_LSM6DS3.h"

// WiFi credentials

const char* ssid = "YOUR_WIFI";

const char* password = "YOUR_PASS";

// Server endpoint (Flask or Cloud dashboard)

const char* server = "http://192.168.1.100:5000/data";

// Objects for sensors

MAX30105 particleSensor;
Adafruit_MLX90632 mlx = Adafruit_MLX90632();

Adafruit_SHTC3 shtc3 = Adafruit_SHTC3();

Adafruit_SSD1306 display(128, 64, &Wire);

// Setup

void setup() {

Serial.begin(115200);

// Connect WiFi

WiFi.begin(ssid, password);

while (WiFi.status() != WL_CONNECTED) {

delay(500);

Serial.print(".");

Serial.println("WiFi Connected!");

// Init display
if(!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) {

Serial.println("SSD1306 allocation failed");

for(;;);

display.clearDisplay();

display.setTextSize(1);

display.setTextColor(SSD1306_WHITE);

display.setCursor(0,0);

display.println("Firefighter Health");

display.display();

// Init sensors

particleSensor.begin(Wire, I2C_SPEED_STANDARD);

mlx.begin();

shtc3.begin();

// Loop
void loop() {

// Dummy values (replace with actual sensor reads)

float heartRate = 78.0;

float temp = mlx.readObjectTempC();

sensors_event_t humidity, temp_event;

shtc3.getEvent(&humidity, &temp_event);

float hum = humidity.relative_humidity;

// Display on OLED

display.clearDisplay();

display.setCursor(0,0);

display.printf("HR: %.1f\n", heartRate);

display.printf("Temp: %.1f C\n", temp);

display.printf("Hum: %.1f %%\n", hum);

display.display();

// Send to server
if(WiFi.status() == WL_CONNECTED) {

HTTPClient http;

http.begin(server);

http.addHeader("Content-Type", "application/json");

String json = "{";

json += "\"hr\":" + String(heartRate) + ",";

json += "\"temp\":" + String(temp) + ",";

json += "\"hum\":" + String(hum);

json += "}";

int httpResponseCode = http.POST(json);

if(httpResponseCode > 0) {

Serial.printf("Data sent, code: %d\n", httpResponseCode);

} else {

Serial.printf("Error: %s\n", http

.errorToString(httpResponseCode).c_str());

}
http.end();

delay(2000);

You might also like