safwan092

Untitled

Nov 16th, 2022
171
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.20 KB | None | 0 0
  1. #include "LiquidCrystal.h" // تضمين مكتبة الأكواد الخاصة بالشاشة
  2. #include "DHT.h" // تضمين مكتبة الحساس
  3. #define DHTTYPE DHT11 //تعرف نوع الحساس
  4. #define DHTPIN 12 //تعريف رقم طرف توصيل الحساس
  5. LiquidCrystal lcd(2, 3, 4, 5, 6, 7); //LCD connection pins
  6. DHT dht(DHTPIN, DHTTYPE);
  7. #define REMOTEXY_MODE__ETHERNET_LIB
  8. #include <Ethernet.h>
  9. /* Ethernet shield used pins: 10(SS) */
  10. #include <SPI.h>
  11. /* SPI interface used pins: 11(MOSI), 12(MISO), 13(SCK) */
  12.  
  13. #include <RemoteXY.h>
  14. #include<IPAddress.h>
  15. // RemoteXY connection settings
  16. #define REMOTEXY_ETHERNET_MAC "C2:B6:58:85:CD:64"
  17. #define REMOTEXY_SERVER_PORT 6377
  18. #define REMOTEXY_ACCESS_PASSWORD "123456789"
  19. //#define RemoteXY RM
  20.  
  21.  
  22. //IPAddress ip(192, 168, 1, 177);
  23. //IPAddress myDns(192, 168, 1, 1);
  24. //IPAddress gateway(192, 168, 1, 1);
  25. //IPAddress subnet(255, 255, 0, 0);
  26.  
  27. // RemoteXY configurate
  28. #pragma pack(push, 1)
  29. int RemoteXY_CONF[] = // 98 bytes
  30. { 255, 0, 0, 25, 0, 91, 0, 16, 167, 1, 66, 193, 30, 17, 25, 7, 34, 26, 66, 129,
  31. 5, 17, 25, 7, 191, 26, 66, 193, 15, 56, 30, 7, 2, 26, 67, 4, 20, 28, 20, 5,
  32. 2, 26, 11, 67, 4, 20, 66, 20, 5, 2, 26, 11, 129, 0, 6, 8, 18, 6, 24, 84,
  33. 101, 109, 112, 116, 101, 114, 58, 0, 129, 0, 16, 49, 18, 6, 24, 72, 117, 109, 105, 100,
  34. 105, 116, 121, 58, 0, 129, 0, 25, 34, 9, 6, 8, 48, 32, 67, 217, 146, 0
  35. };
  36.  
  37. // this structure defines all the variables and events of your control interface
  38. struct {
  39.  
  40. // output variables
  41. int TempHigh; // =0..100 level position
  42. int TempLow; // =0..100 level position
  43. int Hum; // =0..100 level position
  44. char f[12]; // string UTF8 end zero
  45. char h[12]; // string UTF8 end zero
  46.  
  47. // other variable
  48. int connect_flag; // =1 if wire connected, else =0
  49.  
  50. } RemoteXY;
  51. #pragma pack(pop)
  52.  
  53.  
  54. //IPAddress ip(192.168.247.1);
  55. void setup() //دالة الإعداد وتنفذ مرة واحدة فقط فى بداية البرنامج
  56. { //كل الأوامر التالية بين القوسين ضمن هذه الدالة
  57.  
  58. //أمر لبدء تشغيل الحساس
  59.  
  60.  
  61. lcd.begin(16, 2); //أمر لبدء تشغيل الشاشة
  62. dht.begin(); //أمر لبدء تشغيل الحساس
  63. lcd.clear(); //أمر مسح الشاشة
  64. lcd.print("Temp & Humidity"); //أمر طباعة رسالة تعريفية للدائرة
  65. lcd.setCursor(0, 1);
  66. lcd.print(" Measurement ");
  67. delay(2000); //أمر إنتظار ثانيتين
  68. lcd.clear();
  69. lcd.print(" Waad Ghos ");
  70. lcd.setCursor(0, 1);
  71. lcd.print(" 3820046 ");
  72. delay(2000);
  73. lcd.clear();
  74. lcd.print("Temp: Humidity:");
  75.  
  76. // RemoteXY_Init ();
  77.  
  78. }
  79. void loop() //دالة التكرار وتنفذ باستمرار طالما يوجد تغذية كهرباء للأردوينو
  80. {
  81. lcd.clear();
  82. delay(500);
  83.  
  84.  
  85.  
  86. lcd.setCursor(0, 1); //وضع المؤشر فى اول عمود والصف الثانى
  87. float h = dht.readHumidity(); // قراءة نسبة الرطوبة
  88. float f = dht.readTemperature(true); //قراءة قيمة درجة الحرارة بالفهرنهايت من الحساس
  89. float c = (f - 32) / 1.8; //تحويل من فهرنهايت إلى سيليزيوس
  90. if (isnan(h) || isnan(f))
  91.  
  92. {
  93. lcd.print("ERROR");
  94. return;
  95. }
  96. lcd.print(c); // طباعة درجة الحرارة
  97. lcd.setCursor(7, 1);
  98. lcd.print(h); // طباعة الرطوبة
  99.  
  100. RemoteXY_Handler ();
  101. float hum = dht.readHumidity(); // قراءة نسبة الرطوبة
  102. float temp = dht.readTemperature(); //قراءة قيمة درجة الحرارة بالفهرنهايت من الحساس
  103. // float c = (f - 32) / 1.8; //تحويل من فهرنهايت إلى سيليزيوس
  104. if (isnan(h) || isnan(f))
  105. dtostrf(f, 0, 1, RemoteXY.f);
  106. dtostrf(h, 0, 1, RemoteXY.h);
  107. delay(2000);
  108. }
Advertisement
Add Comment
Please, Sign In to add comment