My first proposal for the contest “Revolutionize Your IoT Prototyping with NXP” was to develop the blessTags (https://www.microsoft.com/en-us/p/blesstags-a-sensortag-app/9p054xsjjr1n) application in order to be able to manage NXP Rapid IoT Kit. Unfortunate the NXP Rapid IoT Kit is unable to pair with a personal computer (using the Windows 10 standard "Add Bluetooth device" dialog interface). Several other users reported also this problem. I am sure that this problem will be solved by the NXP company in the shortest time. But up to that moment I was forced to develop another application.
This new application started from the observation that this generation, my generation but not only my generation, is an indoor generation. A generation that spend 90% of it is life indoors. A generation that filled the homes with lovely things and with all the stuff wanted and required to have a beautiful and a peaceful life. So, our home became a place from where we would never want to leave.
The scientists discovered that the air inside our homes is up to five times more polluted than the air outside. In fact, millions of homes are unhealthy to live in. They discover that living in damp homes increases the risk of asthma by 40%. Millions of people suffers from asthma and allergies caused by a bad indoor environment.
It turns out that kids’ rooms often have the highest concentration of toxicants in the house. Children are particularly vulnerable to the impact of poor indoor climate because their lungs and brains are not yet fully developed. Kids’ rooms are often the worst places to be for air pollution. As well as toxic particles from sources around the home, the many toys and electronic appliances found in so many children’s rooms can also be responsible for potentially harmful emissions. A recent Danish survey found that around half of the participating families had higher than recommended night-time concentrations of CO2 in kids’ rooms, and that around every fourth room had three times the recommended maximum CO2levels. Air pollution and high CO2 levels can lead to problems like headaches, troubled sleep and fatigue through to difficulty concentrating.
When a human is overheated and, in the same time, stay in places with high humidity, this may lead to infections of respiratory tract. On the other hand, high temperature and low relative air humidity may dehydrate mucous membranes thus increasing vulnerability to viruses and bacteria.
Moreover, the successful transmission of an infection via the airborne route relies on several factors, particularly the optimal temperature and optimal relative humidity. The survival of viruses and other infectious agents depends partially on levels of relative humidity (RH), and reducing virus viability may prevent direct transmission of viral infections. Generally, viruses with lipid envelopes will tend to survive longer at lower 20–30% RHs. This applies to most respiratory viruses, which are lipid enveloped, including influenza, corona viruses, respiratory syncytial virus, parainfluenza viruses, as well as febrile rash infections caused by measles, rubella, varicella zoster virus, etc. Conversely, non-lipid enveloped viruses tend to survive longer in higher 70–90% RHs. These include respiratory adenoviruses and rhinoviruses.
IntroductionFrom all of these facts, presented above, is easily to observe that there is a need to develop a system able to determine in real time the temperature, humidity, temperature-humidity indexes, the concentration of the CO2, and the concentration of toxic volatile organic compounds.
The system that I have developed is composed of a software component that runs on an Android mobile phone that is able to connects to a NXP Rapid IoT Prototyping Kit device from where it picks up and determines all these values.
A short demonstrative movie, of the system, is presented here:
NXP SoftwareThe software that runs on the NXP Rapid IoT device is a small modification of the “Rapid IoT Kit Out Of Box Demo” project. Mainly because the level of the CO2 is not sent through the Bluetooth protocol but the CCS811 air quality sensor acquires this information, a new block was introduced (see figure below) and configured in order to expose this information through a new characteristic (with the UUID: 1305b3ca-096e-4366-9f68-1ae8df01f27f) of the Bluetooth service (service UUID: 1305b3ca-096e-4366-9f68-1ae8df01f278).
All the configuration and connection of this block (BLE GATT Characteristic Element) can be “seen” and “touch” through the “Rapid IoT Kit Out Of Box Demo.atmo” source file. Please download the file from the link bit.ly/2T82P6o and imported into NXP Rapid IoT Studio.
To be able to upload the firmware into the NXP Rapid IoT device, please:
- Importing the downloaded file into the NXP Studio;
- Compile the project. Make sure you got "Project has been completed" message on the top;
- Download the firmware by pressing "Program Firmware" icon;
- Connect NXP Rapid IoT device (the SLN-RPK-NODE) to your computer using USB cable;
- Switch SLN-RPK-NODE into programming mode;
- Drop the firmware file to the newly mounted drive.
Or download the firmware file from here http://bit.ly/2IJkMng and upload it to the NXP Rapid IoT device (the SLN-RPK-NODE).
Android Smartphone SoftwareThe software for the Android was developed using MIT App Inventor web developer environment.
Thea application was developed having as a starting points three screens:
The second screen is a main one, from which the application was further developed. The program uses several non-visible components such as: a BluetoothLE component (available under Connectivity in the Palette), a ThinyDB (available under Storage in the Palette, used to: (a) send data between the second screen and the third screen and (b)to store the user selections – the information displayed in the user interface) and two Notifies elements used to present different warning information to the user.
When the program starts, and the second screen is initialized several database operations are executed (get the user selections and to set the initial values that will be displayed to “--”) and, in the end, the first screen is loaded – see the figure from below.
On the second screen you will need several components to be placed:
- A Button component named “ButtonScan” that will be pressed to scan for Bluetooth LE devices.
- A Button component named “ButtonConnect” that will be used to connect to a BLE device. Set the text to “Connect”.
- A Button component named “ButtonDisconnect” used to disconnect from a BLE device. Set the text to “Disconnect”.
- A Label component named “LabelStatus” with text set to “Status:”.
- A ListBLE that will show a list of BLE devices found during scanning.
Each of these buttons in the Blocks editor responds to the ”.click”events in a very specific way. For example, the ButtonScan start a scan for Bluetooth devices through the BluetoothLE_NXP_IoT.StartScanning block.
If a new device is fond, this devices will be saved in the list of BLE devices found during scanning:
When the ButtonConnect componentis pushed, the “global address” variable is filled by the BluetoothLE_NXP_IoT.FoundDeviceAddress. In general, FoundDeviceAddress takes an integer as its input. It uses this to index into the devices list and returns the address of the corresponding device. After saving the device address, call BluetoothLE_NXP_IoT.ConnectWithAddress with “global address” as the parameter. This allows your app to connect to one of the BLE devices listed in BluetoothLE_NXP_IoT.DeviceList. The device list is 1 indexed, meaning that if you want to connect to the first device that shows up, you must input index 1 and not 0.
Finally, you need to add the ability to disconnect from a Bluetooth LE device. To do this, drag the event handler ButtonDisconnect.Click and inside, call BluetoothLE_NXP_IoT.DisconnectWithAddress, passing in the global variable “address” as the parameter for the block. This will disconnect the BLE device. But previously unregister all the notification from the different characteristics of the NXP Rapid IoT device (the SLN-RPK-NODE).
When the checkbox for humidity (for example) is checked, internally the Android program registers the notification event to receives updates when one or more floated point numbers, associated with a specific characteristic of a specific service from a connected BluetoothLE device, are changed:
Due to the fact that several (in the example presented in the figure from below, only two: temperature and humidity) characteristics are associated with the same event BluetoothLE_NXP_IoT.FloatsReceived, each of them must be identified based on its own characteristic UUID using for this two "if" structures:
The entire source file of the Android application, developed in MIT App Inventor environment, can be downloaded from here: bit.ly/2Eor2v6.
Comments