Advertisement
safwan092

Untitled

Nov 28th, 2022
19
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.42 KB | None | 0 0
  1. //2 3 4 5 6 7 8 10 11 12 13
  2. #define REMOTEXY_MODE__ETHERNET_LIB
  3. #include <Ethernet.h>
  4. /* Ethernet shield used pins: 10(SS) */
  5. #include <SPI.h>
  6. /* SPI interface used pins: 11(MOSI), 12(MISO), 13(SCK) */
  7. #include <RemoteXY.h>
  8. #include <LiquidCrystal.h>
  9. #include "DHT.h"
  10.  
  11. // RemoteXY connection settings
  12. #define REMOTEXY_ETHERNET_MAC "C2:B6:58:85:CD:64"
  13. #define REMOTEXY_SERVER_PORT 6377
  14. #define REMOTEXY_ACCESS_PASSWORD "123456789"
  15.  
  16. #define DHTTYPE DHT11
  17. #define DHTPIN 8
  18.  
  19. LiquidCrystal lcd(2, 3, 4, 5, 6, 7);
  20. DHT dht(DHTPIN, DHTTYPE);
  21.  
  22. // RemoteXY configurate
  23. #pragma pack(push, 1)
  24. uint8_t RemoteXY_CONF[] = // 98 bytes
  25. { 255, 0, 0, 25, 0, 91, 0, 16, 167, 1, 66, 193, 30, 17, 25, 7, 34, 26, 66, 129,
  26. 5, 17, 25, 7, 191, 26, 66, 193, 15, 56, 30, 7, 2, 26, 67, 4, 20, 28, 20, 5,
  27. 2, 26, 11, 67, 4, 20, 66, 20, 5, 2, 26, 11, 129, 0, 6, 8, 18, 6, 24, 84,
  28. 101, 109, 112, 116, 101, 114, 58, 0, 129, 0, 16, 49, 18, 6, 24, 72, 117, 109, 105, 100,
  29. 105, 116, 121, 58, 0, 129, 0, 25, 34, 9, 6, 8, 48, 32, 67, 217, 146, 0
  30. };
  31.  
  32. // this structure defines all the variables and events of your control interface
  33. struct {
  34.  
  35. // output variables
  36. int8_t TempHigh; // =0..100 level position
  37. int8_t TempLow; // =0..100 level position
  38. int8_t Hum; // =0..100 level position
  39. char temp[11]; // string UTF8 end zero
  40. char hum[11]; // string UTF8 end zero
  41.  
  42. // other variable
  43. uint8_t connect_flag; // =1 if wire connected, else =0
  44.  
  45. } RemoteXY;
  46. #pragma pack(pop)
  47.  
  48. /////////////////////////////////////////////
  49. // END RemoteXY include //
  50. /////////////////////////////////////////////
  51.  
  52.  
  53.  
  54. void setup()
  55. {
  56. RemoteXY_Init ();
  57. lcd.begin(16, 2);
  58. dht.begin();
  59. lcd.clear();
  60. lcd.print("Temp & Humidity");
  61. lcd.setCursor(0, 1);
  62. lcd.print(" Measurement ");
  63. delay(2000);
  64. lcd.clear();
  65. lcd.print(" ARABS MAKERS ");
  66. delay(2000);
  67. lcd.clear();
  68. lcd.print("Temp: Humidity:");
  69. }
  70.  
  71. void loop()
  72. {
  73. RemoteXY_Handler ();
  74.  
  75.  
  76. // TODO you loop code
  77. // use the RemoteXY structure for data transfer
  78. // do not call delay()
  79. lcd.setCursor(0, 1);
  80. float h = dht.readHumidity();
  81. float f = dht.readTemperature(true);
  82. float c = (f - 32) / 1.8;
  83.  
  84. dtostrf(c, 0, 1, RemoteXY.temp);
  85. dtostrf(h, 0, 1, RemoteXY.hum);
  86. RemoteXY.Hum = h;
  87.  
  88. if (isnan(h) || isnan(f))
  89. {
  90. lcd.print("ERROR");
  91. return;
  92. }
  93. lcd.print(c);
  94. lcd.setCursor(7, 1);
  95. lcd.print(h);
  96. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement