README.md 6.77 KB
Newer Older
1
2
# CO<sub>2</sub> Ampel

Eric Duminil's avatar
Eric Duminil committed
3
*CO<sub>2</sub> Ampel* is an open-source project, written in C++ for [ESP8266](https://en.wikipedia.org/wiki/ESP8266) or [ESP32](https://en.wikipedia.org/wiki/ESP32).
4
5
6
7
8

It measures the current CO<sub>2</sub> concentration (in ppm), and displays it on an LED ring.

The room should be ventilated as soon as one LED turns red.

Eric Duminil's avatar
Eric Duminil committed
9
## Ampel web-conf
Eric Duminil's avatar
Eric Duminil committed
10

Eric Duminil's avatar
Eric Duminil committed
11
Ampel-firmware + [IotWebConf](https://github.com/prampec/IotWebConf).
Eric Duminil's avatar
Eric Duminil committed
12

Eric Duminil's avatar
Eric Duminil committed
13
This is beta software, and bugs are expected! There is not much free RAM left on ESP8266, so the ESP might crash randomly. :-/
Eric Duminil's avatar
Eric Duminil committed
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28

* You probably need to update `config.h`. There's a new template in `config.public.h`.
* Every parameter can be set in the web-configuration, so you don't have to modify `config.h` once it's been updated.
* Flash
* Start the *Ampel*
* It should blink turquoise, to indicate *Access Point* mode
* Connect with a laptop/smartphone to ESPxxxxxx WiFi.
* Open a browser, it should bring you to the *Ampel* web-page.
* The usual web-page will be shown. You can click on "Configuration".
* You'll have to set an *Ampel* password with at least 8 characters.
* You can set WiFi SSID + Password if you want. It will then try to connect if you disconnect from the *Access Point*.
* If you don't specify SSID + Password, the *Ampel* will simply stay in *Access Point* mode.
* The *Ampel* password will be required if a connection fails, and the *Access Point* starts again.
* The *Ampel* password will be needed (with user 'admin') to connect to the web-page once the *Ampel* is connected to WiFi.
* It might be necessary to reset the *Ampel* after changing important parameters.
Eric Duminil's avatar
Eric Duminil committed
29
* You can rename the *Ampel*. This name will be used instead of ESPxxxxxx for CSV files and the mDNS address. You'll get a new CSV file after renaming, which can be convenient, e.g. to indicate at which location the measurements were made.
Eric Duminil's avatar
Notes    
Eric Duminil committed
30
31
* If you forgot the password, you can send `reset_config` as command, and `reset` the ampel.
* If you disabled WiFi, you can enable it again with `wifi 1`.
Eric Duminil's avatar
Doc    
Eric Duminil committed
32
33
* It's also possible to specify WiFi SSID and password in the console, with `ssid wifi_ssid_here` and `pwd wifi_password_here` commands.
* You can enable CSV by clicking on "+CSV", or disable it by clicking on "Disable CSV".
Eric Duminil's avatar
Notes    
Eric Duminil committed
34
35
* The same applies to MQTT and LoRaWAN.
* If you disable a set, the parameters are still saved, and will appear again once the service is enabled.
Eric Duminil's avatar
Eric Duminil committed
36

Eric Duminil's avatar
Eric Duminil committed
37
38
39
40
## Features

The *CO<sub>2</sub> Ampel* can:

Eric Duminil's avatar
Eric Duminil committed
41
* Display CO<sub>2</sub> concentration on LED ring.
Eric Duminil's avatar
Eric Duminil committed
42
* Allow calibration.
Eric Duminil's avatar
Eric Duminil committed
43
44
45
* Get current time over [NTP](https://en.wikipedia.org/wiki/Network_Time_Protocol)
* Send data over [MQTT](https://en.wikipedia.org/wiki/MQTT).
* Send data over [LoRaWAN](https://en.wikipedia.org/wiki/LoRa#LoRaWAN).
Eric Duminil's avatar
Eric Duminil committed
46
* Display measurements and configuration on a small website.
Eric Duminil's avatar
Eric Duminil committed
47
* Log data to a [CSV](https://en.wikipedia.org/wiki/Comma-separated_values) file, directly on the ESP flash memory.
Eric Duminil's avatar
Eric Duminil committed
48
* Accept many interactive commands.
Eric Duminil's avatar
Eric Duminil committed
49

50
51
52
53
## Hardware Requirements

* [ESP8266](https://en.wikipedia.org/wiki/ESP8266) or [ESP32](https://en.wikipedia.org/wiki/ESP32) microcontroller (this project has been tested with *ESP8266 ESP-12 WIFI* and *TTGO ESP32 SX1276 LoRa*)
* [Sensirion SCD30](https://www.sensirion.com/en/environmental-sensors/carbon-dioxide-sensors/carbon-dioxide-sensors-co2/) "Sensor Module for HVAC and Indoor Air Quality Applications"
Eric Duminil's avatar
Eric Duminil committed
54
* [NeoPixel Ring - 12](https://www.adafruit.com/product/1643), or [NeoPixel Ring - 16](https://www.adafruit.com/product/1463) (experimental)
55

Eric Duminil's avatar
Eric Duminil committed
56
57
See the [documentation](https://transfer.hft-stuttgart.de/gitlab/co2ampel/ampel-documentation) for more info.

58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
## Software Requirements

* [PlatformIO](https://platformio.org/)
or
* [Arduino IDE](https://www.arduino.cc/en/software)

## Installation

* If `config.h` does not exist, copy it from `config.public.h`
* Modify `config.h`, e.g. for measurement time-steps, WiFi access, MQTT, NTP and web-server.

### PlatformIO

PlatformIO can be run from [VSCODE](https://platformio.org/install/ide?install=vscode), [Eclipse CDT](https://www.eclipse.org/cdt/) or console:

```bash
make upload board=esp8266 && make monitor # For ESP8266
```
```bash
make upload board=esp32 && make monitor # For ESP32
```

### Arduino IDE

* All the libraries are included in this repository. No need to install anything via *Library Manager*.

* Add your board to the [board manager](https://github.com/esp8266/Arduino#installing-with-boards-manager). Either ESP8266:

        http://arduino.esp8266.com/stable/package_esp8266com_index.json

  or ESP32:

        https://dl.espressif.com/dl/package_esp32_index.json

* Choose the correct board in *Tools > Board > ...*
* Choose the correct *Flash size* (e.g. "Flash Size : 4MB (1MB FS, OTA:~1019kB)" for *ESP8266 ESP-12 WIFI*)

* *Verify*
* *Upload*
* *Tools > Serial Monitor*

Eric Duminil's avatar
Eric Duminil committed
99
100
101
102
## Available commands

In Arduino IDE *Serial Monitor* or PlatformIO *Monitor*, type `help` + <kbd>Enter</kbd> in order to list the available commands:

Eric Duminil's avatar
Eric Duminil committed
103
* `ap!` (Forces access point mode).
Eric Duminil's avatar
Eric Duminil committed
104
105
* `auto_calibrate 0/1` (Disables/enables autocalibration).
* `calibrate 600` (Starts calibration process, to given ppm).
Eric Duminil's avatar
Eric Duminil committed
106
* `calibrate` (Starts calibration process).
Eric Duminil's avatar
Eric Duminil committed
107
* `calibrate! 600` (Calibrates right now, to given ppm).
Eric Duminil's avatar
Eric Duminil committed
108
* `co2 1500` (Sets CO<sub>2</sub> level, for debugging).
Eric Duminil's avatar
Eric Duminil committed
109
110
111
112
* `color 0xFF0015` (Shows color, specified as RGB, for debugging).
* `csv 60` (Sets CSV writing interval, in s).
* `format_filesystem` (Deletes the whole filesystem).
* `free` (Displays available heap space).
Eric Duminil's avatar
Eric Duminil committed
113
* `led 0/1` (Turns LEDs on/off).
Eric Duminil's avatar
Eric Duminil committed
114
115
116
* `local_ip` (Displays local IP and current SSID).
* `lora 300` (Sets LoRaWAN sending interval, in s).
* `mqtt 60` (Sets MQTT sending interval, in s).
Eric Duminil's avatar
Eric Duminil committed
117
* `pwd abc` (Sets WiFi password to 'abc').
118
* `reset` (Restarts the ESP).
Eric Duminil's avatar
Eric Duminil committed
119
* `reset_config` (Resets the complete IotWeb config).
Eric Duminil's avatar
Eric Duminil committed
120
* `reset_scd` (Resets SCD30).
Eric Duminil's avatar
Eric Duminil committed
121
* `save_config` (Saves the config to EEPROM).
Eric Duminil's avatar
Eric Duminil committed
122
123
124
* `send_local_ip` (Sends local IP and SSID via MQTT. Can be useful to find sensor).
* `set_time 1618829570` (Sets time to the given UNIX time).
* `show_csv` (Displays the complete CSV file on Serial).
Eric Duminil's avatar
Eric Duminil committed
125
* `ssid name` (Sets SSID to 'name').
Eric Duminil's avatar
Eric Duminil committed
126
* `timer 30` (Sets measurement interval, in s).
Eric Duminil's avatar
Eric Duminil committed
127
* `wifi 0/1` (Turns Wifi on/off).
Eric Duminil's avatar
Eric Duminil committed
128
129
130
131
* `wifi_scan` (Scans available WiFi networks).

The commands can be sent via the Serial interface, from the webpage or via MQTT.

132
133
## Authors

134
135
136
137
138
139
 * Eric Duminil (HfT Stuttgart)
 * Robert Otto (HfT Stuttgart)
 * Myriam Guedey (HfT Stuttgart)
 * Tobias Gabriel Erhart (HfT Stuttgart)
 * Jonas Stave (HfT Stuttgart)
 * Michael Käppler
140
141

## Contributing
Eric Duminil's avatar
Eric Duminil committed
142
143
144
145

* Merge requests are welcome, and should be based on the `develop` branch.
* The `develop` branch gets merged into the `master` once it has been sufficiently tested.
* For major changes, please open an issue first to discuss what you would like to change.
146
147
148

## License

Eric Duminil's avatar
Eric Duminil committed
149
Copyright © 2021, [HfT Stuttgart](https://www.hft-stuttgart.de/)
150
[GPLv3](https://choosealicense.com/licenses/gpl-3.0/)