Advertisement
pleasedontcode

LoRa Management rev_13

Nov 29th, 2024
28
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /********* Pleasedontcode.com **********
  2.  
  3.     Pleasedontcode thanks you for automatic code generation! Enjoy your code!
  4.  
  5.     - Terms and Conditions:
  6.     You have a non-exclusive, revocable, worldwide, royalty-free license
  7.     for personal and commercial use. Attribution is optional; modifications
  8.     are allowed, but you're responsible for code maintenance. We're not
  9.     liable for any loss or damage. For full terms,
  10.     please visit pleasedontcode.com/termsandconditions.
  11.  
  12.     - Project: LoRa Management
  13.     - Source Code compiled for: Arduino Uno
  14.     - Source Code created on: 2024-11-29 23:05:30
  15.  
  16. ********* Pleasedontcode.com **********/
  17.  
  18. /****** SYSTEM REQUIREMENTS *****/
  19. /****** SYSTEM REQUIREMENT 1 *****/
  20.     /* configure a lora gateway */
  21. /****** END SYSTEM REQUIREMENTS *****/
  22.  
  23.  
  24. /* START CODE */
  25.  
  26. /****** DEFINITION OF LIBRARIES *****/
  27. #include <SPI.h>
  28. #include <LoRa.h>   //https://github.com/sandeepmistry/arduino-LoRa
  29.  
  30. /****** FUNCTION PROTOTYPES *****/
  31. void setup(void);
  32. void loop(void);
  33. void updateOutputs(void);
  34.  
  35. /***** DEFINITION OF DIGITAL INPUT PINS *****/
  36. const uint8_t module_SX127x_DIO0_PIN_D3     = 3;
  37.  
  38. /***** DEFINITION OF DIGITAL OUTPUT PINS *****/
  39. const uint8_t module_SX127x_NRESET_PIN_D2       = 2;
  40.  
  41. /***** DEFINITION OF SPI PINS *****/
  42. const uint8_t module_SX127x_SPI_PIN_MOSI_D11        = 11;
  43. const uint8_t module_SX127x_SPI_PIN_MISO_D12        = 12;
  44. const uint8_t module_SX127x_SPI_PIN_SCLK_D13        = 13;
  45. const uint8_t module_SX127x_SPI_PIN_CS_D10      = 10;
  46.  
  47. /***** DEFINITION OF OUTPUT RAW VARIABLES *****/
  48. /***** used to store raw data *****/
  49. bool    module_SX127x_NRESET_PIN_D2_rawData     = 0;
  50.  
  51. /***** DEFINITION OF OUTPUT PHYSICAL VARIABLES *****/
  52. /***** used to store data after characteristic curve transformation *****/
  53. float   module_SX127x_NRESET_PIN_D2_phyData     = 0.0;
  54.  
  55. /****** DEFINITION OF LIBRARIES CLASS INSTANCES*****/
  56.  
  57. void setup(void)
  58. {
  59.     // put your setup code here, to run once:
  60.  
  61.     pinMode(module_SX127x_DIO0_PIN_D3,  INPUT);
  62.     pinMode(module_SX127x_NRESET_PIN_D2,    OUTPUT);
  63.     pinMode(module_SX127x_SPI_PIN_CS_D10,   OUTPUT);
  64.    
  65.     // start the SPI library:
  66.     SPI.begin();
  67.  
  68.     // Initialize LoRa module
  69.     LoRa.setPins(module_SX127x_SPI_PIN_CS_D10, module_SX127x_NRESET_PIN_D2, module_SX127x_DIO0_PIN_D3); // Set CS, RESET, and DIO0 pins
  70.     if (!LoRa.begin(915E6)) { // Initialize LoRa at 915 MHz
  71.         while (1); // If failed, do nothing
  72.     }
  73. }
  74.  
  75. void loop(void)
  76. {
  77.     // put your main code here, to run repeatedly:
  78.  
  79.     updateOutputs(); // Refresh output data
  80. }
  81.  
  82. void updateOutputs()
  83. {
  84.     digitalWrite(module_SX127x_NRESET_PIN_D2, module_SX127x_NRESET_PIN_D2_rawData);
  85. }
  86.  
  87. /* END CODE */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement