Advertisement
pleasedontcode

"Module Communication" rev_03

May 1st, 2025
148
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: "Module Communication"
  13.     - Source Code NOT compiled for: ESP32 DevKit V1
  14.     - Source Code created on: 2025-05-01 08:01:58
  15.  
  16. ********* Pleasedontcode.com **********/
  17.  
  18. /****** SYSTEM REQUIREMENTS *****/
  19. /****** SYSTEM REQUIREMENT 1 *****/
  20.     /* add mmdvm hat to obsidian esp32 */
  21. /****** END SYSTEM REQUIREMENTS *****/
  22.  
  23. /* START CODE */
  24.  
  25. /****** DEFINITION OF LIBRARIES *****/
  26. #include <SoftwareSerial.h> //https://github.com/plerup/espsoftwareserial
  27.  
  28. /****** FUNCTION PROTOTYPES *****/
  29. void setup(void);
  30. void loop(void);
  31.  
  32. /***** DEFINITION OF Software Serial *****/
  33. const uint8_t myHC05_HC05_mySerial_PIN_SERIAL_TX_D4 = 4;
  34. const uint8_t myHC05_HC05_mySerial_PIN_SERIAL_RX_D13 = 13;
  35. EspSoftwareSerial::UART myHC05_HC05_mySerial;
  36.  
  37. // Define MMDVM hat related pins
  38. const uint8_t MMDVM_TX_PIN = 16; // Example pin for MMDVM TX
  39. const uint8_t MMDVM_RX_PIN = 17; // Example pin for MMDVM RX
  40. EspSoftwareSerial::UART mmdvmSerial; // Create a SoftwareSerial object for MMDVM
  41.  
  42. void setup(void)
  43. {
  44.     // Initialize Software Serial for HC05
  45.     myHC05_HC05_mySerial.begin(9600, SWSERIAL_8N1, myHC05_HC05_mySerial_PIN_SERIAL_RX_D13, myHC05_HC05_mySerial_PIN_SERIAL_TX_D4, false);
  46.    
  47.     // Initialize Software Serial for MMDVM
  48.     mmdvmSerial.begin(9600, SWSERIAL_8N1, MMDVM_RX_PIN, MMDVM_TX_PIN, false);
  49. }
  50.  
  51. void loop(void)
  52. {
  53.     // Main code for handling communication with HC05 and MMDVM
  54.     if (myHC05_HC05_mySerial.available()) {
  55.         // Read from HC05 and send to MMDVM
  56.         char c = myHC05_HC05_mySerial.read();
  57.         mmdvmSerial.write(c);
  58.     }
  59.  
  60.     if (mmdvmSerial.available()) {
  61.         // Read from MMDVM and send to HC05
  62.         char c = mmdvmSerial.read();
  63.         myHC05_HC05_mySerial.write(c);
  64.     }
  65. }
  66.  
  67. /* END CODE */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement