Advertisement
pleasedontcode

"Microcontroller Control" rev_01

Jul 31st, 2024
215
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: "Microcontroller Control"
  13.     - Source Code NOT compiled for: Arduino Nano ESP32
  14.     - Source Code created on: 2024-07-31 14:21:43
  15.  
  16. ********* Pleasedontcode.com **********/
  17.  
  18. /****** SYSTEM REQUIREMENTS *****/
  19. /****** SYSTEM REQUIREMENT 1 *****/
  20.     /* SolarHAT utilise Bluetooth pour transmettre les */
  21.     /* données du capteur DS18B20 à l'application mobile, */
  22.     /* qui ajuste l'éclairage OLED. Le module SIM800L */
  23.     /* envoie les données GPS au cloud, puis à */
  24.     /* l'application mobile. */
  25. /****** END SYSTEM REQUIREMENTS *****/
  26.  
  27. /****** DEFINITION OF LIBRARIES *****/
  28. #include <SoftwareSerial.h> //https://github.com/plerup/espsoftwareserial
  29. #include <Sim800L.h>    //https://github.com/vittorioexp/Sim800L-Arduino-Library-revised
  30. #include <FastLED.h>    //https://github.com/FastLED/FastLED
  31.  
  32. /****** FUNCTION PROTOTYPES *****/
  33. void setup(void);
  34. void loop(void);
  35.  
  36. /***** DEFINITION OF DIGITAL INPUT PINS *****/
  37. const uint8_t sim800_SIM800L_RING_PIN_D6        = 6;
  38.  
  39. /***** DEFINITION OF DIGITAL OUTPUT PINS *****/
  40. const uint8_t sim800_SIM800L_RST_PIN_D5     = 5;
  41. const uint8_t sim800_SIM800L_DTR_PIN_D10        = 10;
  42. const uint8_t bandeled_P9813_CIN_PIN_D4     = 4;
  43.  
  44. /***** DEFINITION OF Software Serial *****/
  45. const uint8_t sim800_SIM800L_Serial_PIN_SERIAL_TX_A0        = A0;
  46. const uint8_t sim800_SIM800L_Serial_PIN_SERIAL_RX_A1        = A1;
  47.  
  48. // Initialize the Software Serial object for SIM800L communication
  49. EspSoftwareSerial::UART sim800_SIM800L_Serial;
  50.  
  51. // Initialize the SIM800L object with RX, TX, and RST pins
  52. Sim800L GSM(sim800_SIM800L_Serial_PIN_SERIAL_RX_A1, sim800_SIM800L_Serial_PIN_SERIAL_TX_A0, sim800_SIM800L_RST_PIN_D5);
  53.  
  54. /***** DEFINITION OF OUTPUT RAW VARIABLES *****/
  55. /***** used to store raw data *****/
  56. bool    sim800_SIM800L_RST_PIN_D5_rawData       = 0;
  57. bool    sim800_SIM800L_DTR_PIN_D10_rawData      = 0;
  58. bool    bandeled_P9813_CIN_PIN_D4_rawData       = 0;
  59.  
  60. /***** DEFINITION OF OUTPUT PHYSICAL VARIABLES *****/
  61. /***** used to store data after characteristic curve transformation *****/
  62. float   sim800_SIM800L_RST_PIN_D5_phyData       = 0.0;
  63. float   sim800_SIM800L_DTR_PIN_D10_phyData      = 0.0;
  64. float   bandeled_P9813_CIN_PIN_D4_phyData       = 0.0;
  65.  
  66. /****** DEFINITION OF LIBRARIES CLASS INSTANCES *****/
  67. #define LED_PIN     4
  68. #define COLOR_ORDER GRB
  69. #define CHIPSET     WS2811
  70. #define NUM_LEDS    30
  71. #define BRIGHTNESS  200
  72.  
  73. CRGB leds[NUM_LEDS]; // Define an array of LEDs
  74.  
  75. void setup(void)
  76. {
  77.     // put your setup code here, to run once:
  78.     pinMode(sim800_SIM800L_RING_PIN_D6, INPUT_PULLUP);
  79.     pinMode(sim800_SIM800L_RST_PIN_D5,   OUTPUT);
  80.     pinMode(sim800_SIM800L_DTR_PIN_D10,  OUTPUT);
  81.     pinMode(bandeled_P9813_CIN_PIN_D4,   OUTPUT);
  82.  
  83.     // Start the Software Serial communication
  84.     sim800_SIM800L_Serial.begin(9600, SWSERIAL_8N1, sim800_SIM800L_Serial_PIN_SERIAL_RX_A1, sim800_SIM800L_Serial_PIN_SERIAL_TX_A0, false);
  85.  
  86.     // Initialize the SIM800L module
  87.     GSM.begin(4800); // Set the baud rate for SIM800L
  88.  
  89.     // Initialize FastLED
  90.     FastLED.addLeds<CHIPSET, LED_PIN, COLOR_ORDER>(leds, NUM_LEDS).setCorrection(TypicalLEDStrip);
  91.     FastLED.setBrightness(BRIGHTNESS);
  92. }
  93.  
  94. void loop(void)
  95. {
  96.     // put your main code here, to run repeatedly:
  97.     updateOutputs(); // Refresh output data
  98.  
  99.     // Here you would typically handle Bluetooth communication and GPS data sending
  100.     handleBluetooth(); // Call function to handle Bluetooth data transmission
  101.     sendGpsDataToCloud(); // Call function to send GPS data to the cloud
  102. }
  103.  
  104. void updateOutputs()
  105. {
  106.     digitalWrite(sim800_SIM800L_RST_PIN_D5, sim800_SIM800L_RST_PIN_D5_rawData);
  107.     digitalWrite(sim800_SIM800L_DTR_PIN_D10, sim800_SIM800L_DTR_PIN_D10_rawData);
  108.     digitalWrite(bandeled_P9813_CIN_PIN_D4, bandeled_P9813_CIN_PIN_D4_rawData);
  109. }
  110.  
  111. // Function to handle Bluetooth communication
  112. void handleBluetooth() {
  113.     // Code for Bluetooth communication to send DS18B20 sensor data to the mobile application
  114.     // This function should include the logic to read the sensor data and transmit it via Bluetooth
  115. }
  116.  
  117. // Function to send GPS data to the cloud
  118. void sendGpsDataToCloud() {
  119.     // Code to gather GPS data and send it to the cloud via the SIM800L module
  120.     // This function should include the logic to read GPS data and make HTTP requests to the cloud server
  121. }
  122.  
  123. /* END CODE */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement