sensoresp/include/sensor_hs1101.h

43 lines
1.1 KiB
C
Raw Normal View History

2021-11-04 16:52:39 +00:00
#ifndef SENSOR_HS1101_H
#define SENSOR_HS1101_H
#include "sensordata.h"
#include <Homie.h>
class Sensor_HS1101
{
private:
HomieNode *sensorNode; //reference to HomieNode
struct sensordata data; //struct values are changed in setup()
bool init_ok;
int hs1101pin;
float getHumidity_HS1101(int pin);
int get_mapped(const unsigned int* _in, const unsigned int* _out, byte size,int val);
#define HUMARRAYSIZE 11
//from HS1101 datasheet https://www.parallax.com/sites/default/files/downloads/27920-Humidity-Sensor-Datasheet.pdf
const unsigned int out_humidity[HUMARRAYSIZE] = {1000,900,800,700,600,500,400,300,200,100,0}; //*10, gets later devided by 10
const unsigned int in_hs1101frequency[HUMARRAYSIZE] = {6033,6186,6330,6468,6600,6728,6853,6976,7100,7224,7351};
//unsigned int out_humidity[HUMARRAYSIZE];
//unsigned int in_hs1101frequency[HUMARRAYSIZE];
public:
Sensor_HS1101(int pin);
void init();
void setSettings(float minchange, unsigned long senddelaymax, unsigned long readdelay);
void advertise(HomieNode& p_sensorNode);
void sensorloop();
};
#endif