Difference between revisions of "Wearable Space Bubble"

From Idea Shop Wiki
 
(12 intermediate revisions by the same user not shown)
Line 3: Line 3:
 
<br clear=all>
 
<br clear=all>
  
===What is W-Air Quality===
+
===What is the Wearable Space Bubble===
 
----
 
----
In 2018 Chicago received an F grade on its air pollution quality report from the American Lung Association, and it was still only the 22nd worst city in America.  Pollution is known to be seriously harmful to those with asthma and is detrimental to health over long term exposure. [1] This project will attempt to shed some light on the issue of air quality by creating a live map of Chicago with points indicating the worst air quality in the city.
 
  
This wearable device creates a live-map of air quality in a city, based on sensor data from an MQ-135 air quality sensor and location from a NEO 6-M GPS module.  An ESP32 microcontroller (MCU) will analyze sensor data, and transmit locations of poor air quality using the RESTful API to a Raspberry Pi cloud that pins that location on a map.
+
The Wearable Space Bubble is an IoT project that detects other people's Bluetooth devices to give you more personal space! Check out the definitely real commercial below!
  
[[File:WAIR-WORLD.png|thumb|center|600px| Using a GPS the device can record pollution data anywhere in the world]]
 
 
<center>
 
 
<div style="text-algin:center;">
 
<div style="text-algin:center;">
 
{{#widget:YouTube
 
{{#widget:YouTube
Line 17: Line 13:
 
|width = 75%
 
|width = 75%
 
}}
 
}}
</center>
 
  
 +
The Space Bubble uses Bluetooth protocols to detect nearby Bluetooth devices, and then estimate their distance to the wearer.  If a new Bluetooth Device is detected within the space bubble it activates a warning siren telling them to move away! In this case, the sound chosen was "Can't Touch This" by MC Hammer.  If a device is detected getting close to the user, LEDs on the user's jacket will light up warning them to step away.
  
 
===Device Architecture===
 
===Device Architecture===
 
----
 
----
  
Essentially, while you're out and about the device will constantly be looking for pollution.  If a high enough level of pollution is reached the user will receive feedback from a ring of LEDs.  The device takes sensor readings to determine the level of gasses present and then grabs the GPS location and stores the value and GPS location in memory.  When the device is near Wi-Fi again this data is uploaded to a Raspberry Pi server which applies the data to a live map based on the GPS coordinates.
+
This device utilizes an ESP32 microcontroller, a NeoPixel LED Ring, and an Adafruit Sound FX board and guitar amplifier.  The ESP32 performs Bluetooth sensing and sampling, and activates the LED ring and Sound FX board when your space bubble is violated!
 
 
In the prototype, the sensor readings are uncalibrated, and should only be compared to other sensor readings from the same prototype. 
 
 
 
<br>
 
[[File:WAIR-CHART.png|thumb|center|600px| This flowchart shows the basic functions of the W-Air Quality Device.]]
 
 
 
 
 
 
 
===Sensing Pollution===
 
----
 
The device utilizes an [https://components101.com/sensors/mq135-gas-sensor-for-air-quality MQ-135] air quality sensor capable of NH3, NOx, Alcohol, Benzene, Smoke, CO2.  Chemicals in those gasses interact with a tin-oxide (SnO2) layer, which will change resistance when the gas is present, allowing us to detect the above gases.  The sensor is also very sensitive to heat, so a heating-element is included in the sensor module to maintain a constant temperature. 
 
 
 
The MQ-135 sensor was far from perfect. The heating element required substantial current (150 mA, more than the current draw of the MCU), and several minutes to warm up to operating temperatures.  The sensor was also very inaccurate, although it could easily detect the presence of gasses it's difficult to determine the concentration of the gas which could be used to determine the AQI (Air Quality Index), which is widely used to gather Air Quality data.  This definitely leaves room for the project to expand.
 
 
 
Originally, the levels of gas were measured as a threshold value.  However, to determine the severity of pollution in an area, the device records the peak value from the sensor as a function of voltage.  Once the threshold for pollution is reached, the device begins tracking the highest value of pollution detected to be recorded as the "peak value".  A sampling function was also included, which takes 5 samples during the data collection period and averages them to even out faulty sensor data.
 
<br>
 
[[File:MQ-135-GRAPHS.png|thumb|center|800px| Tests performed on MQ-135 Sensor with a 500 millisecond sampling period]]
 
<br>
 
 
 
 
 
In these tests, a 40% alcohol solution was introduced to the sensor for 5 sensor cycles (2.5 seconds), and the resulting data is recorded above.  With the sampling algorithm applied, you can observe that the readings appear much steadier. 
 
  
===GPS Information===
+
The LED Ring is controlled using PWM (Pulse Width Modulation), you can learn more about PWM on the '''[[Arduino]]''' page!
-----
 
To retrieve its location the device utilizes NEO-6M GPS module.  The GPS module I’m using for this device is self-contained and simply sends NMEA Strings over Serial Communication lines to the Arduino (at 9600 baud). NMEA stands for National Marine Electronics Association and is the standard for GPS communication world-wide (GPS World).  I used the TinyGps++ library to parse these strings and read the latitude, longitude, and number of satellites the GPS module can see.
 
  
After implementing the library, I found that it takes a lock on at least 3 satellites to get the position, but the best accuracy is had at a lock on 4 satellites. This is useful to know, we can require a lock on 4 satellites before longitude and latitude values are accepted.
+
The Adafruit Sound FX board is activated with a digital output pin on the ESP, and can be set to play multiple sounds.  At first, I wanted to store the sound files on the ESP32, but when I compressed them to fit available memory I found the quality dropped too much to be usable.  Here's a great project from  '''[https://hackaday.com/2018/02/06/esp32-we-have-ways-to-make-you-talk/ Hackaday]''' on storing WAV files on an ESP32.'
 +
[[File:SPACE-BUB-ARCH.png|400px|thumb|center|Everything is held together with sturdy duct-tape connections.]]
  
===ESP32===
+
===Bluetooth Sensing===
 
-----
 
-----
The ESP32 is a very popular microcontroller for IoT projects. It can perform standard Wi-Fi functions and can operate using the Bluetooth and BLE protocols.  It also has dual-cores, which makes multitasking with this MCU very easy.
 
 
I implemented state-based control for the LEDs as a process that runs on the second core of the ESP-32.  One of the neat things about the ESP32 is that it uses FreeRTOS, or real-time operating system which allows us to utilize tasks with different priorities that can all run independently.  The task that controls the LEDs runs on Core 1, and Core 0 operates our main function.  A global variable that controls the brightness, color, and type of display (the state) can be changed by the main program that will instantly change the display. 
 
 
[[File:WAIR-PROTO.jpg|thumb|center|400px|"Prototype W-Air Quality Device "]]
 
  
Something I’ve seen in other IoT devices and always wanted to implement is a solution for the user to input their SSID and Password over Wi-Fi so their IoT device can access the internet.  To do this, I utilized a captive portal on the ESP32 based on ESPRESSIF’s captive portal example (ESP32 Resources).  A captive portal is a web page that can be accessed by joining a network, what makes it ''captive'' is that all traffic is directed to the page once a device is connected.  You can see this on airplanes, when you connect to the in-flight Wi-Fi and get redirected to their website.  The way the ESP 32 does this is by establishing itself as a DNS server and creating a Wi-fi network you can connect to.  It waits for a client connection and then directs all traffic to a webpage it hosts.  I added a form to the webpage for the SSID and Password of your network, input from that is parsed on the Arduino from a GET request using code I wrote.
+
Almost everyone nowadays has a Bluetooth device on them, that is identifiable with a MAC address (like a license plate for devices), whether it’s their phone or headphones these devices can be accessed and detected without directly connecting to them or interfering with them at all.
  
'''[https://github.com/ShoelessJo3/ESP32-Captive-Portal Use my captive portal program in your own ESP project]'''
+
To determine the location of nearby devices, the Space Bubble sends out an “inquiry packet”, asking nearby devices to identify themselves. Bluetooth devices that receive this request will respond with their identification, and the social distancing device can determine how far away these devices are depending on the strength of the returned request.  This is called RSSI, received signal strength indicator, and it’s measured in decibels. 
  
One of the design constraints I was concerned about in my initial proposal is a lack of Wi-Fi connection.  If there’s no Wi-Fi, we need to be able to store the coordinates and send them to the server when a Wifi connection is availableI considered two solutions to this problem, writing to the Flash memory on the ESP with SPIFFs or writing directly into the EEPROM. SPIFFs is a flash file system that lets you write files to flash and update them later, it works similarly to the os commands in python that allow you to edit filesThis has the advantage of storing larger files, but large files aren’t necessary on this project, and I found that I’m already using over 80% of the flash memory on the ESP32 so the more I can minimize that usage, the better.
+
Testing this method on the ESP32, I found that the RSSI varied depending on the distance of devices, and proximity to other Bluetooth devicesBluetooth devices all operate on the 2.45 GHz frequency, which is close to Wi-Fi, so some noise is expected*I utilized a method of sampling several different values and averaging them to get a more accurate reading for distance.
  
The solution I ended up using was writing to the EEPROM, which is limited to 512 bytes, so I decided to create a memory map, similar to what we did in ECE 441, embedded systems. There are 3 things I need to store in memory; SSID, Password, and sensor values.  I used $000 to store the number of locations, and since SSID and Password are variable strings I used $001 and $002 to store their lengths. I also had to include a spacer after the SSID in EEPROM, otherwise it would be difficult for the Arduino EEPROM library to differentiate the two strings.  Using my memory map, we can determine where each String and Coordinate are located.  For example, the Coordinates start at $005+ the length of the SSID + the length of the password.  Using this method I calculated we can store roughly 40 sets of coordinates in the EEPROM which can be returned when the device is connected to Wi-Fi again.
+
[[File:SPACE-BUB.png|400px|thumb|center|All devices nearby are detected, and if the device is new (not one of your devices), it can trigger the alarm.]]
  
===Website Interface===
+
If a Bluetooth device is detected within a certain range of RSSI values, we check its MAC address against previously detected addresses (this is in case the user has a Bluetooth device) and then determine a more accurate RSSI value using the sampling algorithm.  If the device is not within 6 feet of the user (give or take a few feet), the Space Bubble will output a variable number of LEDs on the LED ring which should show other people how close they are to violating your space bubble. If the detected device is within 6 feet of the user (give or take a few feet), the LED ring will spin and flash, and a siren is activated to warn the approaching person.
-----
 
  
Using the Flask API I was able to parse GET requests from the ESP32 on the Raspberry Pi and store them in a CSV file using Pandas, a python library for editing data structures.  Then I utilized Plotly, a python library for generating interactive HTML plots, to create a heat-map based on the CSV file.  I updated the main page of my website to deliver the plotly HTML page to the user.  Currently, when a GET request is sent, the server first appends it to the CSV file, then reopens the CSV file with plotly to remake the heat-map.  This is not optimal if the ESP sends a large quantity of coordinates, and may waste a lot of time, so I will consider reoptimizing this in the future. Perhaps the GET request could include a flag, so the server would know only to append to the CSV file, and wait to create the heat-map until the last coordinate is received.
 
  
[[File:WAIR-RASPI.png|thumb|center|400px|Raspi and Plotly Coding]]
+
<nowiki>*</nowiki>Side Note: To prevent the majority of the noise, Bluetooth Devices utilize adaptive frequency hopping. Basically, it's like if you were using a radio channel with your friend, and someone else hopped on and started talking.  You tell your friend you're moving to a different channel and you both move to a new, clear channel.
  
 
===Next Steps===
 
===Next Steps===
 
-----
 
-----
The next step for this device is implementing it into a wearable device. This project was originally designed to be sewn into a jacket using conductive thread and have a PCB printed for the device, but due to limitations caused by COVID-19 this was not possible. A PCB was designed, and this page will be updated in the future to reflect project progress.
 
  
[[File:WAIR-PCB.png|thumb|center|400px|PCB]] [[File:WAIR-SCH.png|thumb|center|700px|Schematic]]
+
The next steps for this project are improving the quality of the build and designing an enclosure for it.  The LED ring in the sleeve was sewn in, however I didn't have the right wire to complete the build due to quarantine restrictions, or a soldering iron, so I duct-taped wire together from an old cord I had in my apartment (this is not advisable it kept falling apart). It would also be interesting to factor in other nearby devices that could cause noise in the RSSI algorithm.
<br>
 
  
 +
Thanks for reading!
 +
- Joe Ricker
 +
 
-----
 
-----
 
===Sources===
 
[1] - “Chicago Gets 'F' Grade in 2018 Air Pollution Report,” WTTW News. [Online]. Available: https://news.wttw.com/2018/04/20/chicago-gets-f-grade-2018-air-pollution-report. [Accessed: 16-Mar-2020].
 

Latest revision as of 22:24, 30 April 2020


What is the Wearable Space Bubble


The Wearable Space Bubble is an IoT project that detects other people's Bluetooth devices to give you more personal space! Check out the definitely real commercial below!

The Space Bubble uses Bluetooth protocols to detect nearby Bluetooth devices, and then estimate their distance to the wearer. If a new Bluetooth Device is detected within the space bubble it activates a warning siren telling them to move away! In this case, the sound chosen was "Can't Touch This" by MC Hammer. If a device is detected getting close to the user, LEDs on the user's jacket will light up warning them to step away.

Device Architecture


This device utilizes an ESP32 microcontroller, a NeoPixel LED Ring, and an Adafruit Sound FX board and guitar amplifier. The ESP32 performs Bluetooth sensing and sampling, and activates the LED ring and Sound FX board when your space bubble is violated!

The LED Ring is controlled using PWM (Pulse Width Modulation), you can learn more about PWM on the Arduino page!

The Adafruit Sound FX board is activated with a digital output pin on the ESP, and can be set to play multiple sounds. At first, I wanted to store the sound files on the ESP32, but when I compressed them to fit available memory I found the quality dropped too much to be usable. Here's a great project from Hackaday on storing WAV files on an ESP32.'

Everything is held together with sturdy duct-tape connections.

Bluetooth Sensing


Almost everyone nowadays has a Bluetooth device on them, that is identifiable with a MAC address (like a license plate for devices), whether it’s their phone or headphones these devices can be accessed and detected without directly connecting to them or interfering with them at all.

To determine the location of nearby devices, the Space Bubble sends out an “inquiry packet”, asking nearby devices to identify themselves. Bluetooth devices that receive this request will respond with their identification, and the social distancing device can determine how far away these devices are depending on the strength of the returned request. This is called RSSI, received signal strength indicator, and it’s measured in decibels.

Testing this method on the ESP32, I found that the RSSI varied depending on the distance of devices, and proximity to other Bluetooth devices. Bluetooth devices all operate on the 2.45 GHz frequency, which is close to Wi-Fi, so some noise is expected*. I utilized a method of sampling several different values and averaging them to get a more accurate reading for distance.

All devices nearby are detected, and if the device is new (not one of your devices), it can trigger the alarm.

If a Bluetooth device is detected within a certain range of RSSI values, we check its MAC address against previously detected addresses (this is in case the user has a Bluetooth device) and then determine a more accurate RSSI value using the sampling algorithm. If the device is not within 6 feet of the user (give or take a few feet), the Space Bubble will output a variable number of LEDs on the LED ring which should show other people how close they are to violating your space bubble. If the detected device is within 6 feet of the user (give or take a few feet), the LED ring will spin and flash, and a siren is activated to warn the approaching person.


*Side Note: To prevent the majority of the noise, Bluetooth Devices utilize adaptive frequency hopping. Basically, it's like if you were using a radio channel with your friend, and someone else hopped on and started talking. You tell your friend you're moving to a different channel and you both move to a new, clear channel.

Next Steps


The next steps for this project are improving the quality of the build and designing an enclosure for it. The LED ring in the sleeve was sewn in, however I didn't have the right wire to complete the build due to quarantine restrictions, or a soldering iron, so I duct-taped wire together from an old cord I had in my apartment (this is not advisable it kept falling apart). It would also be interesting to factor in other nearby devices that could cause noise in the RSSI algorithm.

Thanks for reading! - Joe Ricker