Project showcase
Controlling Patient's Fever with Artik & Arduino

Controlling Patient's Fever with Artik & Arduino © GPL3+

This project consists of 2 devices. the first one is wearable and monitors temperature, second one will control the temperature.

  • 6,054 views
  • 4 comments
  • 13 respects

Components and supplies

Apps and online services

About this project

Introduction

This project consists of 2 devices, the first one is wearable mkr1000 with battery and temperature and humidity sensor, the mkr1000 send temperature and humidity to Artik cloud. Now doctors can observe patient's fever and sweating of patient, and if temperature goes too high or low. Artik will send email to doctor and send action to second device! Second device is a mkr1000 that control cooler with relay!

how it works

Adding libraries to Arduino

Open Arduino ide go to sketch>>include library>>manage libraries.

Now search and install MQTTClient.h, ArduinoJson.h, WiFi101.h, dht.h.

Making cloud ready!

Go to https://developer.artik.cloud/dashboard/devicetypes and click on +new device type.

now go to https://artik.cloud/my/devices

go to https://developer.artik.cloud/dashboard/devicetypes again and create new device.

now go back to https://artik.cloud/my/devices

Wearable device

The wearable device is the simple part! you just connect your DHT module to mkr1000 and power it with battery or power bank. Connect the +&- of DHT to 5V & GND and connect out pin to the A0 of mkr1000.

Cooler controller

Open the cooler controller code and replace wifi name and password, device id and device token. upload it to mkr1000.

I use a voltage protector to connect relay to cooler because it is more safe!

Relay work's with 5V, but mkr1000's digital write is 3.3V. so we need logic level converter.

At first we connect 5V to HV and GND to GND. Then we connect 6 pin of mkr1000 to LV (because we have digital write, high to 6 pin and it's voltage is 3.3 like our signal voltage).vNow we send signals through one of logic level converter's channels.

RGB led show's the status. Green means that cooler is on and red means off!

Now every thing is OK! You can sit and enjoy your fever while Artik is controlling your body temperature.

Code

fever monitorC/C++
this code send data to Artik cloud from wearable device.
/*
PATIENT'S FEVER & SWEATING MONITORING!
you nead mkr1000 & DHT module(temperature and humidity sensor)!
Attach the OUT pin of a DHT to pin A0, the + pins to +5V, and - to ground fo mkr1000!
this code measure temperature and humidity on the skin of paitent and send them to artik cloud!
 */
 
//libraries 
#include <MQTTClient.h>     //  MQTT messaging protocol library!
#include <ArduinoJson.h>    // sending data with Json format library!
#include <WiFi101.h>        // conecting mkr1000 to internet library!
#include <dht.h>            // temperature and humidity sensor library!

//wifi parameters
char WIFI[]     = "^your ssid^";            // your wifi name
char PASSWORD[] = "^your password^";    // your wifi password

//cloud parameters
char CloudServer[]     = "api.artik.cloud";                                             // artik cloud server
int  MQTTPort          = 8883;                                                          // MQTT protocol port
char Did[]             = "^your device id^";                                            // your device id
char Dtoken[]          = "^your device token^";                                         // your device token
char CloudDataOut[]    = "/v1.1/messages/^your device id^";              
char ClientName[]      = "ARTIK-Arduino";                                               // your client's name

char buf[128];   // data storage in buf before going to cloud!

//building objects
WiFiSSLClient ipCloudStack;
MQTTClient mqttCloudClient;
dht DHT;


void setup() 
{

  Serial.begin(9600);  
  WiFi.begin(WIFI, PASSWORD);                                              //starting wifi
  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print("attempting connect to : ");
    Serial.println(WIFI);
  }
  Serial.println();
  Serial.println("WiFi connected");
  
  mqttCloudClient.begin(CloudServer, MQTTPort, ipCloudStack);             // connecting to artik cloud

  Serial.println("start ARTIK Cloud connect"); Serial.println();
  
  while (!mqttCloudClient.connect(ClientName, Did, Dtoken)) {             //connecting to device
    Serial.print("*");
    delay(500);    
  }

}


void loop() 
{

  Serial.println("sending data to cloud");
  sendToArtikCloud();                                     // sending data to cloud
  delay(60*1000);                                         // wait 60s!

}



void sendToArtikCloud() 
{
  
  loadBuffer();                                    // making data ready in Json format
  mqttCloudClient.publish(CloudDataOut, buf);      // sending data to cloud

}


void loadBuffer()                                        // this function make data redy for sending in Json format!
{

  StaticJsonBuffer<200> jsonBuffer;
  JsonObject& dataPair = jsonBuffer.createObject();
  DHT.read11(A0);                                       // reading temperature & humidity
  dataPair["temp"] = DHT.temperature;                   // adding temperature value to Json
  dataPair["humidity"] = DHT.humidity;                  // adding humidity value to Json
  dataPair.printTo(buf, sizeof(buf));
  
}

void messageReceived(String topic, String payload, char * bytes, unsigned int length)
{
  
  }
cooler controllerC/C++
this code receive actions from Artik cloud. and control the cooler with them
/*
 controling cooler with artik actions!
 connect relay to digital 9 pin!
 */
//libraries 
#include <MQTTClient.h>     //  MQTT messaging protocol library!
#include <ArduinoJson.h>    // sending data with Json format library!
#include <WiFi101.h>        // conecting mkr1000 to internet library!

//wifi parameters
char WIFI[]     = "^your ssid^";            // your wifi name
char PASSWORD[] = "^your password^";    // your wifi password



//cloud parameters
char CloudServer[]     = "api.artik.cloud";                             // artik cloud server
int  MQTTPort          = 8883;                                          // MQTT protocol port
char Did[]             = "^your device id^";                            // your device id
char Dtoken[]          = "^your device token^";                         // your device token
char CloudDataOut[]    = "/v1.1/messages/^your device id^";              
char ClientName[]      = "ARTIK-Arduino";
char CloudActionsIn[] = "/v1.1/actions/^your device id^";               // (/v1.1/actions/"DEVICE ID") 


char buf[200]; // Json Data to Artik Cloud  

//building ubjects
WiFiSSLClient ipCloudStack; 
MQTTClient mqttCloudClient; // MQTT Protocol


int relayPIN=9;
int redled=7;
int greenled=8;

 
 
void setup() 
{
  pinMode(relayPIN,OUTPUT);
  pinMode(redled,OUTPUT);
  pinMode(greenled,OUTPUT);
  //providing low 3.3V for logic level converter
  pinMode(6,OUTPUT);
  digitalWrite(6,HIGH);
  Serial.begin(9600);  
  WiFi.begin(WIFI, PASSWORD);                                 //connecting to wifi
  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print("attempting connect to : ");
    Serial.println(WIFI);
  }
  Serial.println();
  Serial.println("WiFi connected");
  
  mqttCloudClient.begin(CloudServer, MQTTPort, ipCloudStack); // Connecting to Artik cloud 
  while (!mqttCloudClient.connect(ClientName, Did, Dtoken))   // connecting to device
  { 
    Serial.print("not connected to device"); 
    delay(1000); 
  } 
mqttCloudClient.subscribe(CloudActionsIn); 

}



void loop()
{ 

  //waiting for actions
  Serial.println("listening...");
  mqttCloudClient.loop();
  delay(10000);
}


void messageReceived(String topic, String payload, char * bytes, unsigned int length) { 
  Serial.print("data from artik cloud:"); 
  Serial.println(payload);  
  parseBuffer(payload); 
 
}


void parseBuffer(String _payload)     //translating data from Json format
{
   
StaticJsonBuffer<200> jsonBuffer; 
String json = _payload; 
JsonObject& root = jsonBuffer.parseObject(json);
boolean ACS = root["actions"][0]["parameters"]["sw"];   //ACS = order from Artik

if (ACS)                         //turning on
{
  digitalWrite(relayPIN,LOW);
  digitalWrite(greenled,HIGH);
  digitalWrite(redled,LOW);  
}
else                            //turning off
{
  digitalWrite(relayPIN,HIGH);
  digitalWrite(greenled,LOW);
  digitalWrite(redled,HIGH); 
}

}  

Schematics

cooler controller
Arduino%20MKR1000.fzpz

Comments

Similar projects you might like

HBus Home Automation And Artik

Project tutorial by Vincenzo

  • 2,310 views
  • 0 comments
  • 6 respects

Temperature Logger With Arduino And Artik Cloud

Project tutorial by RAFI RASHEED T C

  • 2,109 views
  • 1 comment
  • 7 respects

ARTIK + MKR1000 + DHT11 + MQTT

Project tutorial by vincent wong

  • 3,704 views
  • 12 comments
  • 10 respects

Water Quality Monitoring Using MKR1000 and ARTIK Cloud

Project tutorial by Team Animo!

  • 7,075 views
  • 12 comments
  • 30 respects

Monitor Fire and Temperature Using ARTIK Cloud

Project tutorial by Samsung IoT

  • 2,933 views
  • 0 comments
  • 21 respects
Add projectSign up / Login