Advertisement
joaopedros2

Untitled

Oct 2nd, 2023
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.65 KB | None | 0 0
  1. Guru Meditation Error: Core 1 panic'ed (Interrupt wdt timeout on CPU1).
  2.  
  3. Guru Meditation Error: Core 1 panic'ed (Unhandled debug exception).
  4. Debug exception reason: Stack canary watchpoint triggered (IDLE)
  5. Core 1 register dump:
  6. PC : 0x40056f60 PS : 0x00060036 A0 : 0x820112c2 A1 : 0x3fcf4e40
  7. A2 : 0x3fcf4e50 A3 : 0x3c034c90 A4 : 0x00000060 A5 : 0x3fcf4e80
  8. A6 : 0x3c034bf3 A7 : 0x3c034bfc A8 : 0x00000000 A9 : 0x00000000
  9. A10 : 0x3fcf4d04 A11 : 0x80000001 A12 : 0x00040025 A13 : 0x3fcf5000
  10. A14 : 0x00060a34 A15 : 0x00040024 SAR : 0x0000000a EXCCAUSE: 0x00000001
  11. EXCVADDR: 0x00000000 LBEG : 0x40056f5c LEND : 0x40056f72 LCOUNT : 0x00000002
  12.  
  13.  
  14. Backtrace:0x40056f5d:0x3fcf4e40 |<-CORRUPTED
  15.  
  16.  
  17. Core 0 register dump:
  18. PC : 0x42027fea PS : 0x00060134 A0 : 0x82010909 A1 : 0x3fcf4b50
  19. A2 : 0x00000000 A3 : 0x42019274 A4 : 0x00060120 A5 : 0x80000000
  20. A6 : 0x02c93ee0 A7 : 0x00ffffff A8 : 0x82010452 A9 : 0x3fcf4b20
  21. A10 : 0x00000000 A11 : 0x3fc93ed0 A12 : 0x3fc93ed0 A13 : 0x00000000
  22. A14 : 0x00060120 A15 : 0x00000000 SAR : 0x0000001a EXCCAUSE: 0x00000006
  23. EXCVADDR: 0x00000000 LBEG : 0x00000000 LEND : 0x00000000 LCOUNT : 0x00000000
  24.  
  25.  
  26. Backtrace:0x42027fe7:0x3fcf4b500x42010906:0x3fcf4b70 0x4037cab4:0x3fcf4b90
  27.  
  28.  
  29. ------
  30.  
  31. Guru Meditation Error: Core 0 panic'ed (Interrupt wdt timeout on CPU0).
  32.  
  33. Guru Meditation Error: Core 0 panic'ed (Unhandled debug exception).
  34. Debug exception reason: Stack canary watchpoint triggered (IDLE)
  35. Core 0 register dump:
  36. PC : 0x40056f60 PS : 0x00060036 A0 : 0x820112c2 A1 : 0x3fcf48d0
  37. A2 : 0x3fcf48e0 A3 : 0x3c034c80 A4 : 0x00000060 A5 : 0x3fcf4900
  38. A6 : 0x3c034bcf A7 : 0x3c034bd8 A8 : 0x00000000 A9 : 0x00000000
  39. A10 : 0x00000001 A11 : 0x00000001 A12 : 0x00040025 A13 : 0x3fcf4a90
  40. A14 : 0x00060134 A15 : 0x00040024 SAR : 0x0000000a EXCCAUSE: 0x00000001
  41. EXCVADDR: 0x00000000 LBEG : 0x40056f5c LEND : 0x40056f72 LCOUNT : 0x00000003
  42.  
  43.  
  44. Backtrace:0x40056f5d:0x3fcf48d0 |<-CORRUPTED
  45.  
  46.  
  47. Core 1 register dump:
  48. PC : 0x42027fea PS : 0x00060a34 A0 : 0x82010909 A1 : 0x3fcf50c0
  49. A2 : 0x00000000 A3 : 0x00000003 A4 : 0x00060023 A5 : 0x80000000
  50. A6 : 0x02c93ee0 A7 : 0x00ffffff A8 : 0x3fc96054 A9 : 0x00000001
  51. A10 : 0x00000001 A11 : 0x3fcf4e80 A12 : 0x00000020 A13 : 0x80000000
  52. A14 : 0x00060023 A15 : 0x00000000 SAR : 0x00000000 EXCCAUSE: 0x00000005
  53. EXCVADDR: 0x00000000 LBEG : 0x00000000 LEND : 0x00000000 LCOUNT : 0x00000000
  54.  
  55.  
  56. Backtrace:0x42027fe7:0x3fcf50c00x42010906:0x3fcf50e0 0x4037cab4:0x3fcf5100
  57.  
  58.  
  59. ---
  60.  
  61. #include "Arduino.h"
  62. #include "LoRaWan_APP.h"
  63. #include <ResponsiveAnalogRead.h>
  64.  
  65. // ----------------------------------------------------------------------------
  66. // LoRa Configs
  67. // ----------------------------------------------------------------------------
  68.  
  69. #define RF_FREQUENCY 433000000 // Hz
  70.  
  71. #define TX_OUTPUT_POWER 17 // dBm
  72.  
  73. #define LORA_BANDWIDTH 0 // [0: 125 kHz, 1: 250 kHz, 2: 500 kHz, 3: Reserved]
  74.  
  75. #define LORA_SPREADING_FACTOR 9 // [SF7..SF12]
  76. #define LORA_CODINGRATE 4 // [1: 4/5, 2: 4/6, 3: 4/7, 4: 4/8]
  77.  
  78. #define LORA_PREAMBLE_LENGTH 8 // Same for Tx and Rx
  79. #define LORA_SYMBOL_TIMEOUT 0 // Symbols
  80. #define LORA_FIX_LENGTH_PAYLOAD_ON false
  81. #define LORA_IQ_INVERSION_ON false
  82.  
  83. #define RX_TIMEOUT_VALUE 1000
  84. #define BUFFER_SIZE 30 // Define the payload size here
  85.  
  86. char txpacket[BUFFER_SIZE];
  87. char rxpacket[BUFFER_SIZE];
  88.  
  89. bool lora_idle=true;
  90.  
  91. static RadioEvents_t RadioEvents;
  92. void OnTxDone( void );
  93. void OnTxTimeout( void );
  94.  
  95. // ----------------------------------------------------------------------------
  96. // Define Pins
  97. // ----------------------------------------------------------------------------
  98.  
  99. #define VBAT_PIN 1 // Define the battery voltage pin
  100. #define VBAT_READ_CNTRL_PIN 37 // Control pin for battery voltage reading
  101.  
  102. #define MOISTURE_PIN 7 // Define the moisture sensor pin
  103. #define MOISTURE_PIN_POWER 6 // Define the moisture sensor pin power
  104.  
  105. // ----------------------------------------------------------------------------
  106. // Settings
  107. // ----------------------------------------------------------------------------
  108.  
  109. //For Sector Number
  110. const int SECTOR_NUMBER = 1; // Define the sector number
  111.  
  112. //For Deep Sleep Mode
  113. const uint32_t DEEP_SLEEP_TIME = 1; // Define the time duration in minutes
  114.  
  115. ResponsiveAnalogRead analogBattery(VBAT_PIN, false, 0.0005);
  116. ResponsiveAnalogRead analogMoisture(MOISTURE_PIN, false, 0.0005);
  117.  
  118. // ----------------------------------------------------------------------------
  119. // Function to Enter in Deep Sleep Mode
  120. // ----------------------------------------------------------------------------
  121.  
  122. void deepSleep() {
  123.  
  124. // Enable timer wake-up for deep sleep
  125. esp_sleep_enable_timer_wakeup(DEEP_SLEEP_TIME * 60 * 1000000);
  126. //esp_sleep_enable_timer_wakeup(DEEP_SLEEP_TIME * 1000000); // For test
  127.  
  128. // Set the MOISTURE_PIN_POWER pin off
  129. digitalWrite(MOISTURE_PIN_POWER, LOW);
  130.  
  131. // End SPI communication
  132. SPI.end();
  133.  
  134. // Set pins as an analog input to save power
  135. pinMode(RADIO_DIO_1, ANALOG);
  136. pinMode(RADIO_NSS, ANALOG);
  137. pinMode(RADIO_RESET, ANALOG);
  138. pinMode(RADIO_BUSY, ANALOG);
  139. pinMode(LORA_CLK, ANALOG);
  140. pinMode(LORA_MISO, ANALOG);
  141. pinMode(LORA_MOSI, ANALOG);
  142.  
  143. // Configure power domains to optimize power consumption
  144. esp_sleep_pd_config(ESP_PD_DOMAIN_RTC_PERIPH, ESP_PD_OPTION_OFF); // Turn off RTC peripherals
  145. esp_sleep_pd_config(ESP_PD_DOMAIN_RTC_SLOW_MEM, ESP_PD_OPTION_OFF); // Turn off RTC slow memory
  146. esp_sleep_pd_config(ESP_PD_DOMAIN_RTC_FAST_MEM, ESP_PD_OPTION_OFF); // Turn off RTC fast memory
  147. esp_sleep_pd_config(ESP_PD_DOMAIN_XTAL, ESP_PD_OPTION_OFF); // Turn off the crystal oscillator
  148.  
  149. Serial.printf("\nEntering deep sleep mode for %u %s...\n", DEEP_SLEEP_TIME, (DEEP_SLEEP_TIME == 1) ? "minute" : "minutes");
  150.  
  151. delay(100);
  152.  
  153. // Enter deep sleep mode
  154. esp_deep_sleep_start();
  155.  
  156. }
  157.  
  158. void blinkLED() {
  159. digitalWrite(LED, HIGH);
  160. delay(100);
  161. digitalWrite(LED, LOW);
  162. }
  163.  
  164. void setup() {
  165.  
  166. Serial.begin(115200);
  167.  
  168. analogMoisture.setAnalogResolution(4096);
  169.  
  170. pinMode(LED, OUTPUT);
  171.  
  172. // Set the VBAT_READ_CNTRL_PIN pin to turn it off
  173. pinMode(VBAT_READ_CNTRL_PIN, OUTPUT);
  174. digitalWrite(VBAT_READ_CNTRL_PIN, LOW);
  175.  
  176. // Set the MOISTURE_PIN_POWER pin to turn it on
  177. pinMode(MOISTURE_PIN_POWER, OUTPUT);
  178. digitalWrite(MOISTURE_PIN_POWER, HIGH);
  179.  
  180.  
  181. Mcu.begin();
  182. Serial.println("\nInitializing LoRa Radio...");
  183.  
  184. RadioEvents.TxDone = OnTxDone;
  185. RadioEvents.TxTimeout = OnTxTimeout;
  186.  
  187. Radio.Init( &RadioEvents );
  188. Radio.SetChannel( RF_FREQUENCY );
  189. Radio.SetTxConfig( MODEM_LORA, TX_OUTPUT_POWER, 0, LORA_BANDWIDTH,
  190. LORA_SPREADING_FACTOR, LORA_CODINGRATE,
  191. LORA_PREAMBLE_LENGTH, LORA_FIX_LENGTH_PAYLOAD_ON,
  192. true, 0, 0, LORA_IQ_INVERSION_ON, 3000 );
  193.  
  194. }
  195.  
  196. void loop()
  197. {
  198. if(lora_idle == true)
  199. {
  200. //delay(100);
  201.  
  202. Serial.println("\nGetting Analog Values from the sensors...");
  203.  
  204. analogBattery.update();
  205. analogMoisture.update();
  206.  
  207. delay(60000);
  208.  
  209. Serial.print("Battery: ");
  210. Serial.println(analogBattery.getValue());
  211. Serial.print("Moisture: ");
  212. Serial.println(analogMoisture.getValue());
  213.  
  214. // Start a package
  215. sprintf(txpacket, "%d:%d:%d", SECTOR_NUMBER, analogBattery.getValue(), analogMoisture.getValue());
  216.  
  217. Serial.printf("\r\nSending Packet: \"%s\", length %d\r\n",txpacket, strlen(txpacket));
  218.  
  219. // Send the package out
  220. Radio.Send((uint8_t *)txpacket, strlen(txpacket));
  221. lora_idle = false;
  222. }
  223. Radio.IrqProcess();
  224.  
  225. }
  226.  
  227. void OnTxDone( void ) {
  228.  
  229. // Put LoRa radio to sleep
  230. Radio.Sleep();
  231. Serial.println("TX done......");
  232. lora_idle = true;
  233.  
  234. // Blink the LED when sending the package out
  235. blinkLED();
  236.  
  237. delay(100);
  238. deepSleep();
  239.  
  240. }
  241.  
  242. void OnTxTimeout( void ){
  243.  
  244. // Put LoRa radio to sleep
  245. Radio.Sleep();
  246. Serial.println("TX Timeout......");
  247. lora_idle = true;
  248.  
  249. delay(100);
  250. deepSleep();
  251.  
  252. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement