Friday 15 December 2017

Bio-Signal based Home automation using Arduino and Raspberry Pi





So... I've been working on this project with my friends for a year. It was for a contest(And we won. fuck yeah.)
Now since that shit's over, I thought that I should document it. So here it is.

So, Here's The Deal.

people sleep, right? And sometimes, when you're watching Netflix, or just normal TV, or just...whatever, you fall asleep with appliances on.  Then those appliances use electricity. That's bad. For the environment, and for yer bills. So, what if there was a device that turned off appliances when you fall asleep? and turn the lights back on when you're awake? I mean, you gotta get up to turn the lights on. If you have bad eyesight, or you're old and can't see well in the dark, your house can be a fucking hazard. If the light turn on automatically when you're awake, that would be awesome. So, me and my friends decided to build a thing that did that.


Stuff We Used

Image result for arduino oled screen
0.96'' I2C OLED Display

Image result for mpu 6050
Accelerometer/gyro sensor(MPU 6050).

Image result for mlx90614
Temp Sensor (MLX 90614). Fancy stuff.
It can tell the temperature of an object right infront of it, as well as the ambient temp.

Image result for arduino pulsesensor
Pulse sensor.(We ditched this sensor mid way.)
Image result for arduino relay module
Relay module.

Image result for ds3231
DS3231 RTC module.


Image result for adafruit powerboost 1000c
Adafruit Powerboost 1000C

Image result for 18650
18650 liion battery
Image result for bluno nano
Bluno Nano.
Arduino Nano w/ intergrated bluetooth module.


Image result for arduino nano
Arduino Nano.
Image result for rpi 3
Raspberry Pi 3 Model B.




+ random wires, resistors, capacitors, buttons,servo motors + metal brackets, EVA foam, glue, knives, tape, heatshrink tubing, solder, soldering iron, heatgun, lighter, cables, chargers, more shit.

MK.I

This thing. Like...WTF?
This thing was just a piece of shit. It was shoddy, shitty, didn't have a battery or a screen, didn't have a pulse sensor, was made out of paper.... None of the wires were soldered, it was JUST for testing. didn't last a day. but we DID get data from that thing. MK.I was nothing more than a proof of concept, checking the software stuff more than the hardware stuff. And it served as a base for MK.II, which lasted Way longer, and was way more comfortable. 
















MK.II

Finally, Something wearable. It has a screen, a knob to change what was displayed on the screen, SOLDERED WIRES, comfy,spongey materials, more integrity, and...just...all around better. It still had a LONG way to go. Still wired(Both battery wise and data transfer wise), no lock mechanism, was made out of a foam sponge and electrical tape. even with all these flaws, we still managed to get some data. 





Mk.III

MK.III. This one uses an arduino uno. It also has a LCD shield instead of the OLED screen. The straps are made of EVA foam, and...electrical tape. electrical tape FTW. This one didn't work that well. The code was sorta..all over the place. the sensors dodn't work well with the LCD,.... many problems.







Ditching Sensors



Look at these numbers. LOOK AT THE FUCKING GRAPH! JUST FUCKING LOOK AT IT! The thing's all over the place. The number ranges from 25 to 236. That's not human. Similar shit happened with the temperature sensor. Human peoples aren't supposed heat over 40 degrees Celsius. After multiple tries, and multiple failures, (and by multiple, I mean a shit ton) we decided to ditch the pulse sensor.



MK.IV

Kay. MK.IV. The final thingy. We decided to ditch the pulse sensor, and replace it with an accelerometer. We also switched the arduino nano we were using to a snazzy thingy called a bluno nano, which has a integrated bluetooth module in there. Wireless data transfer was a go.
The code DID get a LOT dirtier. 
Well. we made the thing out of EVA foam. it was a lot comfier. a lot sturdier. a lot better. We even added a battery. Velcro locking mechanism. Unfortunately, I don't have any solo photos of MK.IV. but I do have a photo of all the devices together. Looks cool in my opinion.(Mabye that's because I'm the one who took it.)
BOOM.

The pink Pip-Boy like thing is the MK.IV. Looks cool,eh? It came a long way from the first one.






Raspberry Pi Stuff

Okay. to be honest, The raspberry pi part wasn't my part. I don't know much of the details. I suck at python.  The code receives the data transmitted from the armband thing. it calculates if the dude is sleeping via the accelerometer values, and chucks out a HIGH/LOW signal to a connected Arduino. It also chucks out a txt file. Cool shit, eh?  My friend who wrote this code is a wizard.



Controlling Appliances

We used relay modules for this job. It's probably a terrible idea, since this method just cuts the power to the appliances, but I don't give a shit. Anyways, We cut open an extension cord, soldered on a 5v adapter, and connected a relay module. 

We also made a switch-turning-off robot with a servo motor. What...Like....why....who.....
anyways, it kinda worked.

these are connected to a arduino which is connected (via USB) to a raspberry pi.

This thing. the pot is there for testing. it came off later.



Code And Shit


This is the schematic for the armband. 




Look at it. Take time to take it all in. Noice.


The code and stuff are here: https://github.com/flthtmtlf/2017STEAMRnE_HomeAutomation/tree/beta


No comments:

Post a Comment