Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
H
Heal_App
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
TMP-23-365
Heal_App
Commits
5bafd706
Commit
5bafd706
authored
Aug 30, 2023
by
Yomal-Dulanjana
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
IOT file create and test done
parent
6c9d08c2
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
294 additions
and
0 deletions
+294
-0
iot/Blink.ino
iot/Blink.ino
+217
-0
iot/icon.h
iot/icon.h
+77
-0
No files found.
iot/Blink.ino
0 → 100644
View file @
5bafd706
#include <Wire.h>
#include "MAX30100_PulseOximeter.h"
#include <OneWire.h>
#include <DallasTemperature.h>
#include <ESP8266WiFi.h>
#include <ESP8266HTTPClient.h>
#include "Adafruit_GFX.h"
#include "OakOLED.h"
#include "icon.h"
//------------------------------------------------------------------------------
#define WIFI_SSID "Galaxy"
#define WIFI_PASS "00000000"
#define SERVER_API "http://192.168.48.209:5000/record"
#define SERVER_SYNC_DELAY 30 // in seconds
#define DEVICE_ID "15555000"
//------------------------------------------------------------------------------
#define REPORTING_PERIOD_MS 1000
OakOLED
oled
;
PulseOximeter
pox
;
float
BPM
,
SpO2
;
uint32_t
tsLastReport
=
0
;
int
serverSyncDelay
=
0
;
const
int
oneWireBus
=
12
;
OneWire
oneWire
(
oneWireBus
);
DallasTemperature
tempsensor
(
&
oneWire
);
float
tempC
;
void
setup
()
{
oled
.
begin
();
Serial
.
begin
(
9600
);
oled
.
clearDisplay
();
oled
.
setTextSize
(
1
);
oled
.
setTextColor
(
1
);
oled
.
setCursor
(
40
,
32
);
oled
.
println
(
"Initializing"
);
oled
.
display
();
delay
(
1000
);
pinMode
(
16
,
OUTPUT
);
WiFi
.
begin
(
WIFI_SSID
,
WIFI_PASS
);
while
(
WiFi
.
status
()
!=
WL_CONNECTED
)
{
delay
(
500
);
oled
.
clearDisplay
();
oled
.
setCursor
(
20
,
32
);
oled
.
println
(
"wifi connecting"
);
oled
.
display
();
}
pox_start
();
// if (!pox.begin()){
// oled.clearDisplay();
// oled.setCursor(40, 32);
// oled.println("POX Error");
// oled.display();
// for (;;);
// }
// else
// {
// oled.clearDisplay();
// oled.setTextSize(1);
// oled.setTextColor(1);
// oled.setCursor(40, 32);
// oled.println("POX SUCCESS");
// oled.display();
// }
pox
.
setIRLedCurrent
(
MAX30100_LED_CURR_7_6MA
);
// WiFi.begin("yourSSID", "yourPASS");
//
tempsensor
.
begin
();
}
void
loop
()
{
tempsensor
.
requestTemperatures
();
tempC
=
tempsensor
.
getTempCByIndex
(
0
);
pox
.
update
();
BPM
=
pox
.
getHeartRate
();
SpO2
=
pox
.
getSpO2
();
//
if
(
millis
()
-
tsLastReport
>
REPORTING_PERIOD_MS
)
{
oled
.
clearDisplay
();
if
(
WiFi
.
status
()
!=
WL_CONNECTED
){
oled
.
drawBitmap
(
112
,
0
,
icon_wifi_off
,
16
,
16
,
1
);
}
else
{
oled
.
drawBitmap
(
112
,
0
,
icon_wifi_on
,
16
,
16
,
1
);
if
(
serverSyncDelay
==
SERVER_SYNC_DELAY
){
pox
.
shutdown
();
sendDatatoServer
();
serverSyncDelay
=
0
;}
serverSyncDelay
++
;
}
oled
.
drawBitmap
(
0
,
0
,
icon_temperature
,
16
,
16
,
1
);
oled
.
drawBitmap
(
40
,
25
,
icon_heart
,
28
,
28
,
1
);
oled
.
setCursor
(
24
,
0
);
oled
.
setTextSize
(
2
);
oled
.
print
((
int
)
tempC
);
oled
.
println
(
"C"
);
oled
.
setCursor
(
0
,
29
);
oled
.
setTextSize
(
1
);
oled
.
println
(
"BPM"
);
oled
.
setCursor
(
76
,
29
);
oled
.
println
(
"Oxygen"
);
oled
.
setCursor
(
0
,
40
);
oled
.
setTextSize
(
2
);
oled
.
println
((
int
)
pox
.
getHeartRate
());
oled
.
setCursor
(
76
,
40
);
oled
.
println
(
pox
.
getSpO2
());
oled
.
display
();
tsLastReport
=
millis
();
//setup_dispaly();
}
//pox.resume();
}
void
pox_start
(){
if
(
!
pox
.
begin
()){
// oled.clearDisplay();
// oled.setCursor(40, 32);
// oled.println("POX Error");
// oled.display();
for
(;;);
}
else
{
oled
.
clearDisplay
();
oled
.
setTextSize
(
1
);
oled
.
setTextColor
(
1
);
oled
.
setCursor
(
40
,
32
);
oled
.
println
(
"POX SUCCESS"
);
oled
.
display
();
}
pox
.
setIRLedCurrent
(
MAX30100_LED_CURR_7_6MA
);
}
void
sendDatatoServer
(){
oled
.
clearDisplay
();
oled
.
setTextSize
(
1
);
oled
.
setCursor
(
40
,
32
);
oled
.
println
(
"Sending Data"
);
oled
.
display
();
WiFiClient
client
;
HTTPClient
http
;
http
.
begin
(
client
,
SERVER_API
);
//HTTP
http
.
addHeader
(
"Content-Type"
,
"application/json"
);
Serial
.
print
(
"[HTTP] POST...
\n
"
);
// start connection and send HTTP header and body
int
httpCode
=
http
.
POST
(
"{
\"
temperature
\"
:
\"
"
+
(
String
)
tempC
+
"
\"
,
\"
bpm
\"
:
\"
"
+
(
String
)
BPM
+
"
\"
,
\"
spo2
\"
:
\"
"
+
(
String
)
SpO2
+
"
\"
,
\"
deviceid
\"
:
\"
"
+
DEVICE_ID
+
"
\"
}"
);
// httpCode will be negative on error
if
(
httpCode
>
0
)
{
// HTTP header has been send and Server response header has been handled
Serial
.
printf
(
"[HTTP] POST... code: %d
\n
"
,
httpCode
);
// file found at server
if
(
httpCode
==
HTTP_CODE_OK
)
{
const
String
&
payload
=
http
.
getString
();
Serial
.
println
(
"received payload:
\n
<<"
);
Serial
.
println
(
payload
);
Serial
.
println
(
">>"
);
}
}
else
{
Serial
.
printf
(
"[HTTP] POST... failed, error: %s
\n
"
,
http
.
errorToString
(
httpCode
).
c_str
());
oled
.
clearDisplay
();
oled
.
setTextSize
(
1
);
oled
.
setCursor
(
40
,
32
);
oled
.
println
(
"HTTP Faild"
);
oled
.
display
();
}
http
.
end
();
delay
(
2000
);
pox_start
();
}
iot/icon.h
0 → 100644
View file @
5bafd706
const
unsigned
char
icon_wifi_on
[]
PROGMEM
=
{
0
b00000000
,
0
b00000000
,
//
0
b00000111
,
0
b11100000
,
// ######
0
b00011111
,
0
b11111000
,
// ##########
0
b00111111
,
0
b11111100
,
// ############
0
b01110000
,
0
b00001110
,
// ### ###
0
b01100111
,
0
b11100110
,
// ## ###### ##
0
b00001111
,
0
b11110000
,
// ########
0
b00011000
,
0
b00011000
,
// ## ##
0
b00000011
,
0
b11000000
,
// ####
0
b00000111
,
0
b11100000
,
// ######
0
b00000100
,
0
b00100000
,
// # #
0
b00000001
,
0
b10000000
,
// ##
0
b00000001
,
0
b10000000
,
// ##
0
b00000000
,
0
b00000000
,
//
0
b00000000
,
0
b00000000
,
//
0
b00000000
,
0
b00000000
,
//
};
const
unsigned
char
icon_temperature
[]
PROGMEM
=
{
0
b00000001
,
0
b11000000
,
// ###
0
b00000011
,
0
b11100000
,
// #####
0
b00000111
,
0
b00100000
,
// ### #
0
b00000111
,
0
b11100000
,
// ######
0
b00000111
,
0
b00100000
,
// ### #
0
b00000111
,
0
b11100000
,
// ######
0
b00000111
,
0
b00100000
,
// ### #
0
b00000111
,
0
b11100000
,
// ######
0
b00000111
,
0
b00100000
,
// ### #
0
b00001111
,
0
b11110000
,
// ########
0
b00011111
,
0
b11111000
,
// ##########
0
b00011111
,
0
b11111000
,
// ##########
0
b00011111
,
0
b11111000
,
// ##########
0
b00011111
,
0
b11111000
,
// ##########
0
b00001111
,
0
b11110000
,
// ########
0
b00000111
,
0
b11100000
,
// ######
};
const
unsigned
char
icon_heart
[]
PROGMEM
=
{
0x00
,
0x00
,
0x00
,
0x00
,
0x01
,
0x80
,
0x18
,
0x00
,
0x0f
,
0xe0
,
0x7f
,
0x00
,
0x3f
,
0xf9
,
0xff
,
0xc0
,
0x7f
,
0xf9
,
0xff
,
0xc0
,
0x7f
,
0xff
,
0xff
,
0xe0
,
0x7f
,
0xff
,
0xff
,
0xe0
,
0xff
,
0xff
,
0xff
,
0xf0
,
0xff
,
0xf7
,
0xff
,
0xf0
,
0xff
,
0xe7
,
0xff
,
0xf0
,
0xff
,
0xe7
,
0xff
,
0xf0
,
0x7f
,
0xdb
,
0xff
,
0xe0
,
0x7f
,
0x9b
,
0xff
,
0xe0
,
0x00
,
0x3b
,
0xc0
,
0x00
,
0x3f
,
0xf9
,
0x9f
,
0xc0
,
0x3f
,
0xfd
,
0xbf
,
0xc0
,
0x1f
,
0xfd
,
0xbf
,
0x80
,
0x0f
,
0xfd
,
0x7f
,
0x00
,
0x07
,
0xfe
,
0x7e
,
0x00
,
0x03
,
0xfe
,
0xfc
,
0x00
,
0x01
,
0xff
,
0xf8
,
0x00
,
0x00
,
0xff
,
0xf0
,
0x00
,
0x00
,
0x7f
,
0xe0
,
0x00
,
0x00
,
0x3f
,
0xc0
,
0x00
,
0x00
,
0x0f
,
0x00
,
0x00
,
0x00
,
0x06
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
};
const
unsigned
char
icon_wifi_off
[]
PROGMEM
=
{
0
b00000000
,
0
b00000000
,
//
0
b00000011
,
0
b11100000
,
// #####
0
b00001111
,
0
b11111000
,
// #########
0
b00011111
,
0
b11111100
,
// ###########
0
b00111110
,
0
b00111110
,
// ##### #####
0
b00111000
,
0
b01111110
,
// ### ######
0
b01110000
,
0
b11111111
,
// ### ########
0
b01110001
,
0
b11110111
,
// ### ##### ###
0
b01110011
,
0
b11000111
,
// ### #### ###
0
b01110111
,
0
b10000111
,
// ### #### ###
0
b00111111
,
0
b00001110
,
// ###### ###
0
b00111110
,
0
b00011110
,
// ##### ####
0
b00011111
,
0
b11111100
,
// ###########
0
b00001111
,
0
b11111000
,
// #########
0
b00000011
,
0
b11100000
,
// #####
0
b00000000
,
0
b00000000
,
//
};
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