M5Unit-ENV 1.5.0 git rev:6195a2c
Loading...
Searching...
No Matches
unit_SCD41.hpp
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2024 M5Stack Technology CO LTD
3 *
4 * SPDX-License-Identifier: MIT
5 */
10#ifndef M5_UNIT_ENV_UNIT_SCD41_HPP
11#define M5_UNIT_ENV_UNIT_SCD41_HPP
12
13#include "unit_SCD40.hpp"
14
15namespace m5 {
16namespace unit {
21namespace scd41 {
23// Max command duration(ms)
24// For SCD40/41
25constexpr uint32_t POWER_DOWN_DURATION{1};
26constexpr uint32_t GET_AUTOMATIC_SELF_CALIBRATION_INITIAL_PERIOD_DURATION{1};
27constexpr uint32_t SET_AUTOMATIC_SELF_CALIBRATION_INITIAL_PERIOD_DURATION{1};
28constexpr uint32_t GET_AUTOMATIC_SELF_CALIBRATION_STANDARD_PERIOD_DURATION{1};
29constexpr uint32_t SET_AUTOMATIC_SELF_CALIBRATION_STANDARD_PERIOD_DURATION{1};
30
32} // namespace scd41
33
38class UnitSCD41 : public UnitSCD40 {
39 M5_UNIT_COMPONENT_HPP_BUILDER(UnitSCD41, 0x62);
40
41public:
42 explicit UnitSCD41(const uint8_t addr = DEFAULT_ADDRESS) : UnitSCD40(addr)
43 {
44 auto ccfg = component_config();
45 ccfg.clock = 400 * 1000U;
46 component_config(ccfg);
47 }
48 virtual ~UnitSCD41()
49 {
50 }
51
54
61 bool measureSingleshot(scd4x::Data& d);
71 bool measureSingleshotRHT(scd4x::Data& d);
73
76
83 bool powerDown(const uint32_t duration = scd41::POWER_DOWN_DURATION);
90 bool wakeup();
92
95
104 const uint16_t hours, const uint32_t duration = scd41::SET_AUTOMATIC_SELF_CALIBRATION_INITIAL_PERIOD_DURATION);
111 bool readAutomaticSelfCalibrationInitialPeriod(uint16_t& hours);
121 const uint16_t hours, const uint32_t duration = scd41::SET_AUTOMATIC_SELF_CALIBRATION_STANDARD_PERIOD_DURATION);
128 bool readAutomaticSelfCalibrationStandardPeriod(uint16_t& hours);
130
131protected:
132 virtual bool is_valid_chip() override;
133};
134
135namespace scd41 {
137namespace command {
138// Low power single shot - SCD41 only
139constexpr uint16_t MEASURE_SINGLE_SHOT{0x219d};
140constexpr uint16_t MEASURE_SINGLE_SHOT_RHT_ONLY{0x2196};
141constexpr uint16_t POWER_DOWN{0x36e0};
142constexpr uint16_t WAKE_UP{0x36f6};
143constexpr uint16_t SET_AUTOMATIC_SELF_CALIBRATION_INITIAL_PERIOD{0x2445};
144constexpr uint16_t GET_AUTOMATIC_SELF_CALIBRATION_INITIAL_PERIOD{0x2340};
145constexpr uint16_t SET_AUTOMATIC_SELF_CALIBRATION_STANDARD_PERIOD{0x244e};
146constexpr uint16_t GET_AUTOMATIC_SELF_CALIBRATION_STANDARD_PERIOD{0x234b};
147
148} // namespace command
150} // namespace scd41
151
152} // namespace unit
153} // namespace m5
154#endif
bool measureSingleshotRHT(scd4x::Data &d)
Request a single measurement temperature and humidity.
Definition unit_SCD41.cpp:67
bool measureSingleshot(scd4x::Data &d)
Request a single measurement.
Definition unit_SCD41.cpp:51
bool readAutomaticSelfCalibrationStandardPeriod(uint16_t &hours)
Read the standard period for ASC correction.
Definition unit_SCD41.cpp:166
bool writeAutomaticSelfCalibrationInitialPeriod(const uint16_t hours, const uint32_t duration=scd41::SET_AUTOMATIC_SELF_CALIBRATION_INITIAL_PERIOD_DURATION)
Write the duration of the initial period for ASC correction.
Definition unit_SCD41.cpp:120
bool writeAutomaticSelfCalibrationStandardPeriod(const uint16_t hours, const uint32_t duration=scd41::SET_AUTOMATIC_SELF_CALIBRATION_STANDARD_PERIOD_DURATION)
Write the standard period for ASC correction.
Definition unit_SCD41.cpp:151
bool wakeup()
Wake up.
Definition unit_SCD41.cpp:96
bool readAutomaticSelfCalibrationInitialPeriod(uint16_t &hours)
Read the duration of the initial period for ASC correction.
Definition unit_SCD41.cpp:135
bool powerDown(const uint32_t duration=scd41::POWER_DOWN_DURATION)
Power down.
Definition unit_SCD41.cpp:83
Top level namespace of M5Stack.
For SCD41.
Unit-related namespace.
SCD40 Unit for M5UnitUnified.