2759 views|1 replies

1662

Posts

0

Resources
The OP
 

Temperature and humidity program based on msp430f5529 [Copy link]

The experimental project uses MSP430F5529 as the main control, WiFi module to transmit data, DHT11 module to detect temperature and humidity, and also detects light conditions and toxic gas detection functions. The

microcontroller source program is as follows:

  1. /*
  2. * light.c
  3. *
  4. * Created on: September 27, 2018
  5. * Author: Wade
  6. * call:13594729060
  7. */
  8. #include <msp430f5529.h>
  9. #include "HAL_Dogs102x6.h"
  10. #include "NumberShow.h"
  11. #include "delay.h"
  12. #include "DHT11.h"
  13. #include "light.h"
  14. #include "gas.h"
  15. #include "led.h"
  16. #include "wifi.h"
  17. int LedStatus;
  18. void Menu(){
  19. Dogs102x6_stringDraw(0, 0, "Smart Home System", DOGS102x6_DRAW_NORMAL);
  20. Dogs102x6_stringDraw(2, 0, "Tem:", DOGS102x6_DRAW_NORMAL);
  21. Dogs102x6_stringDraw(2, 46, "C", DOGS102x6_DRAW_NORMAL);
  22. Dogs102x6_stringDraw(3, 0, "Hum:", DOGS102x6_DRAW_NORMAL);
  23. Dogs102x6_stringDraw(3, 46, "%", DOGS102x6_DRAW_NORMAL);
  24. Dogs102x6_stringDraw(4, 0, "Lig:", DOGS102x6_DRAW_NORMAL);
  25. Dogs102x6_stringDraw(5, 0, "Gas:", DOGS102x6_DRAW_NORMAL);
  26. Dogs102x6_stringDraw(6, 0, "LED:", DOGS102x6_DRAW_NORMAL);
  27. }
  28. void main( void )
  29. {
  30. WDTCTL=WDTPW+WDTHOLD;
  31. UCSCTL4 |= SELS__DCOCLK;
  32. Dogs102x6_init();
  33. Dogs102x6_clearScreen(); //Clear screen
  34. Dogs102x6_init(); //Initialize LCD
  35. Dogs102x6_backlightInit();
  36. Dogs102x6_setContrast(15); //Set contrast
  37. Dogs102x6_setBacklight(11); //Set backlight
  38. WifiConfig(); //wifi initialization (including serial port)
  39. while (1)
  40. {
  41. Dogs102x6_clearScreen();//Clear screen
  42. Menu(); //Redraw the menu interface
  43. DHT11(); //Measure temperature and humidity data and display them on LCD
  44. light(); //Measure the lighting conditions and display the results on the LCD
  45. gas(); //Measure the smoke condition and display the result on LCD
  46. led(); //Detect LED status and display the result on LCD
  47. delay_ms(2000); //Delay 2s to ensure the time interval of temperature and humidity measurement
  48. }
  49. }
  50. // Echo back RXed character, confirm TX buffer is ready first
  51. #pragma vector=USCI_A1_VECTOR
  52. __interrupt void USCI_A1_ISR(void)
  53. {
  54. switch(__even_in_range(UCA1IV,4))
  55. {
  56. case 0:break; // Vector 0 - no interrupt
  57. case 2: // Vector 2 - RXIFG
  58. if('1' == UCA1RXBUF)
  59. {
  60. P1DIR |= 0x01;
  61. P1OUT |= 0x01; //Turn on the LED
  62. LedStatus = 1; //LED FLAG, used as the basis for displaying the status on the LCD
  63. }
  64. else if('0' == UCA1RXBUF)
  65. {
  66. P1DIR |= 0x01;
  67. P1OUT &= 0xFE; //Turn off the LED light
  68. LedStatus = 0; //LED FLAG, as the basis for displaying the status on the LCD
  69. }
  70. else if('2' == UCA1RXBUF)
  71. {
  72. WifiSendMessage(); //WiFi sends the measured data to the client
  73. }
  74. break;
  75. case 4:break; // Vector 4 - TXIFG
  76. default: break;
  77. }
  78. }
This post is from Microcontroller MCU

Latest reply

Just share more programs   Details Published on 2019-7-16 08:34
 

2618

Posts

0

Resources
2
 

Just share more programs

This post is from Microcontroller MCU
 
 

Guess Your Favourite
Just looking around
Find a datasheet?

EEWorld Datasheet Technical Support

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号
快速回复 返回顶部 Return list