- CO2 sensor,
- DC-DC 14-5V converter for CO2 sensor,
- Bluetooth 4.0 LE module,
- DC-DC 5-3.3V converter for Bluetooth 4.0 LE module,
- 12V Bluetooth relay module for the camper's ventilation fan,
- camper's ventilation fan,
- DC-DC stabilizer 2-3A 14-12V for Bluetooth relay module and for the camper's ventilation fan,
- camper's single-board computer with a 4.0 Bluetooth USB dongle and MQTT broker installed,
- the camper's router.
Idea is monitoring the CO2 (carbon dioxide) concentration of air within the camper, then switching on a camper's ventilation fan when the CO2-parameter is more then an upper limit and switch off the ventilation fan when the CO2-parameter is less then a lowest limit. CO2 sensors are very inerted, therefore, measurements every 2 min is enough. The CO2 sensor must be placed in the camper at the altitude where crew are, not at the floor of the camper and not under the camper's ceil.
Main part of actions and all software in this article is analogous to acts for Microclimate sensor, is good idea to make them both together.
Senseair S8 004-0-0053 sensor was used for monitoring the CO2-parameter.
The CO2 sensor was equipped with Bluetooth Nordic nRF52832 4.0 LE module. In one time this module controls CO2 sensor and broadcast (advertise in therms of Bluetooth) the measured CO2-parameter via Bluetooth. Looks like, but was't tested, the Bluetooth module with Nordic nRF52840 will works like here described too.
Any DC-DC converter can steps down power from 14V to 5V for the CO2 sensor. Another one need for convert 5V to 3.3V for the Bluetooth module (14V to 3.3V can be used too).
The camper's ventilation fan was equipped with 12V Bluetooth 2.1 noLE single relay module based on Bolutek BK3231 chip in this case.
Any DC-DC 2-3A converter can stabilize 12-14V power in to 12V power for the Bluetooth relay module and for the camper's ventilation fan.
The silent 12V Deep Cool XFAN 120 case fan was used for ventilation.
Commands for switch on/off the camper's ventilation, on the base of the CO2 sensor's data, can be by a script running on the Camper assistant works with MQTT broker (as described here) or by single commands from camper's crew gadgets (will be described in later articles).
All settings were made via Windows PC (64 bit is preferred) with toolchain was installed on:
GNU_INSTALL_ROOT := C:/Program Files (x86)/GNU Tools ARM Embedded/8 2018-q4-major/bin/
GNU_VERSION := 8.2.1
GNU_PREFIX := arm-none-eabi
Black Magic Probe (BMP) programmer was used for the software flashing of the Bluetooth Nordic nRF52832 module in this case, this one programmer can be used for the flashing any Bluetooth nRF controllers for the Camper assistant. BMP programmer was connected to the PC via USB. Then on the PC was opened Device Manager:
In Device Manager in "Ports (COM & LPT)" topic was found "Black Magic GDB Server" device (this name is in Windows 7, but in Windows 10 here will be two "USB Serial Device", between them the device with minor COM-port number is sought for), and his COM-port number was noted.
|Black Magic Probe programmer pin||nRF52832 BT module pin|
|VCC 3.3V||10 (VCC)|
Next steps was on the PC in order to flash Bluetooth Nordic nRF52832 module:
Then in the PC command-line terminal was entered one by one:
copy nrf52832_xxaa.hex C:\Users\%username%\temp
copy C:\Users\%username%\Documents\nRF5\nRF5SDK15209412b96\components\softdevice\s132\hex\s132_nrf52_6.1.0_softdevice.hex C:\Users\%username%\temp
cd C:\Program Files (x86)\Nordic Semiconductor\nrf5x\bin\
mergehex -m c:\Users\%username%\temp\s132_nrf52_6.1.0_softdevice.hex c:\Users\%username%\temp\nrf52832_xxaa.hex -o c:\Users\%username%\temp\out.hex
(gdb) target extended-remote com4
Note: here com4 is COM-port number of "Black Magic GDB Server" that was noted above. If number of COM-port more than 10, then \\.\COM1x is used instead of COMx.
(gdb) monitor swdp_scan
(gdb) attach 1
(gdb) file out.hex
(gdb) load C:/Users/%username%/temp/out.hex
From this point, the Bluetooth Nordic nRF52832 module was been flashed for works with Senseair S8 004-0-0053 sensor. The Black Magic Probe programmer was disconnected to Bluetooth Nordic nRF52832 module and to the PC.
The Bluetooth Nordic nRF52832 module was soldered to Senseair S8 004-0-0053 as this wiring diagram with only two wires:
|nRF52832 BT module pin||Senseair S8 004-0-0053 pin|
All components was soldered together at the piece of prototype circuit panel (green colored about having metalized holes).
The power for this ventilation fan controller served by the camper's onboard 12V line. For take this power, the 2-pole screw connector was placed on the circuit panel. One latching normally-opened button was placed on the circuit panel for switch this controller on/off.
Small normally-opened tact push button was placed on the circuit panel for the Senseair S8 004-0-0053 calibration, that need to make time to time as specified for this sensor (described bottom).
The 14-5V DC-DC converter was connected as this wiring diagram:
|the 14-5V DC-DC converter pin||other devices pins|
|DC IN +||Via power on/off button to pole "+" of the screw connector|
|DC IN -||Pole "-" of the screw connector|
|DC OUT +||Senseair S8 004-0-0053 G+ (no more 5,2V allowed on this pin),|
5-3.3V DC-DC converter +
|DC OUT -||Senseair S8 004-0-0053 G0,|
Senseair S8 004-0-0053 bCAL via the normally-opened tact push button,
5-3.3V DC-DC converter -
The 5-3.3V DC-DC was connected with nRF52832 BT module as this wiring diagram:
|the 5-3.3V DC-DC converter pin||nRF52832 BT module pin|
|DC OUT +||Bluetooth Nordic nRF52832 module pin 10 (VCC)|
|DC OUT -||Bluetooth Nordic nRF52832 module pin 24 (GND)|
The assembled controller was equipped with the suitable case and was installed in the camper on the altitude of the bed, where the camper's crew are, for the must relevant CO2 measuring.
This can be viewed like a lifehack, but taking in account the vibrations protection, the case being done on the principle of "toothpaste tube's carton box" is one pretty design. This one can makes from plastic sheet 0.5 mm thickness.
The case of controller was with holes for mounting, for the power button, for the calibration button and for free air convection.
The controller was connected to the onboard 12V line. The Senseair S8 004-0-0053 can produce relevant CO2 parameter after 2-3 minutes as powered on.
For Senseair S8 004-0-0053 the calibration prescribed every 4 month or before usage if was not in use more then 4 month. Calibration makes on open air, desirable not in town but in a clean air. It is considered that clean air is with 400 ppm CO2. When the camper will in a clean air, will need to push tact button, described above, for 4-5 seconds while this controller is working. Looks like if CO2 parameters measured by S8 is low then 400 ppm, the S8 can fall in error, in order to avoid this, need to calibrate S8 in so fresh (clean) air as possible.
Once powered this controller, the data broadcasts the Bluetooth Nordic nRF52832 can be examined with application nRF Connect for Mobile (Android/iOS).
Where is 6E60463601CA the data of sensors in hexadecimal RAW format displays at this moment:
6E60 - is temperature (not null if this CO2 controller soldered together with Microclimate sensor);
4636 - is humidity (not null if this CO2 controller soldered together with Microclimate sensor);
01CA - is CO2 parameter.
This data will changes time to time.
In order to convert RAW-data of sensors broadcasts by Bluetooth Nordic nRF52832 in MQTT standard messages, thats can be used for switch on/off the camper's ventilation fan, the set of MQTT scripts was used.
In this case, all together this set of MQTT scripts, the MQTT broker and the 4.0 Bluetooth USB dongle was deployed on Cubietruck clone with Armbian OS (Ubuntu version) installed and had static IP 192.168.1.71 in the camper's network. This computer was tuned for not sleep, not hibernate. The Node.js with packages was installed on this computer as described in same topic about MQTT broker.
The easy way to install the set of MQTT scripts is to use WinSCP on PC. In some cases will need switch off the PC firewall while settings. In WinSCP, a connection was established to the single-board computer via SCP protocol by host name (IP), port 22, root username and password.
The set of MQTT scripts being unzipped was copied via WinSCP to the /home/USERNAME folder (not to root folder).
Then in the PC was established connection to the single-board computer via PuTTY by host name (IP 192.168.1.71), port 22, root username and password. Bottom listed commands were entered, where
- /home/USERNAME is folder where the set of MQTT scripts was copied;
- b131abcd7195142be0120808817f198d is UUID of Bluetooth Nordic nRF52832 module that was obtained as described above;
- AB:A2:B6:56:34:02 is MAC of the BK3231 Bluetooth 2.1 (noLE) relay module as describes bottom here;
- 800 is CO2 parameter if will achieve, the relay of BK3231 Bluetooth module will closed for switch on the camper's ventilation fan. This parameter can be changed feels like;
- 500 is CO2 parameter if will achieve, then relay of BK3231 Bluetooth module will opened for switch off the camper's ventilation fan. This parameter can be changed feels like;
- 192.168.1.71 the IP of the computer in the camper's network where MQTT broker is:
*/1 * * * * cd /home/USERNAME; sudo timeout 50 node CA_THC_bt2mqtt b131abcd7195142be0120808817f198d CA/THC mqtt://192.168.1.71 >> /dev/null
*/6 * * * * cd /home/USERNAME; sudo hcitool dc AB:A2:B6:56:34:02; sudo node CA_VF_relay AB:A2:B6:56:34:02 500 800 mqtt://192.168.1.71 CA/THC >> /dev/null
# and at least one empty line should be at the end of the file!
Ctrl+O, Enter, Ctrl+X
No later then 1 minute and then each 1 minute, any computer and any camper's crew gadget within the camper's network can recieve standard MQTT topics named CA/THC with human-read sub-string and that can be used for switch on/off the camper's ventilation fan.
In Device Manager in "Ports (COM & LPT)" topic was found and noted the COM-port number of the USB-TTL (RS-232) adapter.
The USB-TTL (RS-232) adapter was temporary connected to the 12V Bluetooth single relay module based on Bolutek BK3231 chip as this wiring diagram:
|USB-TTL (RS-232) adapter pin||12V Bluetooth single relay module|
based on Bolutek BK3231 pin
Within Arduino IDE was chosen COM-port of the attached to the PC USB-TTL (RS-232) adapter, that one was noted above. Then was opened Port Monitor, the 9600 baud and Both NL&CR options was chosen.
Then next AT-commands was sended to the Bolutek BK3231 module via Arduino IDE Port Monitor:
|AT-command was sended||What the mean the AT-command and how must be modified|
|AT+NAMECAVF||Set name of Bluetooth module. Here is CAVF for example only. Can be any up to six chars. Good if this name will be random.|
|AT+PIN7733||Set pin-code of Bluetooth module. Here is 7733 for example only. Can be any up to six chars. Good if this name will be random.|
|AT+COD001f00a||Set local class of Bluetooth device for works in role of the receiver of commands.|
|AT+ROLE0||Set local role of Bluetooth device for works as the receiver of commands.|
|AT+IAC9E8B34||Set identifier of the BK3231 Bluetooth 2.1 (noLE) module. Here is 9E8B34 (hexadecimal). Must be one from the diapazone 0x9E8B34-0x9E8B3F, and must be unique from other the Camper assistant's Bluetooth 2.1 (noLE) modules.|
|AT+LADDR=AB:A2:B6:56:34:02||Set the MAC (global unique identifier) of the BK3231 Bluetooth 2.1 (noLE) module. Here AB:A2:B6:56:34:02 for example only. Must be one generated unique.|
Then the USB-TTL (RS-232) adapter was disconnected to the PC USB and was unwired from the 12V Bluetooth single relay module. The USB-TTL (RS-232) adapter will not need more for this case.
The 12V Bluetooth single relay module, the 12V fan and the DC-DC stabilizer 14-12V was wiring all together as this picture:
Any single-pole switch can be used for switch off the ventilation fan relay for time between journeys.
The ventilation fan with single relay Bluetooth module and with single-pole switch was installed in rear part of the camper where ventilation clapan is.
After this scheme was assembled and powered from camper's onboard 12V line, the fan was switches on/off depends on parameters of CO2 measured by the Senseair S8 sensor.