Elmin Delibašić
Published © GPL3+

COVID-19: Doctor's dashboard

COVID-19 Doctor's Dashboard

AdvancedFull instructions providedOver 4 days768
COVID-19: Doctor's dashboard

Things used in this project

Hardware components

balenaFin
balenaFin
×1
Compute Module 3 Lite
Raspberry Pi Compute Module 3 Lite
×1
Thunderboard™ Sense 2 Sensor-to-Cloud Advanced IoT Development Kit
Silicon Labs Thunderboard™ Sense 2 Sensor-to-Cloud Advanced IoT Development Kit
×1
Audio / Video Cable Assembly, Ultra Slim RedMere HDMI to HDMI
Audio / Video Cable Assembly, Ultra Slim RedMere HDMI to HDMI
×1
5V 2.5A Switching Power Supply
Digilent 5V 2.5A Switching Power Supply
×1
Coin Cell Battery CR2032
Coin Cell Battery CR2032
×1
Arduino MKR WiFi 1010
Arduino MKR WiFi 1010
×1
NTC Thermistor
×1
Resistor 10k ohm
Resistor 10k ohm
×1
Andorid TV
×1

Software apps and online services

Raspbian
Raspberry Pi Raspbian
Firebase
Google Firebase
Arduino IDE
Arduino IDE
Android Studio
Android Studio

Story

Read more

Custom parts and enclosures

Android TV application (apk file)

Schematics

Arduino MKR 1010 Wifi and NTC Thermistor shema

Communication

Code

Arduino MKR 1010 WiFi code

Arduino
#include "Firebase_Arduino_WiFiNINA.h"

#define FIREBASE_HOST "Firebase_database_link"
#define FIREBASE_AUTH "Firebase_secret"
#define WIFI_SSID "Wifi_name
#define WIFI_PASSWORD "Wifi_password"

FirebaseData firebaseData;



void getTemp(float * t)
{

  const int analogPin = A2; // replace 0 with analog pin
  const float invBeta = 1.00 / 3380.00;   // replace "Beta" with beta of thermistor

  const  float adcMax = 1023.00;
  const float invT0 = 1.00 / 298.15;   // room temp in Kelvin

  int adcVal, i, numSamples = 5;
  float  K, C, F;

  adcVal = 0;
  for (i = 0; i < numSamples; i++)
   {
     adcVal = adcVal + analogRead(analogPin);
     delay(100);
   }
  adcVal = adcVal/5;
  K = 1.00 / (invT0 + invBeta*(log ( adcMax / (float) adcVal - 1.00)));
  C = K - 273.15;                      // convert to Celsius
  t[0] = K; t[1] = C; t[2] = F;
  return;
}

void setup()
{
  pinMode(A2, INPUT);
  Serial.begin(9600);



  //------------------------------

  Serial.print("Connecting to WiFi");
  
  int status = WL_IDLE_STATUS;
  
  while (status != WL_CONNECTED)
  {
    status = WiFi.begin(WIFI_SSID, WIFI_PASSWORD);
    Serial.print(".");
    delay(300);
  }
  Serial.println();
  Serial.print("IP address: ");
  Serial.println(WiFi.localIP());
  Serial.println();
  Serial.println("------------------------------------------------------------------------------------");
  
  //--------------------------------------------------------------------------

  
  Firebase.begin(FIREBASE_HOST, FIREBASE_AUTH, WIFI_SSID, WIFI_PASSWORD);
  Firebase.reconnectWiFi(true); 
}

void loop()
{
  float temp[3];
  getTemp(temp);


  Firebase.setFloat(firebaseData, "/P2_temperature", temp[1]);
  delay(2000);
}

activity_main.xml

XML
Android Studio XML file for Android TV application
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/main_browse_fragment"
    android:name="com.example.doctorsdashboard.MainFragment"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity"
    tools:deviceIds="tv"
    tools:ignore="MergeRootFrame" >

<RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="80dp"
    android:background="@color/default_background">
    <TextView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:gravity="center"
        android:text="Doctor's Dashboard"
        android:textSize="25dp"></TextView>
</RelativeLayout>

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="400dp"
        android:layout_marginTop="110dp"
        android:layout_marginLeft="50dp"
        android:layout_marginRight="50dp">

        <RelativeLayout
            android:id="@+id/RLayout1"
            android:layout_width="200dp"
            android:layout_height="120dp"
            android:background="@color/default_background">
            <TextView
                android:layout_width="match_parent"
                android:layout_height="30dp"
                android:text="Patient 1"
                android:gravity="center"></TextView>
            <TextView
                android:layout_marginTop="30dp"
                android:layout_marginLeft="10dp"
                android:layout_width="100dp"
                android:layout_height="30dp"
                android:gravity="center_vertical"
                android:text="Temperature: "
                ></TextView>
            <TextView
                android:layout_marginTop="60dp"
                android:layout_marginLeft="10dp"
                android:layout_width="100dp"
                android:layout_height="30dp"
                android:text="Humidity: "
                android:gravity="center_vertical"
                ></TextView>
            <TextView
                android:layout_marginTop="90dp"
                android:layout_marginLeft="10dp"
                android:layout_width="100dp"
                android:layout_height="30dp"
                android:text="Pulse: "
                android:gravity="center_vertical"
                ></TextView>

            <TextView
                android:id="@+id/p1Temperature"
                android:layout_marginTop="30dp"
                android:layout_marginLeft="100dp"
                android:layout_width="100dp"
                android:layout_height="30dp"
                android:text="N/N: "
                android:gravity="center"
                ></TextView>

            <TextView
                android:id="@+id/p1Pressure"
                android:layout_marginTop="60dp"
                android:layout_marginLeft="100dp"
                android:layout_width="100dp"
                android:layout_height="30dp"
                android:text="N/N: "
                android:gravity="center"
                ></TextView>

            <TextView
                android:id="@+id/p1Pulse"
                android:layout_marginTop="90dp"
                android:layout_marginLeft="100dp"
                android:layout_width="100dp"
                android:layout_height="30dp"
                android:text="N/N: "
                android:gravity="center"
                ></TextView>

        </RelativeLayout>

        <RelativeLayout
            android:id="@+id/RLayout2"
            android:layout_width="200dp"
            android:layout_height="120dp"
            android:layout_marginLeft="220dp"
            android:background="@color/default_background">
            <TextView
                android:layout_width="match_parent"
                android:layout_height="30dp"
                android:text="Patient 2"
                android:gravity="center"></TextView>
            <TextView
                android:layout_marginTop="30dp"
                android:layout_marginLeft="10dp"
                android:layout_width="100dp"
                android:layout_height="30dp"
                android:gravity="center_vertical"
                android:text="Temperature: "
                ></TextView>
            <TextView
                android:layout_marginTop="60dp"
                android:layout_width="100dp"
                android:layout_marginLeft="10dp"
                android:layout_height="30dp"
                android:text="Pressure: "
                android:gravity="center_vertical"
                ></TextView>
            <TextView
                android:layout_marginTop="90dp"
                android:layout_width="100dp"
                android:layout_marginLeft="10dp"
                android:layout_height="30dp"
                android:text="Pulse: "
                android:gravity="center_vertical"
                ></TextView>

            <TextView
                android:id="@+id/p2Temperature"
                android:layout_marginTop="30dp"
                android:layout_marginLeft="100dp"
                android:layout_width="100dp"
                android:layout_height="30dp"
                android:text="N/N: "
                android:gravity="center"
                ></TextView>

            <TextView
                android:id="@+id/p2Pressure"
                android:layout_marginTop="60dp"
                android:layout_marginLeft="100dp"
                android:layout_width="100dp"
                android:layout_height="30dp"
                android:text="N/N: "
                android:gravity="center"
                ></TextView>

            <TextView
                android:id="@+id/p2Pulse"
                android:layout_marginTop="90dp"
                android:layout_marginLeft="100dp"
                android:layout_width="100dp"
                android:layout_height="30dp"
                android:text="N/N: "
                android:gravity="center"
                ></TextView>

        </RelativeLayout>

        <RelativeLayout
            android:id="@+id/RLayout3"
            android:layout_marginLeft="440dp"
            android:layout_width="200dp"
            android:layout_height="120dp"
            android:background="@color/default_background">
            <TextView
                android:layout_width="match_parent"
                android:layout_height="30dp"
                android:text="Patient 3"
                android:gravity="center"></TextView>
            <TextView
                android:layout_marginTop="30dp"
                android:layout_marginLeft="10dp"
                android:layout_width="100dp"
                android:layout_height="30dp"
                android:gravity="center_vertical"
                android:text="Temperature: "
                ></TextView>
            <TextView
                android:layout_marginTop="60dp"
                android:layout_marginLeft="10dp"
                android:layout_width="100dp"
                android:layout_height="30dp"
                android:text="Pressure: "
                android:gravity="center_vertical"
                ></TextView>
            <TextView
                android:layout_marginTop="90dp"
                android:layout_marginLeft="10dp"
                android:layout_width="100dp"
                android:layout_height="30dp"
                android:text="Pulse: "
                android:gravity="center_vertical"
                ></TextView>

            <TextView
                android:id="@+id/p3Temperature"
                android:layout_marginTop="30dp"
                android:layout_marginLeft="100dp"
                android:layout_width="100dp"
                android:layout_height="30dp"
                android:text="N/N: "
                android:gravity="center"
                ></TextView>

            <TextView
                android:id="@+id/p3Pressure"
                android:layout_marginTop="60dp"
                android:layout_marginLeft="100dp"
                android:layout_width="100dp"
                android:layout_height="30dp"
                android:text="N/N: "
                android:gravity="center"
                ></TextView>

            <TextView
                android:id="@+id/p3Pulse"
                android:layout_marginTop="90dp"
                android:layout_marginLeft="100dp"
                android:layout_width="100dp"
                android:layout_height="30dp"
                android:text="N/N: "
                android:gravity="center"
                ></TextView>

        </RelativeLayout>

        <RelativeLayout
            android:id="@+id/RLayout4"
            android:layout_width="200dp"
            android:layout_height="120dp"
            android:layout_marginLeft="660dp"
            android:background="@color/default_background">
            <TextView
                android:layout_width="match_parent"
                android:layout_height="30dp"
                android:text="Patient 4"
                android:gravity="center"></TextView>
            <TextView
                android:layout_marginTop="30dp"
                android:layout_marginLeft="10dp"
                android:layout_width="100dp"
                android:layout_height="30dp"
                android:gravity="center_vertical"
                android:text="Temperature: "
                ></TextView>
            <TextView
                android:layout_marginTop="60dp"
                android:layout_width="100dp"
                android:layout_marginLeft="10dp"
                android:layout_height="30dp"
                android:text="Pressure: "
                android:gravity="center_vertical"
                ></TextView>
            <TextView
                android:layout_marginTop="90dp"
                android:layout_width="100dp"
                android:layout_marginLeft="10dp"
                android:layout_height="30dp"
                android:text="Pulse: "
                android:gravity="center_vertical" ></TextView>

            <TextView
                android:id="@+id/p4Temperature"
                android:layout_marginTop="30dp"
                android:layout_marginLeft="100dp"
                android:layout_width="100dp"
                android:layout_height="30dp"
                android:text="N/N: "
                android:gravity="center" ></TextView>

            <TextView
                android:id="@+id/p4Pressure"
                android:layout_marginTop="60dp"
                android:layout_marginLeft="100dp"
                android:layout_width="100dp"
                android:layout_height="30dp"
                android:text="N/N: "
                android:gravity="center" ></TextView>

            <TextView
                android:id="@+id/p4Pulse"
                android:layout_marginTop="90dp"
                android:layout_marginLeft="100dp"
                android:layout_width="100dp"
                android:layout_height="30dp"
                android:text="N/N: "
                android:gravity="center" ></TextView>

        </RelativeLayout>




        <RelativeLayout
            android:layout_width="200dp"
            android:layout_height="120dp"
            android:layout_marginTop="140dp"
            android:background="@color/default_background">
            <TextView
                android:layout_width="match_parent"
                android:layout_height="30dp"
                android:text="Patient 5"
                android:gravity="center"></TextView>
            <TextView
                android:layout_marginTop="30dp"
                android:layout_marginLeft="10dp"
                android:layout_width="100dp"
                android:layout_height="30dp"
                android:gravity="center_vertical"
                android:text="Temperature: "
                ></TextView>
            <TextView
                android:layout_marginTop="60dp"
                android:layout_marginLeft="10dp"
                android:layout_width="100dp"
                android:layout_height="30dp"
                android:text="Pressure: "
                android:gravity="center_vertical"
                ></TextView>
            <TextView
                android:layout_marginTop="90dp"
                android:layout_marginLeft="10dp"
                android:layout_width="100dp"
                android:layout_height="30dp"
                android:text="Pulse: "
                android:gravity="center_vertical"
                ></TextView>

            <TextView
                android:id="@+id/p5Temperature"
                android:layout_marginTop="30dp"
                android:layout_marginLeft="100dp"
                android:layout_width="100dp"
                android:layout_height="30dp"
                android:text="N/N: "
                android:gravity="center"
                ></TextView>

            <TextView
                android:id="@+id/p5Pressure"
                android:layout_marginTop="60dp"
                android:layout_marginLeft="100dp"
                android:layout_width="100dp"
                android:layout_height="30dp"
                android:text="N/N: "
                android:gravity="center"
                ></TextView>

            <TextView
                android:id="@+id/p5Pulse"
                android:layout_marginTop="90dp"
                android:layout_marginLeft="100dp"
                android:layout_width="100dp"
                android:layout_height="30dp"
                android:text="N/N: "
                android:gravity="center"
                ></TextView>

        </RelativeLayout>

        <RelativeLayout
            android:layout_width="200dp"
            android:layout_height="120dp"
            android:layout_marginTop="140dp"
            android:layout_marginLeft="220dp"
            android:background="@color/default_background">
            <TextView
                android:layout_width="match_parent"
                android:layout_height="30dp"
                android:text="Patient 6"
                android:gravity="center"></TextView>
            <TextView
                android:layout_marginTop="30dp"
                android:layout_marginLeft="10dp"
                android:layout_width="100dp"
                android:layout_height="30dp"
                android:gravity="center_vertical"
                android:text="Temperature: "
                ></TextView>
            <TextView
                android:layout_marginTop="60dp"
                android:layout_width="100dp"
                android:layout_marginLeft="10dp"
                android:layout_height="30dp"
                android:text="Pressure: "
                android:gravity="center_vertical"
                ></TextView>
            <TextView
                android:layout_marginTop="90dp"
                android:layout_width="100dp"
                android:layout_marginLeft="10dp"
                android:layout_height="30dp"
                android:text="Pulse: "
                android:gravity="center_vertical"
                ></TextView>

            <TextView
                android:id="@+id/p6Temperature"
                android:layout_marginTop="30dp"
                android:layout_marginLeft="100dp"
                android:layout_width="100dp"
                android:layout_height="30dp"
                android:text="N/N: "
                android:gravity="center"
                ></TextView>

            <TextView
                android:id="@+id/p6Pressure"
                android:layout_marginTop="60dp"
                android:layout_marginLeft="100dp"
                android:layout_width="100dp"
                android:layout_height="30dp"
                android:text="N/N: "
                android:gravity="center"
                ></TextView>

            <TextView
                android:id="@+id/p6Pulse"
                android:layout_marginTop="90dp"
                android:layout_marginLeft="100dp"
                android:layout_width="100dp"
                android:layout_height="30dp"
                android:text="N/N: "
                android:gravity="center"
                ></TextView>

        </RelativeLayout>

        <RelativeLayout
            android:layout_marginLeft="440dp"
            android:layout_marginTop="140dp"
            android:layout_width="200dp"
            android:layout_height="120dp"
            android:background="@color/default_background">
            <TextView
                android:layout_width="match_parent"
                android:layout_height="30dp"
                android:text="Patient 7"
                android:gravity="center"></TextView>
            <TextView
                android:layout_marginTop="30dp"
                android:layout_marginLeft="10dp"
                android:layout_width="100dp"
                android:layout_height="30dp"
                android:gravity="center_vertical"
                android:text="Temperature: "
                ></TextView>
            <TextView
                android:layout_marginTop="60dp"
                android:layout_marginLeft="10dp"
                android:layout_width="100dp"
                android:layout_height="30dp"
                android:text="Pressure: "
                android:gravity="center_vertical"
                ></TextView>
            <TextView
                android:layout_marginTop="90dp"
                android:layout_marginLeft="10dp"
                android:layout_width="100dp"
                android:layout_height="30dp"
                android:text="Pulse: "
                android:gravity="center_vertical"
                ></TextView>

            <TextView
                android:id="@+id/p7Temperature"
                android:layout_marginTop="30dp"
                android:layout_marginLeft="100dp"
                android:layout_width="100dp"
                android:layout_height="30dp"
                android:text="N/N: "
                android:gravity="center"
                ></TextView>

            <TextView
                android:id="@+id/p7HuPressure"
                android:layout_marginTop="60dp"
                android:layout_marginLeft="100dp"
                android:layout_width="100dp"
                android:layout_height="30dp"
                android:text="N/N: "
                android:gravity="center"
                ></TextView>

            <TextView
                android:id="@+id/p7Pulse"
                android:layout_marginTop="90dp"
                android:layout_marginLeft="100dp"
                android:layout_width="100dp"
                android:layout_height="30dp"
                android:text="N/N: "
                android:gravity="center"
                ></TextView>

        </RelativeLayout>

        <RelativeLayout
            android:layout_width="200dp"
            android:layout_marginTop="140dp"
            android:layout_height="120dp"
            android:layout_marginLeft="660dp"
            android:background="@color/default_background">
            <TextView
                android:layout_width="match_parent"
                android:layout_height="30dp"
                android:text="Patient 8"
                android:gravity="center"></TextView>
            <TextView
                android:layout_marginTop="30dp"
                android:layout_marginLeft="10dp"
                android:layout_width="100dp"
                android:layout_height="30dp"
                android:gravity="center_vertical"
                android:text="Temperature: "
                ></TextView>
            <TextView
                android:layout_marginTop="60dp"
                android:layout_width="100dp"
                android:layout_marginLeft="10dp"
                android:layout_height="30dp"
                android:text="Pressure: "
                android:gravity="center_vertical"
                ></TextView>
            <TextView
                android:layout_marginTop="90dp"
                android:layout_width="100dp"
                android:layout_marginLeft="10dp"
                android:layout_height="30dp"
                android:text="Pulse: "
                android:gravity="center_vertical" ></TextView>

            <TextView
                android:id="@+id/p8Temperature"
                android:layout_marginTop="30dp"
                android:layout_marginLeft="100dp"
                android:layout_width="100dp"
                android:layout_height="30dp"
                android:text="N/N: "
                android:gravity="center" ></TextView>

            <TextView
                android:id="@+id/p8Pressure"
                android:layout_marginTop="60dp"
                android:layout_marginLeft="100dp"
                android:layout_width="100dp"
                android:layout_height="30dp"
                android:text="N/N: "
                android:gravity="center" ></TextView>

            <TextView
                android:id="@+id/p8Pulse"
                android:layout_marginTop="90dp"
                android:layout_marginLeft="100dp"
                android:layout_width="100dp"
                android:layout_height="30dp"
                android:text="N/N: "
                android:gravity="center" ></TextView>

        </RelativeLayout>




        <RelativeLayout
            android:layout_width="200dp"
            android:layout_height="120dp"
            android:layout_marginTop="280dp"
            android:background="@color/default_background">
            <TextView
                android:layout_width="match_parent"
                android:layout_height="30dp"
                android:text="Patient 9"
                android:gravity="center"></TextView>
            <TextView
                android:layout_marginTop="30dp"
                android:layout_marginLeft="10dp"
                android:layout_width="100dp"
                android:layout_height="30dp"
                android:gravity="center_vertical"
                android:text="Temperature: "
                ></TextView>
            <TextView
                android:layout_marginTop="60dp"
                android:layout_marginLeft="10dp"
                android:layout_width="100dp"
                android:layout_height="30dp"
                android:text="Pressure: "
                android:gravity="center_vertical"
                ></TextView>
            <TextView
                android:layout_marginTop="90dp"
                android:layout_marginLeft="10dp"
                android:layout_width="100dp"
                android:layout_height="30dp"
                android:text="Pulse: "
                android:gravity="center_vertical"
                ></TextView>

            <TextView
                android:id="@+id/p9Temperature"
                android:layout_marginTop="30dp"
                android:layout_marginLeft="100dp"
                android:layout_width="100dp"
                android:layout_height="30dp"
                android:text="N/N: "
                android:gravity="center"
                ></TextView>

            <TextView
                android:id="@+id/p9Pressure"
                android:layout_marginTop="60dp"
                android:layout_marginLeft="100dp"
                android:layout_width="100dp"
                android:layout_height="30dp"
                android:text="N/N: "
                android:gravity="center"
                ></TextView>

            <TextView
                android:id="@+id/p9Pulse"
                android:layout_marginTop="90dp"
                android:layout_marginLeft="100dp"
                android:layout_width="100dp"
                android:layout_height="30dp"
                android:text="N/N: "
                android:gravity="center"
                ></TextView>

        </RelativeLayout>

        <RelativeLayout
            android:layout_width="200dp"
            android:layout_height="120dp"
            android:layout_marginTop="280dp"
            android:layout_marginLeft="220dp"
            android:background="@color/default_background">
            <TextView
                android:layout_width="match_parent"
                android:layout_height="30dp"
                android:text="Patient 10"
                android:gravity="center"></TextView>
            <TextView
                android:layout_marginTop="30dp"
                android:layout_marginLeft="10dp"
                android:layout_width="100dp"
                android:layout_height="30dp"
                android:gravity="center_vertical"
                android:text="Temperature: "
                ></TextView>
            <TextView
                android:layout_marginTop="60dp"
                android:layout_width="100dp"
                android:layout_marginLeft="10dp"
                android:layout_height="30dp"
                android:text="Pressure: "
                android:gravity="center_vertical"
                ></TextView>
            <TextView
                android:layout_marginTop="90dp"
                android:layout_width="100dp"
                android:layout_marginLeft="10dp"
                android:layout_height="30dp"
                android:text="Pulse: "
                android:gravity="center_vertical"
                ></TextView>

            <TextView
                android:id="@+id/p10Temperature"
                android:layout_marginTop="30dp"
                android:layout_marginLeft="100dp"
                android:layout_width="100dp"
                android:layout_height="30dp"
                android:text="N/N: "
                android:gravity="center"
                ></TextView>

            <TextView
                android:id="@+id/p10Pressure"
                android:layout_marginTop="60dp"
                android:layout_marginLeft="100dp"
                android:layout_width="100dp"
                android:layout_height="30dp"
                android:text="N/N: "
                android:gravity="center"
                ></TextView>

            <TextView
                android:id="@+id/p10Pulse"
                android:layout_marginTop="90dp"
                android:layout_marginLeft="100dp"
                android:layout_width="100dp"
                android:layout_height="30dp"
                android:text="N/N: "
                android:gravity="center"
                ></TextView>

        </RelativeLayout>

        <RelativeLayout
            android:layout_marginLeft="440dp"
            android:layout_marginTop="280dp"
            android:layout_width="200dp"
            android:layout_height="120dp"
            android:background="@color/default_background">
            <TextView
                android:layout_width="match_parent"
                android:layout_height="30dp"
                android:text="Patient 11"
                android:gravity="center"></TextView>
            <TextView
                android:layout_marginTop="30dp"
                android:layout_marginLeft="10dp"
                android:layout_width="100dp"
                android:layout_height="30dp"
                android:gravity="center_vertical"
                android:text="Temperature: "
                ></TextView>
            <TextView
                android:layout_marginTop="60dp"
                android:layout_marginLeft="10dp"
                android:layout_width="100dp"
                android:layout_height="30dp"
                android:text="Pressure: "
                android:gravity="center_vertical"
                ></TextView>
            <TextView
                android:layout_marginTop="90dp"
                android:layout_marginLeft="10dp"
                android:layout_width="100dp"
                android:layout_height="30dp"
                android:text="Pulse: "
                android:gravity="center_vertical"
                ></TextView>

            <TextView
                android:id="@+id/p11Temperature"
                android:layout_marginTop="30dp"
                android:layout_marginLeft="100dp"
                android:layout_width="100dp"
                android:layout_height="30dp"
                android:text="N/N: "
                android:gravity="center"
                ></TextView>

            <TextView
                android:id="@+id/p11Pressure"
                android:layout_marginTop="60dp"
                android:layout_marginLeft="100dp"
                android:layout_width="100dp"
                android:layout_height="30dp"
                android:text="N/N: "
                android:gravity="center"
                ></TextView>

            <TextView
                android:id="@+id/p11Pulse"
                android:layout_marginTop="90dp"
                android:layout_marginLeft="100dp"
                android:layout_width="100dp"
                android:layout_height="30dp"
                android:text="N/N: "
                android:gravity="center"
                ></TextView>

        </RelativeLayout>

        <RelativeLayout
            android:layout_width="200dp"
            android:layout_marginTop="280dp"
            android:layout_height="120dp"
            android:layout_marginLeft="660dp"
            android:background="@color/default_background">
            <TextView
                android:layout_width="match_parent"
                android:layout_height="30dp"
                android:text="Patient 12"
                android:gravity="center"></TextView>
            <TextView
                android:layout_marginTop="30dp"
                android:layout_marginLeft="10dp"
                android:layout_width="100dp"
                android:layout_height="30dp"
                android:gravity="center_vertical"
                android:text="Temperature: "
                ></TextView>
            <TextView
                android:layout_marginTop="60dp"
                android:layout_width="100dp"
                android:layout_marginLeft="10dp"
                android:layout_height="30dp"
                android:text="Pressure: "
                android:gravity="center_vertical"
                ></TextView>
            <TextView
                android:layout_marginTop="90dp"
                android:layout_width="100dp"
                android:layout_marginLeft="10dp"
                android:layout_height="30dp"
                android:text="Pulse: "
                android:gravity="center_vertical" ></TextView>

            <TextView
                android:id="@+id/p12Temperature"
                android:layout_marginTop="30dp"
                android:layout_marginLeft="100dp"
                android:layout_width="100dp"
                android:layout_height="30dp"
                android:text="N/N: "
                android:gravity="center" ></TextView>

            <TextView
                android:id="@+id/p12Pressure"
                android:layout_marginTop="60dp"
                android:layout_marginLeft="100dp"
                android:layout_width="100dp"
                android:layout_height="30dp"
                android:text="N/N: "
                android:gravity="center" ></TextView>

            <TextView
                android:id="@+id/p12Pulse"
                android:layout_marginTop="90dp"
                android:layout_marginLeft="100dp"
                android:layout_width="100dp"
                android:layout_height="30dp"
                android:text="N/N: "
                android:gravity="center" ></TextView>

        </RelativeLayout>



    </RelativeLayout>


</RelativeLayout>

MainActivity.java

Java
package com.example.doctorsdashboard;

import android.app.Activity;
import android.graphics.Color;
import android.os.Bundle;
import android.widget.RelativeLayout;
import android.widget.TextView;

import androidx.annotation.NonNull;

import com.google.firebase.database.DataSnapshot;
import com.google.firebase.database.DatabaseError;
import com.google.firebase.database.DatabaseReference;
import com.google.firebase.database.FirebaseDatabase;
import com.google.firebase.database.ValueEventListener;

/*
 * Main Activity class that loads {@link MainFragment}.
 */
public class MainActivity extends Activity {

    DatabaseReference dref;
    RelativeLayout RL1, RL2, RL3, RL4;
    TextView P1textT, P1textH, P1textP, P2textT, P2textH, P2textP, P3textT, P3textH, P3textP, P4textT, P4textH, P4textP;
    TextView P5textT, P5textH, P5textP, P6textT, P6textH, P6textP, P7textT, P7textH, P7textP, P8textT, P8textH, P8textP;
    TextView P9textT, P9textH, P9textP, P10textT, P10textH, P10textP, P11textT, P11textH, P11textP, P12textT, P12textH, P12textP;
    String P1stringT, P1stringH, P1stringP, P2stringT, P2stringH, P2stringP, P3stringT, P3stringH, P3stringP, P4stringT, P4stringH, P4stringP;
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        RL1 = (RelativeLayout) findViewById(R.id.RLayout1);
        RL2 = (RelativeLayout) findViewById(R.id.RLayout2);
        RL3 = (RelativeLayout) findViewById(R.id.RLayout3);
        RL4 = (RelativeLayout) findViewById(R.id.RLayout4);
        P1textT = (TextView) findViewById(R.id.p1Temperature);
        P1textH = (TextView) findViewById(R.id.p1Pressure);
        P1textP = (TextView) findViewById(R.id.p1Pulse);
        P2textT = (TextView) findViewById(R.id.p2Temperature);
        P2textH = (TextView) findViewById(R.id.p2Pressure);
        P2textP = (TextView) findViewById(R.id.p2Pulse);
        P3textT = (TextView) findViewById(R.id.p3Temperature);
        P3textH = (TextView) findViewById(R.id.p3Pressure);
        P3textP = (TextView) findViewById(R.id.p3Pulse);
        P4textT = (TextView) findViewById(R.id.p4Temperature);
        P4textH = (TextView) findViewById(R.id.p4Pressure);
        P4textP = (TextView) findViewById(R.id.p4Pulse);


        dref = FirebaseDatabase.getInstance().getReference();
        dref.addValueEventListener(new ValueEventListener() {
            @Override
            public void onDataChange(@NonNull DataSnapshot dataSnapshot) {
                P1stringT = dataSnapshot.child("P1_temperature").getValue().toString();
                P1textT.setText(P1stringT + "C");
                float temp1Data = Float.parseFloat(P1stringT);

                if (temp1Data < 37) {
                    RL1.setBackgroundColor(Color.parseColor("#003cb3"));
                }
                else {
                    RL1.setBackgroundColor(Color.parseColor("#ff5c33"));
                }



                P1stringH = dataSnapshot.child("P1_pressure").getValue().toString();
                P1textH.setText(P1stringH);
                P1stringP = dataSnapshot.child("P1_pulse").getValue().toString();
                P1textP.setText(P1stringP);

                P2stringT = dataSnapshot.child("P2_temperature").getValue().toString();
                P2textT.setText(P2stringT + "C");


                float temp2Data = Float.parseFloat(P2stringT);

                if (temp2Data < 37) {
                    RL2.setBackgroundColor(Color.parseColor("#003cb3"));
                }
                else {
                    RL2.setBackgroundColor(Color.parseColor("#ff5c33"));
                }



                P2stringH = dataSnapshot.child("P2_pressure").getValue().toString();
                P2textH.setText(P2stringH);
                P2stringP = dataSnapshot.child("P2_pulse").getValue().toString();
                P2textP.setText(P2stringP);



                P3stringT = dataSnapshot.child("P3_temperature").getValue().toString();
                P3textT.setText(P3stringT + "C");


                float temp3Data = Float.parseFloat(P3stringT);

                if (temp3Data < 37) {
                    RL3.setBackgroundColor(Color.parseColor("#003cb3"));
                }
                else {
                    RL3.setBackgroundColor(Color.parseColor("#ff5c33"));
                }



                P3stringH = dataSnapshot.child("P3_pressure").getValue().toString();
                P3textH.setText(P2stringH);
                P3stringP = dataSnapshot.child("P3_pulse").getValue().toString();
                P3textP.setText(P3stringP);



                P4stringT = dataSnapshot.child("P4_temperature").getValue().toString();
                P4textT.setText(P4stringT + "C");


                float temp4Data = Float.parseFloat(P4stringT);

                if (temp4Data < 37) {
                    RL4.setBackgroundColor(Color.parseColor("#003cb3"));
                }
                else {
                    RL4.setBackgroundColor(Color.parseColor("#ff5c33"));
                }



                P4stringH = dataSnapshot.child("P4_pressure").getValue().toString();
                P4textH.setText(P4stringH + "%");
                P4stringP = dataSnapshot.child("P4_pulse").getValue().toString();
                P4textP.setText(P4stringP);


            }

            @Override
            public void onCancelled(@NonNull DatabaseError databaseError) {

            }
        });
    }
}

tbsense_scan.py

Python
from bluepy.btle import *
import struct
from time import sleep
from tbsense import Thunderboard
from thundercloud import Thundercloud
import threading

def getThunderboards():
	scanner = Scanner(0)
	devices = scanner.scan(3)
	tbsense = dict()
	for dev in devices:
		scanData = dev.getScanData()
		for (adtype, desc, value) in scanData:
			if desc == 'Complete Local Name':
				if 'Thunder Sense #' in value:
					deviceId = int(value.split('#')[-1])
					tbsense[deviceId] = Thunderboard(dev)
	return tbsense

def sensorLoop(fb, tb, devId):

	session = fb.getSession(devId)
	tb.session = session

	value = tb.char['power_source_type'].read()
	if ord(value) == 0x04:
		tb.coinCell = True

	while True:
		text = ''
		text += '\n' + tb.name + '\n'
		data = dict()

		try:
			for key in tb.char.keys():
				if key == 'temperature':
					data['P1_temperature'] = tb.readTemperature()
					text += 'Temperature:\t{} C\n'.format(data['temperature'])
				elif key == 'humidity':
					data['P1_humidity'] = tb.readHumidity()
					text += 'Humidity:\t{} %RH\n'.format(data['humidity'])
				elif key == 'P1_pressure':
					data['pressure'] = tb.readPressure()
					text += 'Pressure:\t{}\n'.format(data['pressure'])

		except:
			return

		print(text)
		fb.putEnvironmentData(session, data)
		sleep(1)

def dataLoop(fb, thunderboards):
	threads = []
	for devId, tb in thunderboards.items():
		t = threading.Thread(target=sensorLoop, args=(fb, tb, devId))
		threads.append(t)
		print('Starting thread {} for {}'.format(t, devId))
		t.start()

if __name__ == '__main__':

	fb = Thundercloud()

	while True:
		thunderboards = getThunderboards()
		if len(thunderboards) == 0:
			print("No Thunderboard Sense devices found!")
		else:
			dataLoop(fb, thunderboards)

thundercloud.py

Python
from firebase import firebase
import uuid
import time

class Thundercloud:
	def __init__(self):
		self.addr     = 'firebase_database_link'
		self.firebase = firebase.FirebaseApplication(self.addr, None)

	def getSession(self, deviceId):
		timestamp = int(time.time() * 1000)
		guid = str(uuid.uuid1())


		d = {
      "P1_temperature": 0,
      "P1_pressure": 0,
      "P1_pulse": 0,
			}
		self.firebase.put("Patients", "P1", d)
		return guid

	def putEnvironmentData(self, guid, data):

		self.firebase.put("Patients", "P1", data)


if __name__ == '__main__':
	fb = Thundercloud()
	guid = fb.getSession(37372)

	data = {
      "P1_temperature": 0,
      "P1_pressure": 0,
      "P1_pulse": 0,
	}

	for i in range(3):
		fb.putEnvironmentData(guid, data)
		time.sleep(1)

tbsense.py

Python
from bluepy.btle import *
import struct
from time import sleep

class Thunderboard:

	def __init__(self, dev):
		self.dev  = dev
		self.char = dict()
		self.name = ''
		self.session = ''
		self.coinCell = False

		scanData = dev.getScanData()

		for (adtype, desc, value) in scanData:
			if (desc == 'Complete Local Name'):
				self.name = value

		ble_service = Peripheral()
		ble_service.connect(dev.addr, dev.addrType)
		characteristics = ble_service.getCharacteristics()

		for k in characteristics:
			if k.uuid == '2a6e':
				self.char['temperature'] = k
			elif k.uuid == '2a6f':
				self.char['humidity'] = k
			elif k.uuid == '2a6d':
				self.char['pressure'] = k

	def readTemperature(self):
		value = self.char['temperature'].read()
		value = struct.unpack('<T', value)
		value = value[0] / 100
		return value

	def readHumidity(self):
		value = self.char['humidity'].read()
		value = struct.unpack('<H', value)
		value = value[0] / 100
		return value

	def readPressure(self):
		value = self.char['pressure'].read()
		value = struct.unpack('<L', value)
		value = value[0] / 1000
		return value

Credits

Elmin Delibašić

Elmin Delibašić

12 projects • 81 followers
Bachelor of Electrical Engineering || Enthusiast for AI and IoT || Master Student at Faculty of Electrical Engineering

Comments