Skip to content
Snippets Groups Projects
Code owners
Assign users and groups as approvers for specific file changes. Learn more.
Sht85.hpp 1.31 KiB
//
// Created by zoe on 11/4/22.
//

#ifndef ESPCAM_SHT85_HPP
#define ESPCAM_SHT85_HPP

#include "ForteSensor.hpp"
#include "MeasurementData.hpp"
#include "Message.hpp"
#include "Pinout.hpp"
#include "RTClib.h"    // adafruit/RTClib @^2.1.1
#include "SHTSensor.h" // sensirion/arduino-sht@^1.2.2
#include "SPI.h"
#include "Time.hpp"
#include "esp_log.h"
#include <Arduino.h>
#include <Wire.h>

// Pin definitions for I2C (SHT85, RTC)
//  This is different from the pins on the ESP32-C3-DevKit boards!
#define SDA 12
#define SCL 13

struct out_data_sht85 {
	float temperature = 0.0;
	float humidity = 0.0;
};

class Sht85 : public ForteSensor<out_data_sht85> {
  public:
	void setup() override;
	out_data_sht85 readData() override;
	std::list<Message> buildMessages() override;
	[[nodiscard]] SensorInformation getSensorInformation() const override;

  private:
	SHTSensor sht; // I2C address: 0x44
	out_data_sht85 data;
	const SensorInformation sensorInformation{"SHT85", Protocol::I2C};
	void readSHT();

	enum class MeasurementType { TEMPERATURE, HUMIDITY };

	// enum to string
	std::map<MeasurementType, const char *> measurementTypeToString = {{MeasurementType::TEMPERATURE, "TEMPERATURE"},
	                                                                   {MeasurementType::HUMIDITY, "HUMIDITY"}};
};

#endif // ESPCAM_SHT85_HPP