Hi everyone,
I have around this O2 sensor Gravity: Electrochemical Oxygen / O2 Sensor (0-25%Vol, I2C) - DFRobot
In reality it is a small board that allows to measure O2 % from the internal sensor through some I2C commands. It is possible to attach it to the new SCK V2.3 and incorporate the new measurement to the online platform?
I guess you have already a guide for that? Let me know the links or some tips.
Best regards
Rafa
Hi!
Currently, we do not have a detailed guide, but I can guide you with some steps (I will consolidate it). You would need to evaluate if the effort of the implementation compensates the hardware choice, but should be fine for the sensor you have. I put general steps, and some specific examples that relate to your case.
Implementing the sensor on firmware
-
Find a library from that has methods to implement the hardware in question. In this particular case, the DF Robot Wiki already points to the library.
-
Add it to the
platformio.ini
file in the SAM folder of the firmware. See here an where: https://github.com/fablabbcn/smartcitizen-kit-21/blob/master/sam/platformio.ini#L24 -
Add a define to include the sensor for your configuration (see the examples) smartcitizen-kit-2x/lib/Sensors/Sensors.h at master · fablabbcn/smartcitizen-kit-2x · GitHub (we need to tell you an ID for it to be stored on the platform - see below)
-
Mostly all the implementation should happen in
SCKAux.h
andSCKAux.cpp
. Make sure that as you implement this, also add the define from the previous point. This is a workaround to avoid filling up the flash memory of the MCU
You can see example definitions on: smartcitizen-kit-2x/sam/src/SckAux.h at master · fablabbcn/smartcitizen-kit-2x · GitHub
Here, you need to:
- Include the library from previous item smartcitizen-kit-2x/sam/src/SckAux.h at master · fablabbcn/smartcitizen-kit-2x · GitHub
- Add the object definitions (like this one: smartcitizen-kit-2x/sam/src/SckAux.h at master · fablabbcn/smartcitizen-kit-2x · GitHub) mostly from the library.
Specifically, you need wrapping methods to:
-
Start the sensor: smartcitizen-kit-2x/sam/src/SckAux.h at master · fablabbcn/smartcitizen-kit-2x · GitHub
and smartcitizen-kit-2x/sam/src/SckAux.cpp at master · fablabbcn/smartcitizen-kit-2x · GitHub -
Stop it: smartcitizen-kit-2x/sam/src/SckAux.h at master · fablabbcn/smartcitizen-kit-2x · GitHub and smartcitizen-kit-2x/sam/src/SckAux.cpp at master · fablabbcn/smartcitizen-kit-2x · GitHub
-
Get reading: smartcitizen-kit-2x/sam/src/SckAux.h at master · fablabbcn/smartcitizen-kit-2x · GitHub and smartcitizen-kit-2x/sam/src/SckAux.cpp at master · fablabbcn/smartcitizen-kit-2x · GitHub
-
Write down the addresses: smartcitizen-kit-2x/sam/src/SckAux.h at master · fablabbcn/smartcitizen-kit-2x · GitHub
Sending data to Smart Citizen
We can create a sensor for you on the platform and tell you the ID. You need to include it on the Sensor.h from above.
Sending data to your own server
As per the configuration of the server, if you have an MQTT server already, the data can be directed directly to yours by using the Shell and configuring the MQTT server (see help command). After this commit the customisation of the MQTT and NTP servers is supported.
The json structure follows something like the defined here, so on your side you should check that it complies with your data ingestion format. Check also the topics of the mqtt and how they are defined here.