M5Unit-ENV 1.2.1 git rev:ad1926a
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Pages
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);
91 bool wakeup();
93
96
105 const uint16_t hours, const uint32_t duration = scd41::SET_AUTOMATIC_SELF_CALIBRATION_INITIAL_PERIOD_DURATION);
113 bool readAutomaticSelfCalibrationInitialPeriod(uint16_t& hours);
123 const uint16_t hours, const uint32_t duration = scd41::SET_AUTOMATIC_SELF_CALIBRATION_STANDARD_PERIOD_DURATION);
131 bool readAutomaticSelfCalibrationStandardPeriod(uint16_t& hours);
133
134protected:
135 virtual bool is_valid_chip() override;
136};
137
138namespace scd41 {
140namespace command {
141// Low power single shot - SCD41 only
142constexpr uint16_t MEASURE_SINGLE_SHOT{0x219d};
143constexpr uint16_t MEASURE_SINGLE_SHOT_RHT_ONLY{0x2196};
144constexpr uint16_t POWER_DOWN{0x36e0};
145constexpr uint16_t WAKE_UP{0x36f6};
146constexpr uint16_t SET_AUTOMATIC_SELF_CALIBRATION_INITIAL_PERIOD{0x2445};
147constexpr uint16_t GET_AUTOMATIC_SELF_CALIBRATION_INITIAL_PERIOD{0x2340};
148constexpr uint16_t SET_AUTOMATIC_SELF_CALIBRATION_STANDARD_PERIOD{0x244e};
149constexpr uint16_t GET_AUTOMATIC_SELF_CALIBRATION_STANDARD_PERIOD{0x234b};
150
151} // namespace command
153} // namespace scd41
154
155} // namespace unit
156} // namespace m5
157#endif
bool measureSingleshotRHT(scd4x::Data &d)
Request a single measurement temperature and humidity.
Definition unit_SCD41.cpp:62
bool measureSingleshot(scd4x::Data &d)
Request a single measurement.
Definition unit_SCD41.cpp:46
bool readAutomaticSelfCalibrationStandardPeriod(uint16_t &hours)
Red the standard period for ASC correction.
Definition unit_SCD41.cpp:161
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:115
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:146
bool wakeup()
Wake up.
Definition unit_SCD41.cpp:91
bool readAutomaticSelfCalibrationInitialPeriod(uint16_t &hours)
Read the duration of the initial period for ASC correction.
Definition unit_SCD41.cpp:130
bool powerDown(const uint32_t duration=scd41::POWER_DOWN_DURATION)
Power down.
Definition unit_SCD41.cpp:78
Top level namespace of M5stack.
For SCD41.
Unit-related namespace.
SCD40 Unit for M5UnitUnified.