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 the
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 the
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 :
- 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.
- 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).
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.
Java code executed by 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
Javacode information, click here !
- Open the TapNLink configuration project
iotize_studio/TapCO2.iotzwith IoTize Studio. For more information about Studio, click here.
- In the
User internal JVMto
Yesand set the
- In IoTize Studio, execute
javabuild to generate the
- Configure your
- 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.
TapNLink, you can now monitor the instantaneous value, or the percentage data that has been stored in the module.
Viewing in the app
- 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).