safwan092

Untitled

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