Pollution is a serious issue, it causes breathing problems and can be detrimental to the health of asthmatic patients. Moreover, monitoring stations are usually placed in remote locations which do not accurately represent and determine features like gas, pressure, humidity, temperature and Air Quality Index (or AQI). These parameters can drastically change from street to street depending on the traffic and proximity to industry. This challenge can be solved using an IoT air quality monitoring station that can be placed outside your work or home to get realtime accurate information. This information can be of great use for people to know prior to travel, especially for individuals with breathing issues.

What it does

An IoT Air quality monitoring system that can capture real time information of temperature, humidity, pressure, and the presence of smoke and other noxious gases like carbon monoxide. The project makes use of three sensors - BME680, MQ9B and MQ2. The BME680 gas sensor can detect temperature, humidity, pressure and gas resistance. This information can be processed further to arrive at an estimate of the Air Quality Index or AQI of that area. The MQ2 sensor helps in detecting inflammable gases and smoke. Here we use it to detect smoke levels. The MQ09 gas sensor can be calibrated to detect the exact quantity of any poisonous gas, like carbon monoxide or methane. Here we use it to detect carbon monoxide, which is released in large amounts by vehicles on roads.

The device reports all its data to a web dashboard and can notify the user when any of the readings cross the safety threshold. So it can be used to remotely detect how safe an area is. The safety thresholds are tunable and will notify the user as soon as any of the readings cross that value.

The microcontroller, acting as the brain, is the SAMW25 Development Board by Atmel with the manufacture id as ATSAMW25-XPRO. The microcontroller has many GPIO Ports and has I2c, SCI, WiFI and ADC built in. It also has a vast range of example projects that can be seen for inspiration and direction. Lastly, with Atmel chips, we have the option to use the powerful Microchip Studio (Previously Atmel Studio) as our Integrated Development Environment. This IDE gives us powerful development and debugging tools to identify and solve issues in our code.

How we built it

Starting from Ideation, to components, to PCB Design and Firmware and Software we did everything from scratch. Dividing all the steps required to build this project into 6 steps.

1. Ideation and Components The first step was to ideate and come up with a mission statement for our project. Once we had an idea, we started designing the power system, port management and decided on the main components and their communication channels. We created a detailed Bill of Materials (BOM) for our project and a block diagram explaining the whole project in simple terms.

2. Schematics and PCB Layout Designing the schematics and PCB was an iterative, time consuming process. There was a lot of back-and-forth on the components our project used. Sometimes we faced supply chain issues and had to drastically change our design. Once done, we moved on to completing the schematic design and laying out that schematic on the PCB. This entire process was done using Altium Designer. Many symbols and layouts were designed by us, barring those for standard components and a few we found on the Altium Manufacture Repository or SnapEDA. We tried our best to follow best practices while routing and laying out, often consulting the datasheet for detailed information.

3. Boot loader and Firmware Once the PCB was on its way for review and printing, we started with the software part of our project. The Real Time Operating System of choice was Free RTOS. We chose Free RTOS for its simplicity, size and open source licensing. The MIT Open Source License allows us to loop at the code and understand how the thread scheduling is done by the RTOS. It also has multiple plugins that can be useful for expanding the project. The boot-loader and firmware are written in C with good programing practices.

4. Sensor and Actuator Interfacing We have 3 sensors in our project as mentioned before. The MCU is the central subsystem that communicates with all the sensors and reads the data from them. The BME680 used I2C to send a string of data containing informations such as the Temperature, humidity and other such information. The MQ2B and MQ09 both give a voltage output that can be converted into a sensible reading using the inbuilt ADC of the MCU. Sam 25 has 2 ADC pins that can be individually configured to read each sensors value.

There is also an on board LED which will flash when the sensors report a value greater than the threshold. Lastly, all the data will be relayed through MQTT to a web dashboard where we can see the real time data and can be alerted if it crosses a threshold. We can also change the threshold from the dashboard. More information is discussed in the next section.

5. MQTT and Wifi To communicate with the web we used the inbuilt WiFi chip on the Sam 25. The specific WiFi chip was the ATWINC1500. We used HiveMQ, an MQTT broker to communicate withe the MCU. We created the server on IBM Cloud (Previously knows as BlueMix).

6. PCB Flashing and Final Testing

We tested our project's functioning using dev boards. Once we receive our custom PCB, we will proceed to test our code on it.

Challenges we ran into

  1. In 2022 the Semiconductor supply chain was the biggest issue. Components were going out of stock overnight and many components were just unavailable. Due to that we had to change our design drastically and within a deadline.
  2. BME 680 was a difficult sensor to interface. The API's were not straightforward and it took a while to understand the specifics. This sensor is required to be initialized and configured properly. For example, the internal gas sensor within the BME has a hot plate that must be heated to 200 - 400 ° C and left for a while before it can measure the gas resistance. The sensor also requires some data compensation to be done in code before the output can be published to human eyes.
  3. The MQ9B sensor is required to be heated and left over 48 hours to calibrate. These restrictions caused some delay in our testing process.

Accomplishments that we're proud of

We're proud of having a project that works the way we planned for in the beginning. It took a lot of patience and perseverance to maneuver through issues and errors that pop up and change with every passing day.

What we learned

  1. Working in a team can be challenging but also rewarding. We gained a lot of maneuverability with different ideas, perspectives and expertise of each team member.

  2. Practical experience, specially in embedded is very necessary. Debugging and problem solving is an essential skill that can only be developed while working on a project. We all have built good intuition and methods to debug and solve hardware or software issues.

  3. Good Coding and Design Practices is a little extra effort at the start but it ultimately makes us better engineers. We have tried our best to follow best practices while designing the PCB and coding the firmware as well.

  4. The course allowed us to learn several industry relevant tools like Altium and FreeRTOS. We also gained some experience in debugging with the Logic Analyzer and Percepio.

What's next for BreathSavers

The BME 680 sensor is at the heart of this project. Currently the gas sensor in our BME680 reports gas resistance. The BME680 requires a BSEC Library, which must be integrated in FreeRTOS, to be able to give accurate AQI information. We hope to integrate this in the future. Another update would be to upgrade the BME 680 sensor to BME 688. The BME688 is the first gas sensor with Artificial Intelligence (AI) and integrated high-linearity and high-accuracy pressure, humidity and temperature sensors. Moreover, using the BME688 AI Studio, the small yet robust sensor, can be calibrated automatically for specific situations and applications such as smart home, IoT and a whole host of other scenarios.

We also want to update the project portfolio with live data from our project from wherever the board is at the moment to be displayed on the portfolio website.

Built With

Share this project: