Main components:
- Bluetooth 4.0 LE module,
- humidity and temperature sensor,
- DC-DC 14-3.3V converter,
- camper's single-board computer with a 4.0 Bluetooth USB dongle and MQTT broker installed,
- the camper's router.
Artekit SI7021 humidity and temperature sensor was used to measure microclimate parameters within a camper. This sensor was connected to the Bluetooth LE controller that translates the microclimate data via the camper's MQTT broker to any computer or camper's crew gadget within the camper's network. Looks like, but wasn’t tested, any microclimate module with Silicon Labs Si7021 chip will work like described here too.
Main part of actions and all software in this article is analogous to acts for Ventilation fan' controller, it is a good idea to make them both together.
The Bluetooth Nordic nRF52832 4.0 LE module was used (the version with no block for user firmware flashing). In one time this module controls the microclimate sensor and broadcasts (advertise in terms of Bluetooth) measured humidity and temperature parameters via Bluetooth. Looks like, but wasn’t tested, the Bluetooth module with Nordic nRF52840 will work like described here too.
Any DC-DC converter can step down power from 14V to 3.3V for both the Bluetooth Nordic nRF52832 4.0 LE module and Artekit SI7021 sensor.
All settings were made via Windows PC (64 bit is preferred) with toolchain was installed on:
Then in to file C:\Users\%username%\Documents\nRF5\nRF5SDK15209412b96\components\toolchain\gcc\Makefile.windows
being opened in a text editor were updated strings ("/" here is right):
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. The BMP programmer was connected to the PC via USB. Then Device Manager was opened on the PC:
Win+R
devmgmt.msc, Enter
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 it's COM-port number was noted.
The Black Magic Probe programmer was connected to Bluetooth Nordic nRF52832 module with Test Hooks Clips for Logic Analyzers as this wiring diagram with only four wires:
Black Magic Probe programmer pin | nRF52832 BT module pin |
---|---|
TMS | 33 (SWDIO) |
TCK | 32 (SWDCLK) |
VCC 3.3V | 10 (VCC) |
GND | 24 (GND) |
Next steps were on the PC in order to flash Bluetooth Nordic nRF52832 module:
Win+R
cmd, Enter
Then in the PC command-line terminal were entered one by one:
mkdir c:\Users\%username%\temp
cd C:\Users\%username%\Documents\nRF5\nRF5SDK15209412b96\examples\ble_peripheral\ble_app_uart\pca10040\s132\armgcc
make
cd C:\Users\%username%\Documents\nRF5\nRF5SDK15209412b96\examples\ble_peripheral\ble_app_uart\pca10040\s132\armgcc\_build
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
cd C:/Users/%username%/temp
arm-none-eabi-gdb
(gdb) target extended-remote com4
Note: here com4 is the COM-port number of "Black Magic GDB Server" that was noted above. If the number of COM-port is more than 10, then \\.\COM1x is used instead of COMx.
(gdb) monitor swdp_scan
(gdb) attach 1
(gdb) file out.hex
(gdb) y
(gdb) load C:/Users/%username%/temp/out.hex
(gdb) quit
(gdb) y
From this point, the Bluetooth Nordic nRF52832 module was ready for work with the Artekit SI7021 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 Artekit SI7021 as this wiring diagram with only two wires:
nRF52832 BT module pin | Artekit SI7021 pin |
---|---|
3 (P0.27) | SCL |
2 (P0.26) | SDA |
All components were soldered together at the piece of prototype circuit panel having metalized holes.
The power for this microclimate sensor served by the camper's onboard 12V line. To take this power, the 2-pole screw connector was placed on the circuit panel. One latching normally-open button was placed on the circuit panel to switch this sensor on/off.
The 14-3.3V DC-DC converter was connected as this wiring diagram:
the 14-3.3V 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 + | Bluetooth Nordic nRF52832 module pin 10 (VCC),
Artekit SI7021 pin VCC |
DC OUT - | Bluetooth Nordic nRF52832 module pin 24 (GND),
Artekit SI7021 pin GND |
The assembled sensor was equipped with the suitable case and was installed in the camper.
This can be viewed like a lifehack, but taking in account the vibrations protection, the case being done on the principle of "toothpaste tube carton box" is one pretty design. This one can be made from plastic sheet 0.5 mm thickness. When case design/select need provide the maximum distance between a DC-DC converter, that can be heating up, and the temperature sensor.
The case of this sensor was with holes for mounting, for the power button and for free air convection.
The sensor was connected to the onboard 12V line.
Once powered this sensor, 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;
4636 - is humidity;
01CA - is CO2 parameter (not null if this microclimate sensor is soldered together with the ventilation fan's controller).
This data will change from time to time.
In order to convert RAW-data of sensors broadcast by Bluetooth Nordic nRF52832 in MQTT standard messages, that can be used for all computers and camper's crew gadgets within the camper's network, 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 configured for not sleeping, not hibernate. The Node.js with packages were installed on this computer as described in the 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 to 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;
- 192.168.1.71 the IP of the computer where MQTT broker is:
crontab -e
@reboot sleep 10; sudo modprobe -r btusb; sleep 10; sudo modprobe btusb
*/1 * * * * cd /home/USERNAME; sudo timeout 50 node CA_THC_bt2mqtt b131abcd7195142be0120808817f198d CA/THC mqtt://192.168.1.71 >> /dev/null
# and at least one empty line should be at the end of the file!
Ctrl+O, Enter, Ctrl+X
Note: the string "@reboot sleep 10; sudo modprobe -r btusb; sleep 10; sudo modprobe btusb" in the crontab file is optional, is for use if a Bluetooth LE dongle, being extremely low power consumption, has no a stable start.
No later than 1 minute and then each 1 minute, any computer and any camper's crew gadget within the camper's network can receive standard MQTT topics named CA/THC with human-read substring.
Then the Nginx web server was installed as described next.
The Nginx web server can be installed on any Linux-computer within the camper's network but this computer must have static IP for easy access to him. It is possible to set a static IP in this computer, but it is more reliable to configure a static IP in the camper's router settings. Also possible but not a good idea to install this server (with specified web port-number) on the same computer where the Camper's NAS was deployed with static IP as the NAS's work is resource expensive and not all single-board computers can serve both the NAS and the web server.
In this case, the Nginx web server 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 configured for not sleeping, not hibernate. This was that one computer where before was deployed all together the MQTT broker and the 4.0 Bluetooth USB dongle, the Node.js with packages.
All settings for Nginx were made via Windows PC. In some cases will need to switch off the PC firewall while settings.
When the Linux-computer chosen for Nginx was connected to the camper's router, it was available in the PC terminal via PuTTY over IP on port 22 with root user and password. The camper's router had Internet connection at this time.
Were entered via PuTTY terminal on PC:
apt-get install nginx
systemctl enable nginx
This files set was unzipped on the PC. One of the unzipped file index.nginx-debian.html was opened in Geany and line with MQTT broker IP was changed as in the camper's network tuned. This was the string MQTTbroker = "192.168.1.71";
Then file index.nginx-debian.html was saved in Geany and no other modification needed to be made within.
The unzipped files set and the just changed file index.nginx-debian.html was transferred in /var/www/html folder of the Linux-computer where Nginx just installed. The easy way to transfer these files to the Linux computer is to use WinSCP.
From this point, the start Nginx web-page can be opened with typing 192.168.1.71 in the Internet browser on any computer or gadget in the camper's network (an iOS needs to be switched on the javascript support, that one typically switched off).
No later than 1 minute, the data will chart. Data of CO2 charts will, if had made the ventilation fan' controller as described in this series of articles.
Note: few first usage of this application must be with Internet connection in order for buffering Java libraries being used. In further the Internet connection is not necessarily.
How to design a free website - See it