Wireless patient health monitoring system
In a hospital ward, traditionally for monitoring the health of patients who are admitted, nurses will go to each patient and collect their body temperature periodically. This method however seems simple, becomes tedious when the number of patients to be monitored increases. In that case, more nurses would be needed to treat all the patients. Now think of a big hospital where the wards for patients will also be more, if nurses were to meet each patient, then there are chances that same patient being treated by two nurses and some patients left out of the routine.. big problem right? also it takes more time and effort to do such things. Having all these problems, we can’t even think about collecting multiple data from patients at regular intervals and doing analysis on each and every patient
My project is about solving this problem in the cheapest possible way. According to my project, wireless health monitoring bands will be provided to all patients in the hospital. Each band will have an unique id. There will be a master hub constantly transmitting device ids and collects the data. When a band receives an id, it will check if the received id matches its uid. If the id doesn’t matches, then the band won’t do anything but waits for its id. If it matches, then it means the central hub requested this band to send its data. so the band will measure the patient’s body temperature and hear rate using sensors and transmits the data back to the hub. Once the hub receives the data, it will save the data in a text file allotted to this id in the server PC. So whenever the doctor needs to see the data of particular patient, he can run a software that will plot the values with respect to time. So the doctor can conclude about the health of the patient just by seeing the graph without physically meeting the patient. He/she could see the trends in the patient’s health and can conclude whether the patient’s health is improving or degrading.
Now a new problem arises. Since all the bands are running with battery, the bands need to be charged once in a while. So for charging, the patients should be given a charger,along with a cable with connector. Now think how they’ll charge it. They have to find a socket to connect their charger. Since hospitals are not built with aim of providing enough sockets for each patient, the charging process would be difficult. Just imagine how the hospital would be if a heart patient sits below a wall socket just to charge his band.. it won’t be good. Also the old people with poor eyesight will suffer a lot while trying to connect the charging cable to the charger as the connectors would be small and complicated.
Hopefully we have a solution for that. Now imagine we have a basket which have a wireless power transmitter attached and each band will have a wireless power receiver. Now the charging procedure would be simple. The patient just need to remove the band from their hand and place it into the basket for sometime. In this time the band will get charged. Many bands can be placed inside a single basket. You don’t need to care about connecting charging cables or carrying charging adapters with you all the time or searching for a wall socket. Just find a basket and keep your band on that for a while.. Yeah it is that simple. Also with absence of connectors, the band can be made robust and rugged and waterproof. Welcome to my project.
By incorporating the wireless power kit with the medical band, it is possible to charge many bands simultaneously without the need for multiple adapters. The main innovation lies with the charging basket, which contains many wireless power transmitter modules and that basket will be powered with a single 230V port.
This project has 4 modules
1) Communication module
2) Sensor module
3) Power module
4) Data visualization
Communication module:
I used 433MHz RF ASK module for communication. The reason to choose RF over wifi is mainly to reduce the cost and complexity of the implementation. Also the power consumption of wifi module is more when compared to RF module.
But unlike wifi module, RF module has no specific communication protocol. So by getting inspired from I2C communication and NEC protocol, I designed a new protocol for data transfer.
The data is sent with one line and received through another line. The output pin is switched ON for a specific time and switched OFF to create pulses. These pulses are detected using port interrupts and timers. By measuring the time difference between two falling edges, the pulse width can be found. Here the data is sent by modulating the width of pulse. Based on the time difference between two falling edges, the type of bit is identified. The data is collection starts with a start bit and the collection ends when a stop bit is received. Totally 9 bits are transferred along with parity bit. The data is sent as
| 1 start bit | 8 data bits | 1 parity bit | 1 stop bit |
This constitutes one byte of data. Like this each data that we feed to the algorithm, is sent by switching of I/O pin at predefined intervals of time. This I/O pin is connected to the data pin of RF transmitter and the receiving pin is connected to the port interrupt pin of micro controller to detect the falling edges.
The problem that I faced with RF module is that, valid data is received only when one transmitter is in switched ON condition at a time. So I made changes to the algorithm such that when master is transmitting, slave will not disturb and when slave transmits, the master will not disturb the waveguide.
Sensor module:
We are using amped pulse sensor to measure the heart rate and LM35 to measure the body temperature.
The pulse sensor works on the principle of photoplythysmography, a technique that measures the pulse rate by measuring the fluctuations in the reflected light which was transmitted separately. Due to the blood flow in fingers, the volume of blood present in the finger oscillates with heart beat so when a light is continuously flashed over the finger, the intensity of the reflected light varies in accordance with the heart beat. So by measuring the intensity and processing it, we can get the heart beat.
The problem with the pulse sensor is that the data output has a lot of noise..
So I made a band pass filter with capacitors 0.1uF( for low pass) and 1uF(for high pass) and the result was beautiful.
The band pass filter along with the pulse sensor is shown below.
Now in the program, I set the threshold value such that only valid pulses will be taken into consideration to avoid errors. Then I used various filtering techniques(in software) to get most accurate value out of the sensor at the cost of processing time.
The temperature is simply proportional to the analog output of LM35 sensor. So just by measuring the analog value and multiplying with a constant yields the patient’s body temperature.
Power module:
In this project, the Central hub microcontroller is connected to a PC so it doesn’t need any external power source. The slave devices are connected with a LiPo battery along with the wireless power kit. The power transmitter is fixed at the bottom of the basket So that the band can be charged just by placing it into the basket.
Data visualization:
The data transmitted from master to PC is in the following format
| 0xD | device_id | temperature | heart_rate | 0x1 |
The character 0xD is the new line character which will be the delimiter for new data in python. The python program reads a line, splits it into device id, temperature and heart rate. Then it creates a file for each id and saves the data in the text file along with the time of reception. The plotting program will read each line of the text and plot the temperature and heart_rate.
Working:
This project can have one master( central hub ) and many slave devices( health band ) but in this demonstration, I used only two slaves. Initially the master will send out an address byte, the health band corresponding to the transmitted id will respond by transmitting back the device id, heart beat data and body temperature. This data will be collected by the central master micro controller and sent to PC via UART. Then the master iterates the address byte and transmits the next address and the corresponding band will respond back with its data and it goes on like this. So if in a ward, 30 patients are there, then the master will iterate over each address and collects its data and stores it in a text file. The data sent to the PC is constantly saved by a python program in separate text files for each patient. This data can be plotted at any time using the plot program that I wrote in python, to see the trend of patient’s heart beat or temperature.
Data from patient 1 is shown below, where you can see that the heart rate values are approximately 70 and the body temperature is approximately 35
Data from patient 2 is
Please look into this video for a better understanding of my project.
With proper fabrication technology, the size of this project can be reduced and made into small rugged wearables so that patient can wear it comfortably and that could make this system practically implementable.
Thank you for spending your time to know about my project..
Components needed:
MSP430G2553 micro controllers – 3
433 MHz RF ASK modules – 3 transmitter and 3 receiver
amped pulse sensor – 1
LM35 temperature sensor – 1
Jumpers and bread boards
Software needed:
Python 2.7 environment to run the python program.
Code composer studio to burn the code in MSP430 micro controller
Use notepad++ with C language setting for better readability
Here four programs are pasted together. First and second programs are for micro controllers and is in embedded C, third and fourth are python programs.
///////////////////////////////// 1.code for MASTER ///////////////////////////////////////
/*
Pin connections
P1.0 Tx data
P1.3 temperature sensor
P1.4 Rx data
P1.5 heart beat sensor
P1.6 Tx vcc
alloted device id for slave devices – 200 to 255
*/
#include “msp430g2553.h”
char patient_id = 0; //to iterate patient ids
char heart_rate,temperature;
int time; //16 bit value to hold the Timer A0 Register value
int val; //temporary variable for holding recieved values
//variables for receiving algorithm
char current,new,digitcollected,data;
int t1 = 3000,t2 = 2000 ,t3 = 1000,t4 = 1000,t5 = 1000,t6 = 2000,t7 = 7000;
char data_received =0;
int timeout;
void sendbyte(char byte);
int wait_time;
void attend_patient(char device_id);
///////////////////////////////////// main function
void main(void)
{ WDTCTL = WDTPW + WDTHOLD;
//setting initial state
P1DIR = 0; P2DIR = 0; P1OUT = 0; P2OUT = 0; P1IE = 0; P1SEL = 0; P1SEL2 = 0;
P1DIR |= BIT0;
P1OUT |= BIT0;
// configure UART
// SET DCO
BCSCTL1 = CALBC1_1MHZ;
DCOCTL = CALDCO_1MHZ;
//SET OUTPUT
P1SEL |= BIT1 + BIT2 ; // P1.1 = RXD, P1.2=TXD
P1SEL2 |= BIT1 + BIT2 ; // P1.1 = RXD, P1.2=TXD
// SET CLOCK FOR BAUD
UCA0CTL1 |= UCSSEL_2; // SMCLK
//SET BAUD RATE
UCA0BR0 = 104; // 1MHz 9600
UCA0BR1 = 0; // 1MHz 9600
//Enable
UCA0CTL1 &= ~UCSWRST; // **Initialize USCI state machine**
IE2 |= UCA0RXIE; // Enable USCI_A0 RX interrupt
// configuring Port interrupts falling edge
P1REN |= BIT4; // Enable internal pull-up/down resistors
P1OUT |= BIT4; // Select pull-up mode for P1.4
P1IE |= BIT4; // P1.4 interrupt enabled
P1IES |= BIT4; // P1.4 falling edge
P1IFG &= ~(BIT4); // P1.4 IFG cleared
// configuring the CPU speed
DCOCTL = 0; // Select lowest DCOx and MODx
BCSCTL1 = CALBC1_1MHZ; // Set range
DCOCTL = CALDCO_1MHZ; // Set DCO step + modulation
// configuring Timer A0
CCTL1 = OUTMOD_7; // CCR1 reset/set
CCR0 = 10000; // 10 ms
TA0CTL = TASSEL_2 + MC_1 + ID_0; // SMCLK, up mode, prescale by 0
// Enable Global Interrupts
__enable_interrupt();
while(1)
{
for(patient_id = 200; patient_id < 255; patient_id++) //for patient ids from 200 to 254
{
attend_patient(patient_id); //iterates over the patient ids
}
}
}
void attend_patient(char device_id)
{
_delay_cycles(1000); //some delay
data_received = 0;
P1IE &= ~BIT4; // P1.4 port_interrupt_OFF;
P1OUT |= BIT6; //switch on transmitter
sendbyte(device_id); //device 1
P1IE |= BIT4; // P1.4 port_interrupt_OFF;
P1OUT &= ~BIT6; //switch on transmitter
//waiting for heart beat data
timeout = 1000;
while((data_received == 0)&&(timeout)) //checks the flag for certain amount of time
{ //it quits waiting when it receives any data or when the timeout period finishes
_delay_cycles(100);
timeout–;
}
if(data_received) //if data is received
{
data_received = 0;
heart_rate = data; //sets the heart rate data
data = 0;
}
//waiting for temperature data
timeout = 1000;
while((data_received == 0)&&(timeout)) //it quits waiting when it receives any data or when the timeout period finishes
{
_delay_cycles(100);
timeout–;
}
if(data_received) //if data is received
{
data_received = 0;
temperature = data; //sets the heart rate data
data = 0;
}
// heart_rate = 0 is invalid
// temperature = 0 is invalid
if((heart_rate)&&(temperature)) //if both values are valid
{ //sends the data to PC
while (!(IFG2 & UCA0TXIFG));UCA0TXBUF = 13; //ASCII vallue for new line
while (!(IFG2 & UCA0TXIFG));UCA0TXBUF = device_id;
while (!(IFG2 & UCA0TXIFG));UCA0TXBUF = heart_rate;
while (!(IFG2 & UCA0TXIFG));UCA0TXBUF = temperature;
while (!(IFG2 & UCA0TXIFG));UCA0TXBUF = 1; //delimiter
}
}
///////////////////////////////////// receiver
#pragma vector=PORT1_VECTOR //port interrupt vector – falling edge
__interrupt void Port_1(void)
{ P1IFG &= ~(BIT4); // P1.4 interrupt flag is cleared first
time =TAR; //time between two falling edges
TAR = 0;
switch(current)
{
case 0:
{
if((time > (t1 + t2 – 500))&&(time < (t1 + t2 + 500))) //checks if the start condition is satisfied
{
current = 1; //To start a new session to collect data from next interrupt
digitcollected = 0;
val = 0;
break;
}
else //then it is not a valid session
current = 0;
break;
}
case 1: // code for collecting the data bits
{
if((time > (t5 + t6 – 500))&&(time < (t5 + t6 + 500))) //if time difference between two pulses is 3ms then it is logical 1
{
val |= 1; // corresponding bit is written and is shifted left. MSB is recieved first.
val <<= 1;
}
else if((time > (t3 + t4 – 500))&&(time < (t3 + t4 + 500))) //if time difference between two pulses is 2ms then it is logical 0
{
val <<= 1; //simply shifting means writing zero to the bit.
}
else if((time > (t1 + t2 – 500))&&(time < (t1 + t2 + 500))) //if a byte is received partially and suddenly a new button is pressed,then a start condition is produced
{
current = 1; // starts a new data collecting session
digitcollected = 0;
val = 0;
break;
}
else
{
current = 0; //session is invalid
break;
}
digitcollected++; //incrementing – indicating that bit is written
if(digitcollected == 8) //when all digits are collected
{
data = val>>1; //reason not identified but it keeps everything working fine
current = 0; //next interrupt will start a new session
digitcollected = 0;
val = 0;
// FINALLY ALL DATA IS RECEIVED HERE in ‘data’ variable
data_received = 1;
}
break;
}
}
}
///////////////////////////////////// transmitter
void sendbyte(char byte) //This sends the entire packet containing data and address
{
char i;
P1OUT &= ~BIT0; //Initial protocol for starting a communication
_delay_cycles(3000); //t1 3ms OFF //high for 3ms and low for 2ms
P1OUT |= BIT0;
_delay_cycles(2000); //t2 2ms ON
for(i=0b10000000 ;i; i>>=1) //MSB first
{
if(byte & i) //’i’ determines the position of bit to read in ‘byte’
{ //logical 1 – 1ms high and 2ms low
P1OUT &= ~BIT0;
_delay_cycles(1000); //t5 1ms OFF
P1OUT |= BIT0;
_delay_cycles(2000); //t6 2ms ON
}
else
{ //logical 0 – 1ms high and 1ms low
P1OUT &= ~BIT0;
_delay_cycles(1000); //t3 1ms OFF
P1OUT |= BIT0;
_delay_cycles(1000); //t4 1ms ON
}
}
P1OUT &= ~BIT0;
_delay_cycles(7000); //t7 7ms OFF //wait for 7ms in low until next communication starts
P1OUT |= BIT0; // ON forever
}
////////////////////////////////// 2.code for SLAVE ////////////////////////////////////////
//SLAVE
/*
Pin connections
P1.0 Tx data
P1.3 temperature sensor
P1.4 Rx data
P1.5 heart beat sensor
P1.6 Tx vcc
*/
#include “msp430g2553.h”
// for RF receiver algorithm
int time; //16 bit value to hold the TAR value
int val; //temporary variable for holding recieved values
char current,new,digitcollected,data;
int t1 = 3000,t2 = 2000 ,t3 = 1000,t4 = 1000,t5 = 1000,t6 = 2000,t7 = 7000;
char data_received =0;
// for transmitting data
void send_temperature_data(void);
void send_heart_data(void);
void sendbyte(char byte);
// Unique device id for each device
char device_id = 200;
// for heart rate counter
char rised = 0,count = 0,collected = 0;
int sum,time,ADC;
///////////////////////////////////// main function
void main(void)
{ WDTCTL = WDTPW + WDTHOLD; //stopping the watchdog timer
P1DIR = 0; P2DIR = 0; P1OUT = 0; P2OUT = 0; P1IE = 0; P1SEL = 0; P1SEL2 = 0; //setting initial state
P1DIR |= BIT0;
P1OUT |= BIT0;
//configuring CPU clock
// SET DCO
BCSCTL1 = CALBC1_1MHZ;
DCOCTL = CALDCO_1MHZ;
// configuring Port interrupts falling edge
P1REN |= BIT4; // Enable internal pull-up/down resistors
P1OUT |= BIT4; // Select pull-up mode for P1.4
P1IE |= BIT4; // P1.4 interrupt enabled
P1IES |= BIT4; // P1.4 falling edge
P1IFG &= ~(BIT4); // P1.4 IFG cleared
// configuring the CPU speed
DCOCTL = 0; // Select lowest DCOx and MODx
BCSCTL1 = CALBC1_1MHZ; // Set range
DCOCTL = CALDCO_1MHZ; // Set DCO step + modulation
// configuring Timer A0
CCTL1 = OUTMOD_7; // CCR1 reset/set
CCR0 = 10000; // 10 ms
TA0CTL = TASSEL_2 + MC_1 + ID_0; // SMCLK, up mode, prescale by 0
// configuring Timer A1 for heart rate conter
TA1CCR0 = 65535; // PWM Period
TA1CCR1 = 32768; // CCR1 PWM duty cycle
TA1CTL = TASSEL_1 + MC_1 + ID_0; // SMCLK, up mode, prescale by 8
// Enable Global Interrupts
__enable_interrupt();
while(1)
{
while(data_received == 0); //waiting for device id
data_received = 0; //clearing the data received flag
if(data == device_id) // if the received device id matches with this device
{
// send_heart_data();
// _delay_cycles(1000);
send_heart_data();
_delay_cycles(1000);
send_temperature_data();
_delay_cycles(1000);
}
// if the device id doesn’t match, the device knows that the master didn’t call it and it will wait for its turn
}
}
void send_heart_data(void)
{
char heart_rate = 0;
// configuring ADC on P1.5 for measuring heart rate
ADC10CTL0 =ADC10ON; //turn on ADC
ADC10CTL1 = INCH_5; // single channel mode P1.5 for input
ADC10AE0 = BIT5; // Enable ADC input on pot at P1.5
// algorithm for measuring heart rate
while(1)
{
ADC10CTL0 |= ADC10SC+ ENC; // enable +start a new conversion
ADC=ADC10MEM; // convert to volts and store
ADC=ADC>>2; // scale down actual value by 4, so 10 bit ADC now has: 2^10 /4= 256 levels
//while (!(IFG2 & UCA0TXIFG));UCA0TXBUF = ADC;
if(ADC > 10) //minimum value that denotes a valid heart beat
{
if(rised == 0) // since the ADC value is going to be above the trigger value until the peak vanishes, we are restricting the execution only to one time per peak
{
count++;
P1OUT |= BIT0; // switch ON red LED
if(count > 3) // to eliminate false values in the begining
{
time = TA1R; // collect time value
TA1R = 0; // reset the timer for measuring the time from now
time >>= 8; // converting 16 bit value to 8 bit value
if((time > 20)&&(time < 65)) //filtering the invalid values
{
sum += time; // averaging the time value from 20 data
collected++;
if(collected > 10)
{
sum /= 10;
collected = 0;
sum =0;
// to transmit the heart rate value
P1IE &= ~BIT4; // P1.4 port_interrupt_OFF;
P1OUT |= BIT6; //switch on transmitter
sendbyte(heart_rate); //device 1
P1IE |= BIT4; // P1.4 port_interrupt_OFF;
P1OUT &= ~BIT6; //switch on transmitter
break;
}
}
count = 0;
}
}
rised = 1;
}
else
{
rised = 0;
P1OUT &= ~BIT0;
}
}
}
void send_temperature_data(void)
{
char temperature = 0;
// configuring ADC on P1.3 for measuring heart rate
ADC10CTL0 =ADC10ON; //turn on ADC
ADC10CTL1 = INCH_3; // single channel mode P1.5 for input
ADC10AE0 = BIT3; // Enable ADC input on pot at P1.5
// measure analog value at P1.3
ADC10CTL0 |= ADC10SC+ ENC; // enable +start a new conversion
temperature=ADC10MEM>>2; // convert 10 bit adc value to 8 bit value
// transmit the temperature value
P1IE &= ~BIT4; // P1.4 port_interrupt_OFF;
P1OUT |= BIT6; //switch on transmitter
sendbyte(temperature); //device 1
P1IE |= BIT4; // P1.4 port_interrupt_OFF;
P1OUT &= ~BIT6; //switch on transmitter
}
///////////////////////////////////// receiver
#pragma vector=PORT1_VECTOR //port interrupt vector – falling edge
__interrupt void Port_1(void)
{ P1IFG &= ~(BIT4); // P1.4 interrupt flag is cleared first
time =TAR; //time between two falling edges
TAR = 0;
switch(current)
{
case 0:
{
if((time > (t1 + t2 – 500))&&(time < (t1 + t2 + 500))) //checks if the start condition is satisfied
{
current = 1; //To start a new session to collect data from next interrupt
digitcollected = 0;
val = 0;
break;
}
else //then it is not a valid session
current = 0;
break;
}
case 1: // code for collecting the data bits
{
if((time > (t5 + t6 – 500))&&(time < (t5 + t6 + 500))) //if time difference between two pulses is 3ms then it is logical 1
{
val |= 1; // corresponding bit is written and is shifted left. MSB is recieved first.
val <<= 1;
}
else if((time > (t3 + t4 – 500))&&(time < (t3 + t4 + 500))) //if time difference between two pulses is 2ms then it is logical 0
{
val <<= 1; //simply shifting means writing zero to the bit.
}
else if((time > (t1 + t2 – 500))&&(time < (t1 + t2 + 500))) //if a byte is received partially and suddenly a new button is pressed,then a start condition is produced
{
current = 1; // starts a new data collecting session
digitcollected = 0;
val = 0;
break;
}
else
{
current = 0; //session is invalid
break;
}
digitcollected++; //incrementing – indicating that bit is written
if(digitcollected == 8) //when all digits are collected
{
data = val>>1; //reason not identified but it keeps everything working fine
current = 0; //next interrupt will start a new session
digitcollected = 0;
val = 0;
// FINALLY ALL DATA IS RECEIVED HERE
//while (!(IFG2 & UCA0TXIFG));UCA0TXBUF = data;
data_received = 1;
}
break;
}
}
}
///////////////////////////////////// transmitter
void sendbyte(char byte) //This sends the entire packet containing data and address
{
char i;
P1OUT &= ~BIT0; //Initial protocol for starting a communication
_delay_cycles(3000); //t1 3ms OFF //high for 3ms and low for 2ms
P1OUT |= BIT0;
_delay_cycles(2000); //t2 2ms ON
for(i=0b10000000 ;i; i>>=1) //MSB first
{
if(byte & i) //’i’ determines the position of bit to read in ‘byte’
{ //logical 1 – 1ms high and 2ms low
P1OUT &= ~BIT0;
_delay_cycles(1000); //t5 1ms OFF
P1OUT |= BIT0;
_delay_cycles(2000); //t6 2ms ON
}
else
{ //logical 0 – 1ms high and 1ms low
P1OUT &= ~BIT0;
_delay_cycles(1000); //t3 1ms OFF
P1OUT |= BIT0;
_delay_cycles(1000); //t4 1ms ON
}
}
P1OUT &= ~BIT0;
_delay_cycles(7000); //t7 7ms OFF //wait for 7ms in low until next communication starts
P1OUT |= BIT0; // ON forever
}
//////////////////////////// 3.python code for saving the data ///////////////////////
import serial as se
import datetime
s = se.Serial(‘COM4’, 9600)
i=0
data1 = 0
data2 = 0
data3 = 0
data4 = 0
n=1
while 1:
try:
if(ord(s.read()) == 13):
data1 = ord(s.read())
data2 = ord(s.read())
data3 = ord(s.read())
data4 = ord(s.read())
print(n, “t”, data1, “t”, data2, “t”, data3,”t”, data4, “t”, str(datetime.datetime.now()), “n”)
f = open(str(data1)+”.txt”,”a+”)
f.write(“%dt”%n)
n +=1
f.write(“%dt”%data1)
f.write(“%dt”%data2)
f.write(“%dt”%data3)
f.write(“%dt”%data4)
f.write(str(datetime.datetime.now()))
f.write(“n”)
f.close()
i = i+1;
except KeyboardInterrupt:
s.close()
////////////////////////// 4.python code for plotting the data ///////////////////////
import serial as se
import datetime
s = se.Serial(‘COM4’, 9600)
i=0
data1 = 0
data2 = 0
data3 = 0
data4 = 0
n=1
while 1:
try:
if(ord(s.read()) == 13):
data1 = ord(s.read())
data2 = ord(s.read())
data3 = ord(s.read())
data4 = ord(s.read())
print(n, “t”, data1, “t”, data2, “t”, data3,”t”, data4, “t”, str(datetime.datetime.now()), “n”)
f = open(str(data1)+”.txt”,”a+”)
f.write(“%dt”%n)
n +=1
f.write(“%dt”%data1)
f.write(“%dt”%data2)
f.write(“%dt”%data3)
f.write(“%dt”%data4)
f.write(str(datetime.datetime.now()))
f.write(“n”)
f.close()
i = i+1;
except KeyboardInterrupt:
s.close()