IoT based remote health monitoring system using Arduino IoT Cloud

IoT based remote health monitoring system using Arduino IoT Cloud IoT based remote health monitoring system using Arduino IoT Cloud

Overview or Abstract:

In this Health monitoring Project, we are going to create an Remote health monitoring system based on IoT using Microcontrollers with built in WiFi such as ESP8266 NodeMCU or ESP32 by connecting few latest sensors which can measure few health parameters and send the data to Arduino IoT cloud where we can monitor the data remotely from any place.

As we already discussed in our previous project of IoT based Health monitoring system over webserver. We know important it is to monitor the health of a patient or a normal person regularly. but in that project the data is limited to the same local network. For example: You have old parents at home, who needs you to take care of their health but you have work to do, which makes your time difficult. So taking this scenario into account we came up with an idea to build a remote health monitoring system which can transmit the health data to the cloud servers, which you can access from anywhere and act fast on issues.

Sensors used and their working:

First lets discuss which sensors we are using in this IoT project and how they are useful in this project:

GY-MAX30100 Pulse Oximeter and Heart rate sensor

Here we are using the latest GY-MAX30100 Heart rate and Pulse Oximetry sensor instead of old MAX30100 as it has design issues. This sensor is compact and measures Blood oxygen percentage along with the heart rate which is number of times the heart beats in one minute.

GY-MAX30100 MODULE

This sensor has IR and Red LEDs which emits on the finger and measures the SpO2 and Heart rate according to the absorption principle of blood oxygen which we explained in detail here: How pulse oximeters works? 

To learn more about this sensor in detail check our detailed article on Interfacing MAX30100 sensor with Arduino

MAX30100 operates between 3.3v to 5v DC voltage. In this Project we tried to interface with new MAX30102 and MAX30105 sensors but their libraries are conflicting with ArduinoIoTCloud libraries which caused huge bunch of errors, which we try to solve and update in upcoming posts.

DS18B20 waterproof temperature sensor

To measure the body temperature of patient or a person we are using DS18B20 waterproof temperature sensor as it senses the temperature with great precision of ±0.5°C. It has features like OneWire technology where we can connect multiple DS18B20 sensors which has unique 64 bit serial code to single data GPIO pin and measure temperature values individually. In our Project we can measure temperature of Head, neck and mouth. As we use Fahrenheit for medical parameters we can convert centigrade to Fahrenheit using software code.

DS18B20 temperature sensor pinout diagram

DS18B20 works more stable than LM35 and operates in the range of 3v-5.5V dc voltage and consumes very less power nearly 1mA.

To learn more about this sensor in detail check our detailed article on: DS18B20 Temperature sensor with Arduino,ESP8266 and ESP32.

BME280 Temperature and humidity sensor

To measure temperature and humidity of the room we are using BME280 temperature and humidity sensor which is build with BOSCH piezo-resistive technology and has salient features like low energy consumption, ultra compact design, measurements with great precision and stability in output signal.

Here we are using BME280 instead of BMP 280 because BME 280 has humidity sensing as BMP doesn’t. This sensor measures temperatures between -40 to 85°C with an accuracy of 1°C. It also measures relative humidity with an accuracy of ±3%.

BME 280 sensor operates between voltages ranging from 1.8v to 3.3v and communicates through microcontrollers through I2C interface.

To learn more about this sensor in detail check the: BME280 Official datasheet

Required components (Bill of Materials):

Product NameQuantityamazon logoamazon logo india
ESP8266 NodeMCU ( for ESP8266 version)1https://amzn.to/3tqMwkBhttps://amzn.to/3sVdSjG
ESP 32 WiFi and Bluetooth Board (For ESP32 Version)1https://amzn.to/3s0Sut6https://amzn.to/3Kw2np2
GY-MAX30100 Heart rate and pulse oximetry sensor1https://amzn.to/35pylEshttps://amzn.to/3tPUYu6
DS18B20 Waterproof temperature sensor1https://amzn.to/3C7lmmRhttps://amzn.to/3pUglJl
BME280 temperature and humidity sensor1https://amzn.to/3Mka2s7https://amzn.to/37hlqFg
Few Connecting Wireshttps://amzn.to/3H2BV4ehttps://amzn.to/3J0WVu2
You can buy the required components from the given best buy links. We choose the components according to value for money.

Circuit diagram of IoT based remote health monitoring system interfacing sensors.

Connect all the required components according the below schematic diagrams. Here we are providing 2 versions one for ESP8266 NodeMCU and another for ESP32. Choose according to your microcontroller and connect them.

ESP8266 (NodeMCU) version:

According to the above circuit diagram all the connections between ESP8266 and Sensors are explained below.

IoT based remote health monitoring system interfacing sensors with esp8266 circuit diagram

Interfacing GY-MAX30100 and ESP8266 NodeMCU

  • VIN –> Vin (5v)
  • SDA –> D2
  • SCL –> D1
  • GND –> GND

Interfacing DS18B20 and ESP8266 NodeMCU

  • RED wire  –> Vin (5v)
  • Black Wire –> GND
  • Yellow Wire –> D5 (GPIO 14)

Interfacing BME280 and ESP8266 NodeMCU

  • VIN –> Vin (3.3v)
  • GND –> GND
  • SCL –> D1
  • SDA –> D2

ESP32 Version:

IoT based remote health monitoring system interfacing sensors with esp32 circuitdiagram

 

According to the above circuit diagram all the connections between ESP8266 and Sensors are explained below.

Interfacing GY-MAX30100 with ESP32

  • VIN –> Vin (5v)
  • SDA –> D21
  • SCL –> D22
  • GND –> GND

Interfacing DS18B20 with ESP32

  • RED wire  –> Vin (5v)
  • Black Wire –> GND
  • Yellow Wire –> D5 (GPIO 5)

Interfacing BME280  with ESP32

  • VIN –> Vin (3.3v)
  • GND –> GND
  • SCL –> D22
  • SDA –> D21

After connecting all the components according to the above diagrams and lists now its time to create and account on Arduino IoT Cloud and follow the below steps to create variables and access tokens and keys

Getting started with Arduino IoT Cloud:

Account setup:

Step1: Open Arduino IoT cloud using following Link : https://create.arduino.cc/iot

Step2: Signup for a new account or login if you already have an account by providing credentials.

Step3: Click on Create thing, to get a setup page to configure project name, board, variables, and network according to the below image.

setting up arduino iot cloud empty Device setup:

Click on select device button, and choose setup a 3rd party device as we are not using Arduino board. Now from the radio buttons choose ESP8266 or ESP32 as per the device you are using. If you are using NodeMCU choose ESP8266 radio button and select NodeMCU 1.0 (ESP-12E Module) from device model dropdown. Next click on continue to name the device and download or copy the Device ID and Secret Key PDF for further reference in the code as shown in the below screenshot.

Arduino IoT cloud web setting up device with secret keyVariables setup:

As per our IoT based remote health monitoring project we need 5 variables for Body temperature, Heart rate, SpO2, Room temperature and Humidity. So click on add variable type the variable name, choose the variable type, keep the variable update policy to on change and click on Add variable. Create 5 variables with below names and types.

  • bodytemperature –> Temperature Sensor (°F) eg. 1 °F
  • Heartrate –> Heart Rate eg. 1 bpm
  • bloodoxygen –> Percentage eg. 1 %
  • roomtemperature –> Temperature Sensor (°C) eg. 1 °C
  • humidity –> Relative Humidity eg. 1 %

arduino IoT cloud setup variables device network

After creating these 5 variables next configure the WiFi network.

Network setup:

Click on Configure in the Network block and enter the WiFi name, WiFi password and the Secret key which we copied while device setup and click on save.

Dashboard setup:

Now from the top menu click on Dashboards and click Build Dashboard to create an IoT health monitor dashboard, You can name it according to the project as we names it “CircuitSchools IoT based remote health monitoring System“.

Now add 5 widgets to display the health data and link them to the previous created variables respectively as shown below. We added 3 value widgets for body temperature, heart rate and room temperature, 1 Gauge widget for Blood SpO2 and a chart to display graph of heartrate history. Like wise you can create widgets according to the need.

iot based health monitoring system arduino cloud dashboardThat’s it for the setup and now we need to write a program code to get the data from our 3 sensors.

Coding Part:

Here with the help of Arduino IoT Cloud we can edit the code compile and even upload the code to our ESP32/ ESP8266 microcontrollers directly without the need of Arduino IDE. There is no need to install libraries as it has 100s of preinstalled libraries. Just click on the sketch tab and type or paste the code. You can use open full editor feature for best coding interface. We can also upload the code through Arduino IDE but we need to install ArduinoIoTCloud library and add the variables and dependencies. We will make an another article on how to save compilation time with free account on Arduino IoT Cloud using Arduino IDE.

Copy and paste the below code in Sketch.

/*********
IOT BASED REMOTE HEALTH MONITORING SYSTEM USING ARDUINO IOT CLOUD PLATFORM
COPYRIGHTS AND CREDITS:CIRCUITSCHOOLS.COM
*********/
#include "arduino_secrets.h"
#include "thingProperties.h"
#include <Wire.h>
#include <OneWire.h>
#include <DallasTemperature.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_BME280.h>
#include "MAX30100_PulseOximeter.h"

Adafruit_BME280 bme; // I2C

#define DS18B20 5   // 14 for esp8266 nodeMCU
OneWire oneWire(DS18B20);
DallasTemperature sensors(&oneWire);

#define REPORTING_PERIOD_MS     1000
PulseOximeter pox;
uint32_t tsLastReport = 0;

void onBeatDetected()
{
    Serial.println("Beat!");
}

void setup() {
  // Initialize serial and wait for port to open:
  Serial.begin(9600);

  // Defined in thingProperties.h
  initProperties();

  // Connect to Arduino IoT Cloud
  ArduinoCloud.begin(ArduinoIoTPreferredConnection);
  setDebugMessageLevel(2);
  ArduinoCloud.printDebugInfo();
  
  sensors.begin();  //initialize DS18B20 sensor
  
  if (!bme.begin(0x76)) {   //if still not found try another address or scan through I2C scanner from our prevoius posts
    Serial.println(F("Could not find a valid BME280 sensor, check wiring!"));
    //while (1);

  // Initialize the PulseOximeter instance
    // Failures are generally due to an improper wiring, missing power supply
    if (!pox.begin()) {
        Serial.println("FAILED");
        for(;;);
    } else {
        Serial.println("SUCCESS");
    }
     pox.setIRLedCurrent(MAX30100_LED_CURR_7_6MA);
 
    // Register a callback for the beat detection
    pox.setOnBeatDetectedCallback(onBeatDetected);
  }
}

void loop() {
  ArduinoCloud.update();
  SENSORS_READ();
}

void SENSORS_READ(){
  sensors.requestTemperatures();

  roomtemperature = bme.readTemperature();
  humidity = bme.readPressure()/100; 
  
  Serial.println(roomtemperature);
  Serial.println(humidity);
  bodytemperature = (sensors.getTempCByIndex(0)*9.0)/5.0+32.0; //Converting into Farenheit
  Serial.println(bodytemperature);
  pox.update();
  
  if (millis() - tsLastReport > REPORTING_PERIOD_MS) {
    heartrate= pox.getHeartRate();
    bloodoxygen= pox.getSpO2();
    Serial.print("Heart rate:");
    Serial.print(pox.getHeartRate());
    Serial.print("bpm / SpO2:");
    Serial.print(pox.getSpO2());
    Serial.println("%");
        
        tsLastReport = millis();
    }
  delay(1000);
}

Now select the board as NodeMCU 1.0(ESP-12E module) or ESP32 Wrover module, If you are unable to select the board it shows a popup to download and install an Arduino Create agent. After downloading you can access the connected board. Then Click on Upload, after successful upload click reset on your ESP board and open serial monitor tab, you can see the connection status and data on it as shown in the below image.

remote health monitoring system using iot cloud data on serial monitor

Now the data is shown through the dashboard also, Open the previously created dashboard to view the data as shown in the below image. You can also download Arduino IoT Cloud Remote on your Android mobile to remotely monitor health data over internet.

iot based health monitoring system arduino cloud dashboard with data

Tips, Notes and Error with solutions

Tips: You can interface other sensors like ECG sensorAir Quality monitoring sensors and other latest sensors with the same ESP32 or ESP8266.

Notes: This sensors are just for prototyping and cannot be replaced with the certified medical devices. You can still use them by comparing the results with standard devices and modify the code.

For GY-MAX30100 Attach finger with sensor using rubber band as humans cannot apply constant pressure on it.

6 comments
  1. I have 2 errors about “arduino_secrets.h” and “thingProperties.h”: No such file or directory. How can I fix it?

  2. Guys please help me out I have no time now My esp32 is of module esp-wroom-32 module which do I need to select while selecting the third part devices

Leave a Reply

Your email address will not be published. Required fields are marked *