How do I use my own GetHub branch as a library?

I am working on my MakeBlock balancing robot. Their library is at

if I Fork it or edit a file, I get

But I need to change things that will conflict with the original code. So I have a branch.

but PlatformIO will not except the branch

Infact PlatformIO will not even except the master branch if it is in branch form.

Is there a special way to do this?


You’re giving it the wrong git link. Must be the one you get when you go to “Clone or download” in the upper right corner.


Select the wanted branch name by adding a #branchname or #commithash at the end, as e.g. seen in Howto use dedicated stage version · Issue #49 · platformio/platform-espressif8266 · GitHub


This #-Syntax should really be put into the docs for the libdeps option.
I was looking for it there a few moments ago to reply as I only knew the standard git command

git clone -b <branch> <remote_repo>

and was thinking maybe the platformio.ini gets parsed in a similar way and you could just insert that.

1 Like

I remember something about that from a You-Tube tutorial. But before today I have always just copied the Google Chrome web-page address and it worked. Even that does not work now.

But my current task is a little different. In my repository (which is a fork) I create a branch for my custom code. Then I need PlatformIO to link to this branch. But the branch link (if it works at all) goes to my fork. If my contradictory code is in my fork and I Commit and Push/Pull, then the code tries to insert upstream into "master". This is not the intent. The custom code is relevant to the branch and not master. The only option I see is to never Push/Pull. But this would negate to possibility of collaboration.

Then the upstream remote of your copy of the repository is wrong? Check what it points to using git remote -v. If it does not point to your fork, git remote remove origin and git remote add origin or simply re-clone your repo.

If I use the #branch form, the color coding makes it look as though there is a mistake. But that may just be a color.


The official library always works. The Tree form (Google Chrome address) never works. My custom library does not work anymore.

If you can upload your firmware code and platformio.ini we can have a look at it.

The advantage of version control is the ability to go back in time to a previous version. So, for the last four days I have NOT been working on my project as much as learning Git and GitHub. I have developed the practice of not committing unless the program compiles. Compile does an automatic save. So, I should only have to go back one version. However, I have also been figuring out branches and links in the process. And changed my GitHub name and email address. With a link from "Clone or download" properly pasted to the clipboard and pasted to PlatformIO.ini, Intellisense thinks that the # is the start of a comment. This might also mean that the "'" character (apostrophe to make a plural) is a valid character in a branch name(?).

Think. The MakeBlock firmware is one program. The MakeBlock Library is 100+ programs. The MakeBlock firmware is 3000 lines long. I have reduced it to 2000 lines for my balancing robot project. My robot needs custom gyro code. My version or the MakeBlock Library is online at GitHub at

My program (My_Robot_101.cpp) is at DropBox at

This is four commits back. I would not have done a commit if it did not compile.

So, I can not explain why now it does NOT compile.


Am I remembering correctly that the Makeblock controller was a custom Arduino Mega 2560? If so, the following platformio.ini compiled fine with the code you provided in the dropbox link…

Part of the reason your references weren’t working was probably because the urls are references to specific commits, not a link to the github repo…

platform = atmelavr
board = megaatmega2560
framework = arduino
lib_deps = 
   Nintendo Extension Ctrl
debug_tool = jlink

The MakeBlock Ultimate 2.0 2560 controller is an Arduino Mega 2560 clone. As such, it uses the Arduino framework and the megaatmega2560 board.

As a new user with little experience here, I am doing a lot of reading/studying and most of my work would best be described as experimental. I only have one project. But I saw what I thought was two separate problems and have two threads. Although it may be only one misconfigured platformio.ini file.

Nintendo Extension Ctrl
This topic has been discussed before. I do not call it an issue because it works. Presently it is listed in platformio.ini as "Nintendo Extension". Personally, I believe that it is a typo (an accidental delete of "Ctrl"). I use "Nintendo Extension Ctrl" directly from the original unaltered. “platformio.ini” has been updated to the proper "Nintendo Extension Ctrl".

Arduino PID Library
The Arduino PID library has a conflict with my code. So, I have removed the conflict from the library. Now I use my personal version at GitHub. This works.

debug_tool = jlink
I could put a debugger to good use on the Arduino. However there does not seem to be one. This line is removed.

THINK YOU for your interest and work. That is exactly where I will go soon. The instructions from maxgerhardt and ivankracets have given me on end of headaches. The official technique is not working for me.


I have resolved my issue by deleting my personal repository and starting over. The root cause of the issue was never found.

1. I never found the root cause of the issue.
2. I never did figure out how to revert a commit.

My custom library was not working. So, I deleted it and started over. New fork, new rename, new edit. But I have many "MakeBlockDrive" and "MakeBlock-Libraries" folders. What are they for? Which one is the real one? Some investigators say to follow the money. So, I edited each "library. properties" file with a unique number (1,2,3, . . .). The edit made a difference with the first "MakeBlockDrive" in the .piolibdeps folder. But I have moved away from the name "MakeBlockDrive". The new repository name is "MakeBlock-Balancing-Robot-Library". The new name is "MakeBlock Balancing Robot".

  1. Why is the old name there?
  2. Do I need to do some kind of update?
  3. Are there instructions to do a commit removal?

You have multiple libraries in .piolibdeps because you keep changing the lib_deps lines. You can delete the contents of .piolibdeps, and when you do the next build, PlatformIO will re-install the libraries configured in your platformio.ini lib_deps statement, giving you just the files that are needed.

commit stuff is outside of the scope of platformio. However, what you are looking for is the revert git command… where you a new commit is added which rolls back prior commits to restore your code to a prior state.

There is also the ‘reset’ command, which also rewinds back to a specified point, but it’s best to avoid that for now as you’ll really break stuff if you blindly use it.

You may find if you are playing with git and source control, that the GitLens extension is of help as it provides a much better graphical interface to GIT than the one bundled with VSCode.

PlatformIO opens multiple copies of itself, resulting in my project being removed from the workspace. I had to put it back.

The on-line instructions for Git are about the CLI. "revert" raises the question "Does PlatformIO implement ‘revert’?". It is difficult to prove a negative. You have just done that with PlatformIO.

PlatformIO does not implement "revert", proving that I must learn the CLI.

I have a new confusion with the built-in Git process. There is one (1) change left over and I cannot commit it. Realize that MakeBlock uses the name "MakeBlock-Libraries". So, to avoid confusion, I am moving away from that name and do not see any reason to update anything with that name. PlatformIO does not implement "revert". So, I guess I must commit.

What do I do?


This is an old name that I passed though.

Should i delete the Makeblock-Libraries folder?


Ok, we need to back to basics here, as you are confusing some of the fundamentals.

PlatformIO is a CLI program (or I suppose you could say package, as it’s more than one file), which via an extension, adds features to the Microsoft VSCode editor. PlatformIO does not do any source control, git, workspaces, whatever. That is all in the domain of VSCode. I suspect that when your project was ‘removed’ from the workspace… you either accidentally closed the workspace, or opened a new window, which is a clean slate (i.e. File -> New Window)

VSCode’s source control GUI is very simple… it’s enough to get along by if you just want to to be able commits some code, pull changes, see what’s changed… just the bare essentials. If you want more, you either install an extension like GitLens, switch to using git at the command line (opening a terminal in VSCode make it really easy, as it even opens in the directory of your current project) or use an external program to manage your code versions (i.e. Github Desktop).

If you don’t care about those changes (double click the listing for the change to see what they are) you can right click -> Discard changes

As to…

Should i delete the Makeblock-Libraries folder?

… I’m not sure. I would move it first, and see if the code still compiles, and if it does, delete it.

Can Visual Studio work with two separate branches? (I don’t mean at the same time.) There is a branch name at the bottom left of the window. If it says one branch or the other, am I editing the branch named? And by clicking the name and changing it, I am working with a different branch. Then the code of my program would be specific to the branch.




I think you answered your own question there…

by clicking the name and changing it, I am working with a different branch

And yes, the branch named in the status bar is indeed the currently selected branch. which is where any changes will be pushed to.

It was meant to be a question. “Am I?”

In the past I have tried to have one post for each issue. But I am one person with one project. So, I might as well have just one post.

All the old Arduino examples use a baud rate of 9600. The new examples upgrade to 115200. I have successfully upgraded my code to 115200. But SerialPlot is dropping frames. All values are set to zero. So, I will try 57600. But the characters are illegible. This is true for both SerialPlot and Visual Studio. I have changed monitor_speed to 57600 in platformio.ini!

What have I missed?