TapCO2
This project creates a connected CO2 sensor using a TapNLink module. The project uses TapNLink's embedded Java Virtual Machine (JVM) as the application processor. The JVM runs a simple Java program retrieves data from sensor.
*** DISCLAIMER ***
This example is not a product. This example is not Certified, Qualified, Approved, or Recommended for any commercial use, or for any use by the general public.
Note: Before starting, learn how TapNLink and the associated tools work in this Getting Started.
This project is on GitHub !
The project has 4 folders:
-
app_generated/TapCO2.apk
: The sources for the mobile application that was automatically generated by the IoTize mobile app build server. -
java/TapCO2.java
: The Java code that is executed by theJVM
. -
iotize_studio/TapCO2.iotz
: The IoTize Studio configuration file that is used to configure the TapNLink for this demo. -
doc
: The illustrations and the readme file for theJava
code.
The Main Components
The main components in this project, and where you can purchase them are:
- The TapNLink communication module is available from these distributors.
- A CO2 sensor (STC31-R3) from Sensirion connected to the Tap by I²C.
How it Works
The components are placed in a plastic case (vertical cylinder) with a few holes for aeration. The pictures below show the hardware set up :
TapCO2 components
- Tap and CO2 Sensor are separated so that the heat released by Tap does not affect the recovered values (but the heat from the regulator impacts the measurement).
The CO2 sensor
- The co2 sensor is powered by the 5V power pack USB battery.
TapNLink
- The Tap is connected to the CO2 sensor by I2C and is powered by the sensor board. Note that the regulator is (unfortunately) on the same board that the sensor. This is NOT a good idea because the quality of the measurement depends on the temperature. But it makes things easier since we use a 5V USB rechargeable battery (power pack).
Overview
General view of the project
The general diagram shows the battery connected to the sensor. The TapNLink module reads the information from the sensor with I2C communication. This data is viewed in an app that is generated automatically by the IoTize software tools based on the configuration of the TapNLink.
Schematic
Electrical diagram
Java Code
In the Java
code executed by the JVM
, the onCheck()
method is called periodically (the period is specified in the TapNLinkVar
construct). With this method, we get an image of the power by considering the differences of the pulse counts during the elapsed time period.
- For more
Java
code information, click here !
IoTize Studio
- Open the TapNLink configuration project
iotize_studio/TapCO2.iotz
with IoTize Studio. For more information about Studio, click here. - In the
IoTize_Studio/Tap
section, setUser internal JVM
toYes
and set the.java
file pathjava/TapCO2.java
. - In IoTize Studio, execute
java
build to generate the.bcb
file. - Configure your
TapNLink
withIoTize Studio
:- Setup the connection to your TapNLink
- Set the IoT Platform (MQTT) information.
- Click on the
Configure
button and wait for the end of the configuration process.
- Reboot the TapNLink to apply the new configuration.
Running the 'TapCO2' App
- Because this app has not been published on the app stores, you have to install it manually. See how this is done here.
- After your circuit is properly connected, and your TapNLink configured, launch the mobile app. The fastest way is to approach your mobile phone (with NFC enabled) to the plastic casing. NFC will launch the app and connect the mobile to the TapNLink automatically.
TapCO2 connected
- With
TapNLink
, you can now monitor the instantaneous value, or the percentage data that has been stored in the module.
Viewing in the app
Known issues
- we have designed the plastic case for a specific battery: Duracell Powerbank 3350 mAh. This battery features an automatic power off when the consumption is too low, and the problem was to increase the consumption in order to avoir the automatic power off... The solution we found consists in configuring the TapNLink in Access Point (the consumption is higher for AP than for Station mode) and to discard any 'low power' option. Unfortunately, the device is not able to sendMQTT messages (alarm to the Cloud) when it is in Access Point mode... For sure, it would be better to replace the battery by another that does not switch off the power!
- because of the 3.3V regulator, the temperature of the sensor board is too high. It impacts on the quality measurement (even more because of the previous issue).
- in the same way, it would be much better to get the current atmospheric pressure from the Cloud. But the first issue cancel any direct internet connection...
In conclusion, the measurement are neither very accurate nor very stable. Replacing the battery would be a first good step (it would allow to reduce the overall consumption, the temperature of the sensor board and finally it would provide an access to the internet).