# Compiling the Code

This project uses Platform IO to build the firmware for the various boards. To get started you will need to download,

### Install Visual Studio Code

{% embed url="https://code.visualstudio.com/download" %}

{% hint style="info" %}
The default installation options are okay
{% endhint %}

### Add Platform IO Extension

![](https://1397681474-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F2b78VWyqYPf308KSkgr4%2Fuploads%2F4mCXFtrFchwZKlNbuj4E%2Fimage.png?alt=media\&token=897b6941-55a9-4776-94e6-f752aebac6cc)

Choose install. **\*Wait for all the installation complete popup messages at the bottom\***. It can take a while to install, don't close or do anything else in the meantime.

The final message is please restart VSCode. Go ahead and Restart VSCode by clicking the **Reload Now** button.&#x20;

After it reboots you should see the PlatformIO icon on the bottom of the left tool bar (Alien Head)

### Clone the Git Repository or download + extract the .zip file from GitHub

{% embed url="https://github.com/dlktdr/BTWifiModule" %}

{% hint style="info" %}
I would suggest using an app like GitHub desktop to clone and keep up to date with changes if your not a command line GIT expert. Use https://www.gihub.com/dlktdr/BTWifiModule as the URL Clone source.
{% endhint %}

{% hint style="danger" %}
The folder cannot contain any spaces or you will get build issues. I suggest you put it in the root folder of a drive
{% endhint %}

### Build the Source

From VSCode Click the Platform IO Extension, You will be brought to a list of available boards. Click the drop down arrow on the board you want to build. **Be patient while it loads.** The first time will take a while while it installs and configures in the back end.

Click Build, This will start building the project

![](https://1397681474-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F2b78VWyqYPf308KSkgr4%2Fuploads%2FjwY8aoWkxQ8QPD828CHp%2Fimage.png?alt=media\&token=82a1f1d7-a6a9-4715-affb-c2a82e5206b1)

When it's done you should see a message,

![](https://1397681474-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F2b78VWyqYPf308KSkgr4%2Fuploads%2FobqTQjgi0zYS9sVi7Tq6%2Fimage.png?alt=media\&token=e7712140-090b-4bb4-bd22-937b329dd770)

You can see near the end of the output where the firmware file was written to. In the above case .pio/build/C3Mini/firmware.bin. This is the file that would be uploaded to the board.

#### Upload - PlatformIO has the ability to automatically upload the code to the board.

Choose **Upload** from the list will build and Upload to the board. Note if you have multiple Com ports on your PC, it might not be able to detect the correct one. Look in **platformio.ini** file, you can manually force the upload port here with **upload\_port=xxx.** There are a few examples in the file.

#### Upload and Monitor - This will upload and automatically open the COM port for diagnostic output.

The monitor port, which is usually the same as the programming port is specified in platformio.ini under **monitor\_port=** You should only have to specify this if it's not automatically detect.

#### Hopefully that will get you started. Looking forward to seeing those Pull Requests! 
