Connect the sensors to the Pioneer Kit
Connect the DHT11 temperature and humidity sensor to the Pioneer Kit as follows:
- VCC to 5V
- GND to GND
- Data pin to P10[0] pin of the Pioneer Kit
Connect the BMP180 barometric pressure sensor to the Pioneer Kit as follows:
- VCC to 3.3V
- GND to GND
- SDA to P12[0]
- SCL to P12[1]
Connect the 2x16 LCD display to the Pioneer Kit as follows:
- VSS to GND
- VDD to 5V
- RS to P0[1]
- RW to GND
- E to P0[0]
- D4 to P0[4]
- D5 to P0[5]
- D6 to P0[6]
- D7 to P0[7]
- A to 5V
- K to GND
Create a new project in PSoC Creator Create a new project in PSoC Creator and add the following components:
- UART
- I2C Master
- LCD
- DHT11
- BMP180
Configure the componentsConfigure the UART component to 115200 baud rate and connect it to the PSoC Kit's USB-UART bridge. Configure the I2C Master component to use P12[0] as SDA and P12[1] as SCL. Configure the LCD component to use 2x16 display and connect it to the corresponding pins.
Step 4: Write the codeHere's the code for the weather forecaster:
#include "project.h"
#include "stdio.h"
#include "stdlib.h"
#include "DHT11.h"
#include "BMP180.h"
int main(void)
{
CyGlobalIntEnable; /* Enable global interrupts. */
UART_Start(); /* Start the UART component */
LCD_Start(); /* Start the LCD component */
DHT11_Start(); /* Start the DHT11 component */
BMP180_Start(); /* Start the BMP180 component */
float temperature, humidity, pressure;
char str[16];
for(;;)
{
if(DHT11_GetStatus() == DHT11_READY)
{
temperature = DHT11_GetTemperature();
humidity = DHT11_GetHumidity();
}
if(BMP180_GetStatus() == BMP180_READY)
{
pressure = BMP180_GetPressure();
}
sprintf(str, "Temp: %.1f C", temperature);
LCD_Position(0,0);
LCD_PrintString(str);
sprintf(str, "Humidity: %.1f%%", humidity);
LCD_Position(1,0);
LCD_PrintString(str);
sprintf(str, "Pressure: %.1f kPa", pressure/1000);
UART_PutString(str);
CyDelay(5000);
}





Comments