Measuring air flow, relative humidity & temperature, then showing results at TFT

Dependencies:   FT800_2 HYT mbed

Air flow is measured with FS7 sensor by IST-AG, humidity & temperature are measured by HYT-271 sensor by IST. Graphs displayed it TFT by Riverdi via graphical controller FFT801.

Hardware

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.

/media/uploads/Ksenia/4_-22-.jpg

You have to connect VDD to BLVDD at Break Out Board if you use the board:

/media/uploads/Ksenia/4_-5-.jpg

MCU-board to HYT sensor

MCU-board is connected to sensor via I2C. Remember to use pull-up resisrors there:

/media/uploads/Ksenia/freshpaint-20-2016.09.16-10.37.03.png

MCU-board to FS7 sensor

MCU-board is connected to sensor via FS flowmodule. FS-flowmodul is a PCB implementing bridge circuit which is necessary for FS7.

https://habrastorage.org/files/b25/056/287/b250562871614b4ca4286af885f1fa24

https://habrastorage.org/files/72d/04c/cac/72d04ccac07b4fcfb436e0ffbac73066

Revision:
0:3f440c2facb0
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Thu Mar 16 08:58:18 2017 +0000
@@ -0,0 +1,88 @@
+#include "mbed.h"
+#include "FT_Platform.h"
+#include "HYT.h"
+#include "Display.h"
+
+HYT         SENSOR(PD6, PD7); // sda, scl [efm32hg_stk3400]
+FT800       TFT(PE10, PE11, PE12, PE13, PA1, PB11); // mosi, miso, sck, ss, int, pd [efm32hg_stk3400]
+AnalogIn    ADC(PD4); // [efm32hg_stk3400]
+
+Display     disp(&TFT);
+
+uint8_t     humidity;
+float       flow;
+int8_t      temperature;
+
+#define HUMIDITY_CORRECTION         15
+#define TEMPERATURE_CORRECTION      -1
+
+/*************************************************************************************************************************/
+float calculateFlow(uint16_t resultADC)
+{
+    uint16_t flowVoltage;
+    if ((resultADC / 1000) - 32 >= 0) {
+        flowVoltage = (resultADC / 1000) - 32;
+    } else {
+        flowVoltage = 0;
+    }
+      
+    float voltageToSpeed[31] = { 0, 0, 0, 0.1, 0.1, 0.1, 0.2, 0.2, 0.3, 0.3,
+                                 0.4, 0.5, 0.6, 0.7, 0.8, 1.0, 1.2, 1.5, 2.0, 2.3, 2.8, 3.2, 3.9,
+                                 4.5, 5.1, 5.8, 6.5, 7.4, 8.2, 9.1, 10
+                               };
+    float flowSpeed = voltageToSpeed[flowVoltage];
+
+    return flowSpeed;
+}
+
+/*************************************************************************************************************************/
+uint8_t calculateHumidity(uint8_t humidityFromHYT)
+{
+    uint8_t humidityFinal;
+    if (humidityFromHYT + 15 >= 100) {
+        humidityFinal = 100;
+    } else {
+        humidityFinal = humidityFromHYT + HUMIDITY_CORRECTION;
+    }
+
+    return humidityFinal;
+}
+
+/*************************************************************************************************************************/
+int8_t calculateTemperature(int8_t temperatureFromHYT)
+{
+    return temperatureFromHYT + TEMPERATURE_CORRECTION;
+}
+
+/**************************************************************************************************************************/
+int main()
+{
+    disp.Calibration();
+
+    disp.LoadImagesAndFonts();
+    disp.HandleAllBitmaps();
+
+    disp.showHumidity = 1;
+    disp.showFlow = 1;
+    disp.showTemperature = 1;
+
+    // first point
+    SENSOR.MRCommand();
+    wait_ms(100);
+    SENSOR.DFCommand();
+    
+    while (1) {
+        SENSOR.MRCommand();
+
+        humidity = calculateHumidity((uint8_t) SENSOR.humidity);
+        flow = calculateFlow(ADC.read_u16());
+        temperature = calculateTemperature((int8_t) SENSOR.temperature);
+
+        disp.UpdateDataToDraw(humidity, temperature, flow);
+        disp.MainScreen();
+
+        disp.GetTouch();
+
+        SENSOR.DFCommand();
+    }
+}