I have a grandmother who is at her late 60's, A stroke left her right side of her body paralyzed. This incident inspired me to work on a new project which at first designed as an early warning system for stroke. Later I upgraded it to analyze the pattern of heart attack, heart failure, and up to 15 other diseases. Old People finds it hard to keep track of the medicine consumed on a daily basis, which can lead to many medical problems, which is not their fault they forget about it. I come across similar situations where working class people find it difficult to look after their elderly.
So what is Dr assistant ??
It a small system which runs Android things on raspberry pi 3. There are no much Hardware parts to it. In fact it is just a small boy which is connected to internet through wifi or Ethernet and left at some where in the house , yes literally some where , you don't have to worry about the pace where you will keep where there are lot of sound disturbances and the key feature is one Dr assistant is enough for a big house , you don't have to buy anything else to extend it , you may be wondering how can this be achieved , the answer is you just need to have a Bluetooth speaker with a microphone with it and you are done , imagine taking around a small ear Bluetooth speaker and walking around . That's Dr assistant , a Complete solution for luxury and medical aid .
Special features or medical aid part , excluding the google assistant system is :
- A wrist watch is tighed around youre hand which takes your blood pressure readings every 15 minutes and minitors your heart beak always .
- it can predict desiases of 15 types caused by these two parametrs induvidually , imagine what is its potential if both these parameters are combined together .
- Its has a AI in it which can predict all the diseases , its not just by taking a single day redings .
What is Tensor flow (AI) ?
TensorFlow is an open-source software library made and open sourced by google for data flow programming . It was released in 2015 .It is a great tool for developing AI .It is the AI google uses for its search engine and YouTube searches . the fun part is now can can play with it since they open sourced it .
Diseases which this system can predict are :
- Damaged and narrowed arteries
- Aneurysm.
- Coronary artery disease.
- Enlarged left heart.
- Heart failure.
- Transient ischemic attack (TIA).
- Stroke
- Dementia.
- Mild cognitive impairment.
- Kidney failure.
- Kidney scarring
- Kidney artery aneurysm.
- Vision loose
Effects oF High and Low heart beat :
- Tachycardia -High heart breat
- Bradycardia -low heart beat rate ,usually found in old people often comes and goes , so a standerd Ekg done in the dr office may not find it .
- Serious mitral valve disease .
An EKg can identify bradycardia only if you are actually having it during the test .You may need to use a portable electrocardiogram .
Source : Mayo clinic , American Heart association , From Dr experiences .
So Felt Interesting right . lets get dirty.
I am going to split it into two parts and name them as
1. The Google assistant
2. Blood Pressure Monitor (Which is still a beta version since data collection and due to other technical reasons )
Part 1. Google assistant :
Just a raspberry pi 3 connected to the internet through Ethernet or wifi and the slave device is an ESp8266-01 . It's our assistant in our android phones.Yes the exact same one, then you may be wondering what is the difference be Google assistant on our phone and running the same assistant on a pi. The answer is you can control Electrical appliances with it. Here is an intro on Google assistant by Wayne Piekarski from Google.
So here is how you can install Google Assistant API from Android Things using gRPC.
How Google assistant works ?
It records a spoken request from the connected microphones, sends it to the Google Assistant API and plays back the Assistant's spoken response on the connected speaker.
Pre-requisites :
- Android Studio 2.2+.
- Android Things compatible board.
- If using AIY Projects Voice Kit: Android Things Raspberry Pi Dev Preview 5 image from the Android ThingsConsole.
- If using Android Things: supported microphone and speaker.
set AUDIO_USE_I2S_VOICEHAT_IF_AVAILABLE = false
inAssistantActivity.java
Run the sample
- Configure the Google API Console Project to use the Google Assistant API.
- Download
client_secret_NNNN.json
(type: Other) from the credentials section of the Console.
- Install the google-oauthlib-tool in a Python 3 virtual environment:
python3 -m venv env
env/bin/python -m pip install --upgrade pip setuptools
env/bin/pip install --upgrade google-auth-oauthlib[tool]
- Use the google-oauthlib-tool to generate credentials:
env/bin/google-oauthlib-tool --client-secrets client_secret_NNNN.json \
--credentials app/src/main/res/raw/credentials.json \
--scope https://www.googleapis.com/auth/assistant-sdk-prototype \
--save
- Make sure to set the Activity Controls for the Google Account using the application.
- On the first install, grant the sample required permissions for audio and internet access:
./gradlew assembleDebug
adb install -g app/build/outputs/apk/app-debug.apk
- On Android Studio, click on the "Run" button or on the command line, type:
./gradlew installDebug
adb shell am start com.example.androidthings.assistant/.AssistantActivity
- Try the assistant demo:
Press the button: recording starts.
Ask a question in the microphone. After your question is finished, recording will end.
The Google Assistant answer should playback on the speaker.
1.2 How to connect google assistant with ESP8266-01
Working :
ESP8266 is a wifi SOC (system on a chip) produced by Espressif Systems . It is an highly integrated chip designed to provide full internet connectivity in a small package. And it can be also controlled by our smartphone by using an App. ESP8266-01 having two gpios but here we are using RX & Tx of the esp as a gpio for controlling the LEDs.
When ever the google assistant is given a instruction to turn on some appliance ,lets say a to turn on light and esp is hosting a private web server with its ip adress 192.168.4.1 . Raspbarry pi call send a web requit to the page http://192.168.4.1/on so the esp getings this web request and proceses the request and finds the "on" command in it and turn on the Light .
like wise we can connect as much as appliances you want ,its only limited by your router settings .
So lets get to work :-
Things you will need :
- asm1117 or LM3940 3.3v regulator (make sure you read the data sheet and make a power supply , LM3940 can only step 5 V to 3.3 V DC so first you need to make 5 V DC from 230V (in my place ) to 5 V then use Lm3940 or use a battery source )
- 10uf capacitor
- 5 V relay
- BC547 transistor
- a console cable
Connection :
Connect esp8266 to console cable as black wire to ground, red wire to V+, white wire to TX and green wire to RX
Install the Arduino IDE 1.6.4 or greater
You can download it from here
Install the ESP8266 Board Package
Enter this line in the 'Additional Boards Manager URLs:
http://arduino.esp8266.com/stable/package_esp8266com_index.json
Next, use the Board manager to install the ESP8266 package.
80 MHz as the CPU frequency (you can try 160 MHz overclock later)
115200 baud upload speed is a good place to start - later on you can try higher speeds but 115200 is a good safe place to start. You can move down to lower speeds if you are having upload issues, or speed it up if your setup is stable, for faster uploads!
You don't have to set Programmer because it will always use the serial port, just ignore that menu item!
Time to wire up the circuit
Program ESP8266 using Arduino
Make the circuit as per the above given diagram. Power up the Arduino UNO board and wait till the Arduino Board boots up successful. (It will take around 5 seconds) Connect the Arduino Reset pin to Ground. Reset pin is grounded to bypass the Arduino. It will disable Arduino Board and upload the below code directly to the ESP8266.
Upload the code and you are done
here is the circuit diagram
Part 2 : Blood Pressure Monitor
The main part is a sphygmomanometer ,which is used to measure the blood pressure and a heart beat sensor .
What is Blood pressure ?
The pressure of the blood in the circulatory system, in simple terms , the force in which blood rushes through our artery
What is sphygmomanometer ?
An instrument for measuring blood pressure, typically consisting of an inflatable rubber cuff which is applied to the arm and connected to a column of mercury next to a graduated scale, enabling the determination of systolic and diastolic blood pressure by increasing and gradually releasing the pressure in the cuff.
What do you mean by Heartbeat?A person’s heartbeat is the sound of the valves in his/her’s heart contracting or expanding as they force blood from one region to another. The number of times the heart beats per minute (BPM), is the heart beat rate and the beat of the heart that can be felt in any artery that lies close to the skin is the pulse.
How does a heart beat sensor works ?
The heartbeat sensor is based on the principle of photo phlethysmography. It measures the change in volume of blood through any organ of the body which causes a change in the light intensity through that organ (a vascular region).
So How can these two instruments find out weather you are ill or not ?
The reading are taken and compared to a person who had a some effects of high blood pressure or high heart beat and predicted .
Lets take the case of stroke , Initially to collect training set we ask a person who is likely to have stroke and records his Bp and heart beat every 15 minutes and a particular model is made on it . when the user wears it , it takes their sensor data and analyse it with the trained model and predict weather the user has a chance of getting a stroke .
Enough of theory , lets build it .
Esp8266-12 is used as the micro controller to read data from the band and sends the data to a google sheet every time it gets connected to internet .
Tensor flow running on Android things in Raspberry pi takes this data to predict weather the bp and heart beat pattern is abnormal and has a chance of any disease .
These are the parts you will need
- sphygmomanometer , Which is arduino compatible, which you can buy from here ,
- A heart beat sensor , which is also arduino compatible
- Esp8266-12 wifi board
1. Circuit diagram
Wire up the circuit as shown
2. Set up the dependencies for google sheet plotting
We need to upload data from esp8266-12 to google sheets for tensor flow to analyse with the help of Thingspeak.com
Lets begin
Part 1: Creating and Deploying your Google Sheet
- Sign up for a free Google email if you don’t have one.
- Log in to your free Google account and create a new “Google Sheet,”
- Once you are into it , Right click and make a new folder
Save the key . This key is listed in the URL between the “/d/
” and the “/edit
” of your new spreadsheet (TheHighlighted one )
- Name your Spreadsheet something original like “Heart data analysis,”
- Now we need to insert google app script
To insert our Google App Script we first navigate from our spreadsheet to the Script Editor:
Tools →Script Editor
- Delete every thing in it and past the script (bottom of this page )
- Now save the Google script .
- Edit the highlight portion with your google sheet URL
- Save the script: File→Save All
- Deploy as a web App: Publish-→ Deploy as web App…
- It will ask you to grand permission
Grand permission with your google account .
- Copy and save the URL
Part 2: Configuring PushingBox
Pushingbox.com serves as as simple, free, and easy API middleman in allowing our DHT data to be palatable to Google Sheets. The need for using the PushingBox API intermediary is to turn our HTTP transmitted data into Google compliant HTTPS encrypted data. We could attempt to make a non-trivial encryption algorithm to satisfy the standard requirement but using PushingBox is easier, and we are given up to 1,000 requests a day for free. In addition we don’t have to deal with any “Black Box” API’s in which we can input our own parameters, but then get little control over customization, and no real idea of how the function actually works. Below are the steps for configuring Pushingbox to work with our data:
1. Create a PushingBox account using your Gmail.
2. At the top click on “My Services”
3. While now in “My Services” go to the “Add a service” box and click on “Add a service”.
4. The service you will want to create is the last item on the list of services and is called: ”CustomURL, Set your own service !". Now select this CustomUrl service.
5. A box will open up and ask for three items. Fill them out as below, then hit submit
Name of your CustomURL configuration:
Root URL: This url will start with https://script.google.com... as this is your Google Script address saved from Part 1
6. After submitting your service you must now create a scenario for the service. To do this select “My Scenarios” at the top of the page.
7. Enter an appropriate name for your scenario in the “Create a scenario or add a device” box. After you name your service click the “add” button to the right.
8. Now it will ask to “Add an action for your scenario” You should now choose the “Add an action to this service” button listed next to the service name you created in the previous step. This assigns your new scenario to your new service.
9. A data box will open asking you for your “Get” or “Post” method (we use the Get method although this seems counter-intuitive). For recording all our DHT data (five data points) into your Google sheet you need to link your variable names listed in your Google App Script to the names listed in our Arduino sketch. Formatting the names correctly in the Pushingbox API will accomplish this linking task. Copy and paste the following string into your box.
?BpTime=$Bptime$&sysbp=$sysbp$&diabp=$diabp$&hbtime=$hbtime$&heartbeat=$heartbeat$
Note: STATEMENT BEGINS WITH " ? " TO INDICATE "GET"
Make sure to copy your "DeviceID" string, you will need it for in the next step, and later for the Arduino Sketch in Part 3.
Part 3. Arduino coding
- You can follow the same stemp shows in "1.2 How to connect google assistant with ESP8266-01 " , both board has the same manufacture , so the same procedures to install its libraries
- You need to copy and paste the included Arduino sketch, customize it for your device, and then upload the sketch onto your ESP8266. The sketch also relays serial output at 115200 baud so you can monitor the data getting sent via WiFi. The three fields on the Arduino sketch you must customize are:
A) Your WiFi name
B) Your WiFi Password
C) Your Pushing box Device ID (devid)
wire up the circuit
- Wire up the heart beat sensor , it depends on which type of sensor you used .
- TX-OUT = Transmit output. Output serial data of 3V logic level, Usually connected to RXD pin of microcontrollers
- +5V = Regulated 5V supply input.
- GND = Board Common Ground
This should be the final output :
You are done with it ., all that is left is to make a casing for pi
I got a old UPS lying around so i thought it would be the best choice for me
There was a power cod coming out of it . so i hooded up an 5 V adapter and connected it to pi .
Now all you need to do it to train it and create the model and you are done .
Comments