Skip to content

Commit

Permalink
Only update error screen with new errors to save battery, general cle… (
Browse files Browse the repository at this point in the history
#16)

* Only update error screen with new errors to save battery, general cleanup, prep for next release

* Fixing previous error storage and printout, lowering battery error threshold, adjusting temperature setting for battery fuel gauge

* Updating README with SCD-40 recommendation, hardware options on Amazon, updated pseudocode

* Entering deep sleep after initialization to avoid draining battery

* Updating images to reflect firmware changes

* Removing unused constant, adjusting test display pattern to fill screen
  • Loading branch information
danwahl authored Nov 29, 2022
1 parent 1dcf046 commit 41ee3cd
Show file tree
Hide file tree
Showing 5 changed files with 168 additions and 159 deletions.
38 changes: 23 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,22 +31,24 @@ Most of the COTS parts are from [Adafruit](https://www.adafruit.com/) (hence the
|:---:|:----:|:----------------------------------------------------------------------------------------------:|:----------:|:-----------:|
| 1 | 5477 | Adafruit Esp32-S3 Feather With 4Mb Flash 2Mb Psram - Stemma Qt / Qwiic | 17.5 | 17.5 |
| 1 | 4814 | Adafruit 2.13 Hd Tri-Color Eink / Epaper Display Featherwing - 250X122 Rw Panel With Ssd1680 | 24.95 | 24.95 |
| 1 | 5190 | Adafruit SCD-41 - True CO2 Temperature and Humidity Sensor | 59.5 | 59.5 |
| 1 | 5187 | Adafruit SCD-40 - True CO2 Temperature and Humidity Sensor | 49.5 | 49.5 |
| 1 | 4494 | Adafruit DPS310 Precision Barometric Pressure/Altitude Sensor - STEMMA QT/Qwiic | 6.95 | 6.95 |
| 1 | 2011 | Lithium Ion Battery - 3.7V 2000mAh | 12.5 | 12.5 |
| 2 | 4399 | STEMMA QT / Qwiic JST SH 4-Pin Cable - 50mm Long | 0.95 | 1.9 |
| | | | | 123.30 |
| | | | | 113.30 |

In addition, you'll need several fasteners. Most come in the [Adafruit 3299](https://www.adafruit.com/product/3299) kit, but this is overkill (only 20 out of the 380 pieces are used), so you may have better luck at a hardware store. Either way, you'll need:
(Note that the [SCD-41](https://www.adafruit.com/product/5190) can be used as a drop-in replacement.)

In addition, you'll need several fasteners. Most come in the [Adafruit 3299](https://www.adafruit.com/product/3299) kit, but this is overkill (only 20 out of the 380 pieces are used), so you may have better luck at a hardware store [or](https://smile.amazon.com/gp/product/B018TH1NEM) [on](https://smile.amazon.com/gp/product/B012TAF8AK) [Amazon](https://smile.amazon.com/gp/product/B08F1XFQ7R). Either way, you'll need:

| Qty | Part Description | Material |
|:---:|:-----------------------------:|----------|
| 8 | M2.5 Hex Nut | Nylon |
| 8 | M2.5 x 6mm Screw | Nylon |
| 4 | M2.5 x 6mm M-F Hex Standoff | Nylon |
| 4 | M2.3 x 5mm Self-Tapping Screw | Steel |
| 4 | M2.6 x 5mm Self-Tapping Screw | Steel |

I also bought the self-tapping screws in [a kit](https://smile.amazon.com/dp/B081DVZMHH), but there are almost certainly cheaper options.
I also bought the self-tapping screws in [a kit](https://smile.amazon.com/dp/B081DVZMHH), but there are [other](https://smile.amazon.com/gp/product/B00GDYDCC0) [options](https://smile.amazon.com/gp/product/B01L7PDGXO) too.

Finally, you'll need to 3D print the "top" and "bottom" pieces. If you don't have a 3D printer, either ask someone who does (these are relatively easy parts), visit to a local maker space (maybe even [your library?](https://www.chipublib.org/maker-lab/)), or use a service like [(3D)Hubs](https://www.hubs.com/). (Note: I recommend printing the "top" upside down, both to get a smooth finish on the outside and to avoid unnecessary overhangs.)

Expand All @@ -68,11 +70,11 @@ First assemble the top and bottom of the case separately:
### Bottom

1. Use 4 M2.5 x 6mm screws to attach the 4 M2.5 x 6mm M-F hex standoffs to the inside of the case (using the holes that border the the sensor slot)
2. Attach the 4-pin STEMMA QT cables to either side of the SCD41 board
3. Press the SCD41 board onto the four exposed standoffs, with the sensor facing "out" of the case, and use 2 M2.5 hex nuts to secure to the bottom two standoffs
4. Connect the DPS310 to the 4-pin STEMMA QT cable on the "right" (when facing the non-sensor side) of the SCD41 board
5. Use 2 M2.5 hex nuts to attach the DPS310 to the top two standoffs, back-to-back with the SCD41 so that the sensor is facing "in" (note: first apply Kapton/electrical tape to the back of the DPS310 to avoid shorting to the SCD41)
6. Carefully insert the battery, which should fit snugly lengthwise, and adjacent to the bottom standoffs holding the SCD41 (note: you can use double-sided tape securely affix the battery to the case)
2. Attach the 4-pin STEMMA QT cables to either side of the SCD4x board
3. Press the SCD4x board onto the four exposed standoffs, with the sensor facing "out" of the case, and use 2 M2.5 hex nuts to secure to the bottom two standoffs
4. Connect the DPS310 to the 4-pin STEMMA QT cable on the "right" (when facing the non-sensor side) of the SCD4x board
5. Use 2 M2.5 hex nuts to attach the DPS310 to the top two standoffs, back-to-back with the SCD4x so that the sensor is facing "in" (note: first apply Kapton/electrical tape to the back of the DPS310 to avoid shorting to the SCD4x)
6. Carefully insert the battery, which should fit snugly lengthwise, and adjacent to the bottom standoffs holding the SCD4x (note: you can use double-sided tape securely affix the battery to the case)

![adanet-assembly-bottom](images/adanet-assembly-bottom.jpg)

Expand All @@ -93,6 +95,8 @@ The Arduino firmware (adanet-co2-monitor.ino) has been tested using the followin
- ESP32 Arduino (v2.0.5)
- Sensirion I2C SCD4x (v0.3.1)

### Development environment

To prepare your development environment:

1. Install [Arduino IDE](https://www.arduino.cc/en/software/) (and optionally the [VS Code extension](https://github.com/microsoft/vscode-arduino))
Expand All @@ -102,6 +106,8 @@ To prepare your development environment:
5. In the same menu, change "USB Mode" to "Hardware CDC and JTAG" (see [here](https://github.com/espressif/arduino-esp32/issues/6762)) and "Upload Mode" to "UART0/Hardware CDC"
6. Plug in your Feather using the USB-C connector, and set the Port to match the one assigned by your OS (e.g. `COM5` on Windows, `/dev/ttyACM0` on Linux)

### Loading firmware

To load the firmware on the device:

1. Clone this repository somewhere sensible (Arduino projects are typically located in the `$HOME/Documents/Arduino` folder)
Expand All @@ -110,13 +116,15 @@ To load the firmware on the device:
4. In Arduino (or VS Code using the [Arduino extension](https://github.com/microsoft/vscode-arduino)), open the arduino-co2-monitor.ino file and click Upload (or run the Arduino: Upload task in VS Code)
5. Once finished, you may have to manually press the Reset button again to start the firmware

### Pseudocode

And that's it! The firmware does the following once every 180 seconds (the [fastest update rate](https://learn.adafruit.com/adafruit-2-13-eink-display-breakouts-and-featherwings/usage-expectations) supported by the E Ink screen):

1. Enable the SCD41 and DPS310 sensors, start measurements
2. Light sleep for 5 seconds while the initial CO₂ and pressure measurements are taking place
3. Update SCD41 with ambient pressure (the [nominal reason](http://www.co2meters.com/Documentation/AppNotes/AN149-Senseair-Pressure-Dependence.pdf) for the DPS301 sensor!)
4. Discard initial measurements (as per [SCD41 Low Power Operation](https://sensirion.com/media/documents/077BC86F/62BF01B9/CD_AN_SCD4x_Low_Power_Operation_D1.pdf)) and light sleep for another 5 seconds
5. Read battery charge state from the LC709203F sensor
1. Enable the SCD4x and DPS310 sensors, start measurements
2. Read battery charge state from the LC709203F sensor
3. Light sleep for 5 seconds while the initial CO₂ and pressure measurements are taking place
4. Update SCD4x with ambient pressure (the [nominal reason](http://www.co2meters.com/Documentation/AppNotes/AN149-Senseair-Pressure-Dependence.pdf) for the DPS310 sensor!)
5. Discard initial measurements (as per [SCD4x Low Power Operation](https://sensirion.com/media/documents/077BC86F/62BF01B9/CD_AN_SCD4x_Low_Power_Operation_D1.pdf)) and light sleep for another 5 seconds
6. Save new measurements and disable I2C power (turns off all sensors)
7. Enable the E Ink screen and update the display using the saved measurements
8. Deep sleep for ~170 seconds and repeat
Loading

0 comments on commit 41ee3cd

Please sign in to comment.