Skip to content

PlatformIO

Taraqur Rahman edited this page Oct 8, 2024 · 20 revisions

VSCode IDE

Prerequisites: We need VSCode.

Step 1: Install PlatformIO’s Extension

  1. Go to VSCode’s extension manager and search for the β€˜PlatformIO IDE’ extension.

    Imgur

Step 2: Clone the CDP Repository

  1. In terminal, navigate to your desired folder. (usually in Documents folder)

  2. Clone the CDP repository:

    git clone https://github.com/ClusterDuck-Protocol/ClusterDuck-Protocol.git
    
  3. Navigate to the CDP repository: cd ClusterDuck Protocol

    Imgur

Step 3: Configure MamaDuck

  1. Click on the PlatformIO icon on the sidebar.

  2. Click on Pick a Folder and open ClusterDuck-Protocol/examples/1.Ducks/MamaDuck when prompted.

    Imgur

  3. In the MamaDuck.ino file, set your MamaDuck ID on line 33: std::string deviceId("MAMA0001"); Make sure the final ID is 8 characters long. You can use the default. Each device is required to have a unique identifier to operate properly in the network.

    Imgur

  4. In the platformio.ini file, select the environment from the list configurations to build your MamaDuck.

    • In my case, I'm using a Heltec Wifi Lora 32 V2, so I can select its environment as the default by commenting it out in this file.
      • Note that I’m selecting the production environment because I want to use the released CDP instead of a local copy. If you clone the CDP repo, modify some files, and want to build one of the examples to reflect your changes, you should select the local environment instead.
  5. After setting your MamaDuck ID and board environment, click the upload icon on the taskbar.

    Imgur

  6. If the upload was successful, click on the serial monitor icon on the taskbar and check that your MamaDuck was configured correctly. Once the setup is completed, you should see a [MAMA]: Setup OK! message in the serial monitor.

    Imgur

Step 4: Configure PapaDuck-Basic

There are two PapaDuck examples listed in ClusterDuck-Protocol/examples/1.Ducks: PapaDuck and PapaDuck-Basic. The PapaDuck example forwards all messages (except pings) to the cloud, while the PapaDuck-Basic example doesn’t send to the cloud. We’ll be using the PapaDuck-Basic to communicate with our MamaDuck and output messages to the serial monitor in JSON format.

  1. Disconnect your MamaDuck from the computer and get another development board.

  2. On a new window (or by clicking Open in the PlatformIO extension on the same window –shown with an asterisk), open the ClusterDuck-Protocol/examples/1.Ducks/PapaDuck-Basic as a PlatformIO project.

    Imgur

  3. In the platformio.ini file choose your board development. In my case, I used the TTGO T-Beam (with a SX127x LoRa module).

  4. Click the upload icon on the taskbar.

    Imgur

  5. If the upload was successful, click on the serial monitor icon on the taskbar and check that your PapaDuck-Basic was configured correctly. Once the setup is completed, you should see a [PAPA]: Setup OK! message in the serial monitor.

    Imgur

Step 5: Test the Network

  1. With your PapaDuck-Basic still connected to your computer and its serial monitor open, plug your MamaDuck into any power source. Make sure both boards have their antennas attached.

  2. Look in the serial monitor for any incoming messages from the MamaDuck. If messages start showing up, your network is working!

    imgur

Using CLI

  1. Install PlatformIO CLI

  2. Clone the ClusterDuck Protocol repository

    git clone https://github.com/ClusterDuck-Protocol/ClusterDuck-Protocol.git
    
  3. Navigate to the example you want to upload. For this example, we will go to DuckLink.

    cd ClusterDuckProtocol/examples/1.Ducks/DuckLink
    
  4. Connect the your board.

  5. Upload the firmware using the following command:

    platformio run -e local_heltec_wifi_lora_32_V3 -t upload
    

    The -e command selects the environment. The -t targets the board

    NOTE: These are the default boards that CDP supports. These boards start with local_ and prod_. local_ means you want to use your local CDP repository. prod_ means you are using the CDP repo from Github as is.

    prod_heltec_wifi_lora_32_V2
    local_heltec_wifi_lora_32_V2
    
    prod_heltec_wifi_lora_32_V3
    local_heltec_wifi_lora_32_V3
    
    prod_ttgo_lora32_v1
    local_ttgo_lora32_v1
    
    prod_lilygo_t_beam_sx1262
    local_lilygo_t_beam_sx1262
    
    release_cdp 
    local_cdp
    esp32
    
  6. Open the serial monitor to see the data flow through with this command:

    platformio device monitor
    
  7. You are done. The build and upload should be successful and you are ready to create your own CDP network!