To use the temperatur-controlled chambers, following steps have to be taken. Please note the difference in MQTT broker usage when using a single or multiple chambers.
## Broker for single chamber
When using a single chamber, only one MQTT broker is required. Therefore using mosquitto_master.conf is sufficient. However, two could also be used, if you want to use the same architecture in both cases.
```
mosquitto -c mosquitto_master.conf
```
## Broker for multiple chambers
When using more than one chamber, a master broker should be used as in the previous chapter, that connects all chambers. Each chamber will have their own, local MQTT broker that can be started with, which connects to the master broker.
```
mosquitto -c mosquitto_slave.conf
```
Make sure to edit the configuration accordingly:
- Set `remote_clientid`
- Set host and port in `address`
- Set connection name (optional)
## How to use a temperature-controlled chamber
How to use the chambers...
### Requirements
To start the chamber, check out the git and install both `mosquitto` and the required python packages:
```
apt install mosquitto
pip3 install -r requirements.txt
```
### Usage
To start the chamber simply run the following command:
Depending on the sensors used in your setup, at least on of `SHT21` and `DS1820` should be included in the module list. Make sure you create a configuration file (modules.conf) to configure the ambient and chamber's temperature sensors.
NOTE: Instead of an ambient temperature sensor, you can also specify `AmbientTemperature`. See modules below for additional configuration options.
To use the temperatur-controlled chambers, following steps have to be taken. Please note the difference in MQTT broker usage when using a single or multiple chambers.
This desribes how to use the Climate Chambers that were presented in [this paper](https://dl.acm.org/doi/abs/10.1145/3267204.3267207).
## Broker for single chamber
## Requirements
When using a single chamber, only one MQTT broker is required. Therefore using mosquitto_master.conf is sufficient. However, two could also be used, if you want to use the same architecture in both cases.
### Required Hardware
1) Raspberry PI
2) Chamber Shield
3) One of these temperature sensors: SHT21 or DS18B20
4) Programmable Power supply, e.g. KORAD
5) Climate Chamber
```
mosquitto -c mosquitto_master.conf
```
### Required Software
THIS branch!
## Broker for multiple chambers
## Setting up the chambers
When using more than one chamber, a master broker should be used as in the previous chapter, that connects all chambers. Each chamber will have their own, local MQTT broker that can be started with, which connects to the master broker.
### Preparing the PI
In order to prepare the PI to run all required software follow these steps. You may set up multiple PIs at the same time, but this manual just desribes the case of setting up a single one. In addition the setup assumes that the user of the Raspi is named *pi*!
```
mosquitto -c mosquitto_slave.conf
```
#### Setting up the hardware
1) Turn on a programmable power supply an set it to 0V
2) Connect the power supply via USB to the RASPI
3) Put a shield on the Raspi that should be used for controlling the chambers
4) Connect the outputs of the power supply to the shield
5) Connect the sensors and peltier elements of the chamber to the PI
Make sure to edit the configuration accordingly:
#### Deploying the software
1) Download this branch on a PC
2) Set up an SSH Key and copy it to the Raspi
3) Change into the *ansible* folder of this branch
4) Modify *ansible.hosts* to your requirements. The first line **MUST** stay unchanged. Every following line represents a device you want to set up as a chamber controller, i.e. the Raspis. The first word for a line is the DNS-Name or IPv6 address of the device. The second name ist the hostname of the device.
5) Run *make ansible* on the terminal
6) Restart the Raspi
- Set `remote_clientid`
- Set host and port in `address`
- Set connection name (optional)
#### Configuring the software
1) Connect to the Raspi via SSH
2) Check via *supervisord status* if the Demon *module_loader* ist running. If not: check why!
3) Move to the directory */home/pi/lctc-software/util*
4) Run *setup.py* to create a configuration file for the chamber modules
5) Copy the newly created file *modules.cfg* into */home/pi/lctc-software/*
6) Restart the demon *module_loader*
## How to use a temperature-controlled chamber
## Using the chamber
How to use the chambers...
### How it works
The chamber is controller through several modules that communicate with each other using MQTT. Normally all requirements are automatically installed via ansible.
In order to control the chamber commands have to be sent to the modules via MQTT.
### Requirements
The necessary modules are started automatically by the demon called *module_loader*, which is set up by ansible. The configuration of this demon is stored at */etc/supervisor/lctc.conf*. The default setup uses the **DS18B20** temperature sensor. If you want to change that you have to change the parameters of the demon.
To start the chamber, check out the git and install both `mosquitto` and the required python packages:
The following section describe the most important modules and what their respective jobs are.
```
apt install mosquitto
pip3 install -r requirements.txt
```
#### Sensor
The sensor modules are basically drivers. They read out the temperature data on a regular basis and post it under their respective topic (check the drivers for more details). These are then requested by other modules in order to get the current temperature of the chamber. Currently their are modules for the SHT21 and the DS18B20.
### Usage
#### Chamber
The chamber module is the core component of the controller. It requests the current temperature and adjusts the power supply voltage and current direction in order to reach the target temperature. This requires some input data, e.g. which sensor provides the temperature inside the chamber. Thos data is stored inside the *modules.cfg* file which needs to be located in the same directory as the module_loader with the chamber module is executed. If you follow the steps as explained in the tutorial this should not be a problem.
To start the chamber simply run the following command:
### How to use
The chamber module provides one topic which is called *chamber/<HOSTNAME>/temp*. Transmitting a message to this topic causes the target temperature for the chamber to change. The script *examples/chamber.py* provides an example on how to send and request data from the chambers. It should work without a problem when run on the Raspi that has been set up as the chamber controller. When running on another device to control the chamber remotely it may require some changes, e.g. changing the MQTT topics respectively.
The chamber temperature is provided by the topic that is descirbed in the config file. If you followed the tutorial this file should be */home/pi/lctc-software/modules.cfg*. The parameters should be called **ChamberTemperatureTopic**.
This section should provide some help when trying to set up the chamber but running into some problems.
Depending on the sensors used in your setup, at least on of `SHT21` and `DS1820` should be included in the module list. Make sure you create a configuration file (modules.conf) to configure the ambient and chamber's temperature sensors.
### The demon is running but nothing seems to work
There may be multiple problems with the demon. The *stdout* and *stderr* files are redirected to the files */home/pi/module_loader.stdout.log* and */home/pi/module_loader.stderr.log*. Please consult these.
NOTE: Instead of an ambient temperature sensor, you can also specify `AmbientTemperature`. See modules below for additional configuration options.
### There seems to be a problem with MQTT
Unfortunatly MQTT seems to change a lot. While a few years ago MQTT worked out of the box for these chambers, now it requires more configuration. Therefore we did not provide explicit information on how to set up MQTT in the tutorial above. However allowing anonymous connections seemed to fix it for us. If there are any more problems you should google on how to set up MQQT with the version you are using.
### The modules.cfg script does not seem to work for me
The script was designed to only work for the **SHT21** and **DS18B20** sensors. Any other sensors are not supported. If the script can't find any sensors connected to the Raspi this may be caused by the UDEV rules not beeing set up correctly. They are stored in the repository under *ansible/setup/*. There should be two .rules files. Please make sure that these rules are set up on your PI correctly. If they are, the hardware you are using, be it the sensors or the shield, may be broken.
# Modules
### How do I start additional or different modules
For this you need to modify the config file of the demon, which is stored at */etc/supervisor/lctc.conf*.