![](/media/cache/profiles/9f0876a200701e5fdece2e58aa965574.jpg.50x50_q85.jpg)
HYT humidity & temp sensor polling / showing received data at TFT with capacitive touchscreen
Dependencies: FT800_2 HYT mbed
HYT humidity & temperature sensor: polling and showing data at TFT via graphical controller FT800/FT801.
Hardware
- HYT-271 / HYT-221 / HYT-939 humidity and temperature sensor by IST-AG
- TFT module uxTouch by Riverdi
- Break Out Board 20 by Riverdi
- Any mbed platform with I2C interface, SPI interface and 2 free GPIO for PD and INT signals
For documentation on the FT800 library, please refer to the library pages.
Connection
MCU-board to TFT-module
MCU-board is connected to TFT-module via Break Out Board. You need 6 signals to connect: SCK, MOSI and MISO are connected to a SPI channel, SS is the chip select signal, PD work as powerdown and INT for interrupts from TFT to MCU.
You have to connect VDD to BLVDD at Break Out Board if you use the board:
MCU-board to HYT sensor
MCU-board is connected to sensor via I2C. Remember to use pull-up resisrors there:
Подробнее в статьях Как перестать бояться и полюбить mbed [Часть 1 - 5] на https://habrahabr.ru/users/uuuulala/topics/
Diff: statistics.h
- Revision:
- 0:5d3131d1b142
diff -r 000000000000 -r 5d3131d1b142 statistics.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/statistics.h Fri Oct 07 11:08:19 2016 +0000 @@ -0,0 +1,47 @@ +#include "mbed.h" + +#ifndef STATISTICS_H_ +#define STATISTICS_H_ + +#define INIT_STATISTICS_NUMBER 32767 +#define DELTA_HUMIDITY 6 +#define DELTA_TEMPERATURE 1 +#define TEMPERATURE_MULTIPLIER 10 + +/************************************************************************************************************************** +************************** User class for calculate statistics for last 24 hrs ******************************************** +**************************************************************************************************************************/ + +class Statistics +{ +public: + // xxxx24hrs[][] arrays contains all 24-hrs statistics data: + // 1. xxxx24hrs[0][0...287] - Average values calculated for each five-minute interval + // 2. xxxx24hrs[1][0...287] - Minimums calculated for each five-minute interval + // 2. xxxx24hrs[2][0...287] - Maximums calculated for each five-minute interval + // p.s. there are 288 five-minute intervals in 24 hours + + short int humidity24hrs[3][288]; + short int temperature24hrs[3][288]; + + uint64_t UpdateStatistics(float humidity, float temperature, uint64_t seconds, uint64_t changeSecondsOffset); + void InitValues(float humidity, float temperature); + +private: + + // functions called every second to update average value, minimum and maximum in current five-minute interval + void CalculateTemperature(float temperature, short int secondsIn5min); + void CalculateHumididty(float humidity, short int secondsIn5min); + // function called every 5 minutes to add new value to xxxx24hrs[][] arrays + uint64_t Update24hrsData(uint64_t changeSecondsOffset); + + // counter of five-minute intervals (0...287) + short int Counter24hrs; + // values for calculations "inside" five-minute interval + short int humidity5min[300], temperature5min[300]; + int humidity5minAverage, temperature5minAverage; + int humidity5minSum, temperature5minSum; + short int humidity5minMax, humidity5minMin, temperature5minMax, temperature5minMin; +}; + +#endif /* STATISTICS_H_ */ \ No newline at end of file