safwan092

Untitled

Oct 18th, 2025
40
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.09 KB | None | 0 0
  1. #define REMOTEXY_MODE__WIFI_CLOUD
  2. #include <WiFi.h>
  3. #include <OneWire.h>
  4. #include <RemoteXY.h>
  5. #include <DallasTemperature.h>
  6.  
  7.  
  8.  
  9. // RemoteXY connection settings
  10. #define REMOTEXY_WIFI_SSID "BS Home1"
  11. #define REMOTEXY_WIFI_PASSWORD "0554418546"
  12. #define REMOTEXY_CLOUD_SERVER "cloud.remotexy.com"
  13. #define REMOTEXY_CLOUD_PORT 6376
  14. #define REMOTEXY_CLOUD_TOKEN "f41550dd4fa9c627fb644675dd7e94c7"
  15. #define REMOTEXY_ACCESS_PASSWORD "1234"
  16.  
  17.  
  18.  
  19. #define Temprature_Sensor_PIN 4
  20. #define Level_Sensor_LOW__PIN 34
  21. #define Level_Sensor_MED__PIN 35
  22. #define Level_Sensor_HIGH_PIN 36
  23.  
  24. int LOW__Level_Status = 1;// 1 = no liquid detected
  25. int MED__Level_Status = 1;// 1 = no liquid detected
  26. int HIGH_Level_Status = 1;// 1 = no liquid detected
  27.  
  28.  
  29. // GPIO where the DS18B20 is connected to
  30. const int oneWireBus = Temprature_Sensor_PIN;
  31. // Setup a oneWire instance to communicate with any OneWire devices
  32. OneWire oneWire(oneWireBus);
  33. // Pass our oneWire reference to Dallas Temperature sensor
  34. DallasTemperature sensors(&oneWire);
  35.  
  36.  
  37.  
  38.  
  39.  
  40. // RemoteXY GUI configuration
  41. #pragma pack(push, 1)
  42. uint8_t RemoteXY_CONF[] = // 181 bytes
  43. { 255, 0, 0, 9, 0, 174, 0, 19, 0, 0, 0, 67, 97, 114, 32, 79, 105, 108, 32, 77,
  44. 111, 110, 105, 116, 111, 114, 0, 31, 1, 106, 200, 1, 1, 6, 0, 72, 35, 39, 38, 38,
  45. 44, 166, 140, 134, 26, 0, 0, 0, 0, 0, 0, 16, 66, 0, 0, 0, 0, 1, 0, 0,
  46. 200, 65, 0, 0, 16, 66, 73, 45, 108, 19, 50, 100, 128, 2, 1, 26, 0, 0, 0, 0,
  47. 0, 0, 200, 66, 0, 0, 0, 0, 1, 0, 0, 72, 66, 0, 0, 140, 66, 135, 0, 0,
  48. 140, 66, 0, 0, 180, 66, 1, 0, 0, 180, 66, 0, 0, 190, 66, 69, 246, 0, 20, 20,
  49. 1, 129, 23, 28, 62, 6, 64, 8, 69, 110, 103, 105, 110, 101, 32, 79, 105, 108, 32, 84,
  50. 101, 109, 112, 101, 114, 97, 116, 117, 114, 101, 0, 129, 34, 95, 42, 6, 64, 8, 69, 110,
  51. 103, 105, 110, 101, 32, 79, 105, 108, 32, 76, 101, 118, 101, 108, 0, 69, 246, 22, 20, 20,
  52. 1
  53. };
  54.  
  55. // this structure defines all the variables and events of your control interface
  56. struct {
  57.  
  58. // output variables
  59. int8_t circularBar_01; // from 0 to 36 // TEMP
  60. float linearbar_01; // from 0 to 100 // LEVEL
  61. int16_t sound_01; // =0 no sound, else ID of sound, =1001 for example, look sound list in app
  62. int16_t sound_02; // =0 no sound, else ID of sound, =1001 for example, look sound list in app
  63.  
  64. //RemoteXY.sound_01 = 1001; //Alert ON
  65. //RemoteXY.sound_01 = 0; //Alert OFF
  66.  
  67. // other variable
  68. uint8_t connect_flag; // =1 if wire connected, else =0
  69.  
  70. } RemoteXY;
  71. #pragma pack(pop)
  72.  
  73. /////////////////////////////////////////////
  74. // END RemoteXY include //
  75. /////////////////////////////////////////////
  76.  
  77.  
  78.  
  79. void setup()
  80. {
  81. //Serial.begin(9600);
  82. RemoteXY_Init ();
  83. pinMode(Level_Sensor_LOW__PIN, INPUT);
  84. pinMode(Level_Sensor_MED__PIN, INPUT);
  85. pinMode(Level_Sensor_HIGH_PIN, INPUT);
  86. sensors.begin();
  87.  
  88. // TODO you setup code
  89.  
  90. }
  91.  
  92. void loop() {
  93. RemoteXY_Handler ();
  94. // TODO you loop code
  95. // use the RemoteXY structure for data transfer
  96. // do not call delay(), use instead RemoteXY_delay()
  97. // Take 50 readings and calculate average for each sensor
  98. long lowSum = 0;
  99. long medSum = 0;
  100. long highSum = 0;
  101. int numReadings = 50;
  102. sensors.requestTemperatures();
  103. float temperatureC = sensors.getTempCByIndex(0);
  104. RemoteXY.circularBar_01 = (int)(temperatureC);
  105. if ((int)temperatureC > 25) {
  106. RemoteXY.sound_02 = 2004; //Alert ON
  107. }
  108. else if ((int)temperatureC <= 25) {
  109. RemoteXY.sound_02 = 0; //Alert OFF
  110. }
  111. //Serial.print(temperatureC);
  112. //Serial.println("ΒΊC");
  113. for (int i = 0; i < numReadings; i++) {
  114. lowSum += analogRead(Level_Sensor_LOW__PIN);
  115. medSum += analogRead(Level_Sensor_MED__PIN);
  116. highSum += analogRead(Level_Sensor_HIGH_PIN);
  117. //delay(10); // Small delay between readings
  118. }
  119.  
  120. // Calculate averages
  121. LOW__Level_Status = lowSum / numReadings;
  122. MED__Level_Status = medSum / numReadings;
  123. HIGH_Level_Status = highSum / numReadings;
  124. /*
  125. // Print the averaged values
  126. Serial.print(LOW__Level_Status);
  127. Serial.print(" | ");
  128. Serial.print(MED__Level_Status);
  129. Serial.print(" | ");
  130. Serial.print(HIGH_Level_Status);
  131. Serial.println(" | ");
  132. */
  133. if (LOW__Level_Status == 0 && MED__Level_Status == 0 && HIGH_Level_Status == 0) {
  134. // Serial.println("Oil Level is HIGH ---> OK");
  135. RemoteXY.linearbar_01 = (int)(100);
  136. RemoteXY.sound_01 = 0; //Alert OFF
  137. }
  138. else if (LOW__Level_Status == 0 && MED__Level_Status == 0 && HIGH_Level_Status > 10) {
  139. // Serial.println("Oil Level is Medium ---> Please Fill the Oil and Check For Leaks!!!");
  140. RemoteXY.linearbar_01 = (int)(66.66);
  141. RemoteXY.sound_01 = 2018; //Alert ON
  142. }
  143. else if (LOW__Level_Status == 0 && MED__Level_Status > 10 && HIGH_Level_Status > 10) {
  144. // Serial.println("Oil Level is LOW ---> DANGER !!! Please Fill the Oil and Check For Leaks!!!");
  145. RemoteXY.linearbar_01 = (int)(33.33);
  146. RemoteXY.sound_01 = 2019; //Alert ON
  147. }
  148. else {
  149. // Serial.println("Oil Level is Empty ---> DANGER !!! STOP THE CAR NOW!!!");
  150. RemoteXY.linearbar_01 = (int)(0);
  151. RemoteXY.sound_01 = 2020; //Alert ON
  152. }
  153.  
  154. }
Advertisement
Add Comment
Please, Sign In to add comment