![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
Temperature Sensor DHT readings to FRDMk64f
Fork of Hexi_Blinky_Example by
Diff: main.cpp
- Revision:
- 16:39e45e59677c
- Parent:
- 15:67a7cca7ae06
- Child:
- 17:690d692b29cb
--- a/main.cpp Fri Mar 31 15:03:37 2017 +0000 +++ b/main.cpp Wed Apr 05 19:17:14 2017 +0000 @@ -7,25 +7,25 @@ #define APIKEY JJAOBK32WOINKT00 //Put "Write key" of your channel in thingspeak.com #define IP "184.106.153.149" // IP Address of "api.thingspeak.com\" -#define WIFI_SSID "Batman2G" -#define WIFI_PASS "Alien12345" +#define WIFI_SSID "Redmi" +#define WIFI_PASS "akash12345" Serial FRDM_UART_Debug(USBTX,USBRX); -ESP8266 ESP_8266_UART(PTC17, PTC16, 115200); // UART for ESP8266 Wifi module +ESP8266 ESP_8266_UART(PTC15, PTC14, 115200); // UART for ESP8266 Wifi module // Options are TX-RX - PTB11 - PTB10 , PTC17 - PTC16 , PTC15 - PTC14 SPI SPI_Bus(PTD2,PTD3,PTD1); // (MOSI MISO CLK)setup SPI interface -DigitalOut SPI_CS_AMM(PTC3); -DigitalOut SPI_CS_VOLT(PTC2); +DigitalOut SPI_CS_AMM(PTB9); +DigitalOut SPI_CS_VOLT(PTA1); I2C I2C_Bus(PTE25,PTE24); -AnalogIn AN_Thermo(PTB3); // Thermocouple Analog Input +AnalogIn AN_Thermo(PTB2); // Thermocouple Analog Input -DigitalIn DG_Motion(PTB2); // Motion module Digital Input +DigitalIn DG_Motion(PTB3); // Motion module Digital Input -DHT DHT_Temp_Hum(PTC11,DHT22); //DHT Sensor +DHT DHT_Temp_Hum(PTA2,DHT22); //DHT Sensor const int Light_I2C_Addr = 0x88; @@ -67,7 +67,7 @@ I2C_Bus.frequency(100000); // set required i2c frequency FRDM_UART_Debug.printf("Start sampling data\r\n"); // Starting point - + wait(1); while (1) { Amm_Out = 0; @@ -77,8 +77,6 @@ Temp_Out = 0; Hum_Out = 0; Motion_Out = 0; - - wait(15); // Copy Motion values @@ -105,7 +103,7 @@ SPI_CS_AMM = 1; - Temp_f_1 = (( SPI_High_byte & 0x1f ) << 7 ) | (( SPI_Low_byte >> 1 )); + Temp_f_1 = (( SPI_High_byte & 0x1F ) << 7 ) | (( SPI_Low_byte >> 1 )); Temp_f_2= (float)(( Temp_f_1 * 1.00 ) / 4096.00 ); // Converting to volts @@ -175,7 +173,7 @@ Temp_i_1= I2C_Cmd[0]>>4; Temp_i_2= (I2C_Cmd[0]-(Temp_i_1<<4))*256+I2C_Cmd[1]; - for(loop_count = 0,Temp_i_3 = 1 ; loop_count < Temp_i_1 ; Temp_i_3*=2,loop_count++); + for(loop_count = 0,Temp_i_3 = 1 ; loop_count < Temp_i_1 ; Temp_i_3 = Temp_i_3 * 2,loop_count++); Light_Out= (Temp_i_2 * Temp_i_3) / 100; @@ -222,6 +220,7 @@ Temp_i_1 = DHT_Temp_Hum.readData(); if (Temp_i_1 == 0) // Read success { + //wait_ms(1000); Temp_f_1 = DHT_Temp_Hum.ReadTemperature(FARENHEIT); Temp_f_2 = DHT_Temp_Hum.ReadHumidity(); } @@ -240,6 +239,8 @@ FRDM_UART_Debug.printf("Sending this information to thingspeak.com\r\n"); ESP_8266_TX_Data(); + wait(15); + } }