SekolahRobot
Published © GPL3+

E-Nursing

E-Nursing improvement healthcare by incorporating advanced technologies to improve patient care, data management, and remote monitoring

BeginnerFull instructions provided5 hours181
E-Nursing

Things used in this project

Hardware components

ESP8266 ESP-12E
Espressif ESP8266 ESP-12E
×1

Software apps and online services

Arduino IDE
Arduino IDE

Hand tools and fabrication machines

Soldering iron (generic)
Soldering iron (generic)
Solder Wire, Lead Free
Solder Wire, Lead Free

Story

Read more

Schematics

Schematic

Code

digitalnurse_web.ino

C/C++
#include <ESP8266WiFi.h>
#include <ESP8266HTTPClient.h>

WiFiClient wifiClient;

char buff[64];
bool b_read, b_discard;
char discard;
int i,j=0;
char final_buff[64];

int hexSys,hexDias,hexBPM;
int flag,prosesflag,prosesflag2;

const char* ssid = "Sekolah Robot Indonesia";
const char* password = "sadapsadap";

void setup() {
  // put your setup code here, to run once:
  Serial.begin(115200);
  Serial.print("test Tekanan");
  pinMode(D4,OUTPUT);
  WiFi.mode(WIFI_STA);
  WiFi.begin(ssid, password);
    int i=0;
    while(WiFi.status() != WL_CONNECTED){
      digitalWrite(D4,HIGH); 
      Serial.print(".");
      delay(1000);     
    } 
  Serial.println("");
  digitalWrite(D4,LOW);
  Serial.println("WiFi connected");
  Serial.println("IP address: ");
  Serial.println(WiFi.localIP());
  Serial.println();
}

void loop() {
  // put your main code here, to run repeatedly:
  bacaalat();
  if(prosesflag2==0 && prosesflag==1)
  {
    Serial.println("StartReading");
    prosesflag2=1;
  }

   if(flag==1)
    {
    Serial.print("SYS : ");
    Serial.println(hexSys);
    Serial.print("DIA : ");
    Serial.println(hexDias);
    Serial.print("BPM : ");
    Serial.println(hexBPM);
    uploadDB(hexSys,hexDias,hexBPM);
    delay(1000);
    flag=0;
    prosesflag=0;
    prosesflag2=0;
    }
    if(flag==2)
    {
    Serial.println("error");
    delay(1000);
    flag=0;
    prosesflag=0;
    prosesflag2=0;
    
    }
  
}

void bacaalat()
{
while (Serial.available()) {
}
}

void uploadDB(int sys, int dia, int bpm)
{
  
  HTTPClient http;
        String url = "http://192.168.0.7/digitalnurse/updatedata.php?sys="+String(sys)+"&dia="+String(dia)+"&bpm="+String(bpm);
        Serial.println(url);     
        http.begin(wifiClient,url);
       
        //GET method
        int httpCode = http.GET();
        if(httpCode > 0)
        {
          Serial.printf("[HTTP] GET...code: %d\n", httpCode);
          if(httpCode == HTTP_CODE_OK)
          {
              String payload = http.getString();
              Serial.println(payload);
          }
       }
       else
       {
            Serial.printf("[HTTP] GET... failed, error: %s\n", http.errorToString(httpCode).c_str());
       }
          http.end();
          delay(5000);
}

PHP code

PHP
<?php

if(isset($_GET["sys"])) {
   $ddia = $_GET["dia"]; 
   $dbpm = $_GET["bpm"];    
   $dsys = $_GET["sys"];    
   
   $servername = "localhost";
   $username = "root";
   $password = "";
   $database_name = "digitalnurse_db";

//	$tanggal = date("Y-m-d", time() + (86400*$ddate));
	
//	echo $tanggal;
   
   // Create MySQL connection fom PHP to MySQL server
   $connection = new mysqli($servername, $username, $password, $database_name);
   // Check connection
   if ($connection->connect_error) {
      die("MySQL connection failed: " . $connection->connect_error);
   }
   

	
		$sql = "INSERT INTO data_bloodpresure (hexSys, hexDias, hexBPM, timestamp) VALUES ($dsys, $ddia, $dbpm, NOW())";
		echo $sql;
		   if ($connection->query($sql) === TRUE) {
			  echo "New record created successfully";
		   } else {
			  echo "Error: " . $sql . " => " . $connection->error;
		   }

   $connection->close();
} else {
   echo "a is not set in the HTTP request";
}
?>

Credits

SekolahRobot
9 projects • 21 followers
Sekolah Robot Indonesia is non formal education in Indonesia to learning about robot, and base on Community
Contact

Comments

Please log in or sign up to comment.