Visual Micro-Adding an Arduino Library Project to Sketch Project as a Reference

Hello guys,

I was searching how to make multi layer arduino solution in Visual Studio 2017 and I decided to ask to forum.arduino.cc :slight_smile: . While I writing a question topic , I found the solution :slight_smile:

Now, this is not a question. This is a learn topic.

Layers like this:

---> MySeatSolution(Solution)

-------> MySeatProject.Core (Library Project)

-------> MySeatProject.Model1 (Sketch1)

-------> MySeatProject.Model2 (Sketch2)

I tried some things. My step :

1) Create New Arduino Library Project


formula weight of aluminum sulfate

2) Add Two Sketch Projects to Solution


formula weight of aluminum sulfate

now, my solution looks like :

formula weight of aluminum sulfate

3) Creating a "SerialConsole" Common Class To CoreLibrary Project

formula weight of aluminum sulfate

4) SerialConsole.h

formula weight of aluminum sulfate

#pragma once
class SerialConsole
{
public:
	SerialConsole();
	~SerialConsole();
	void TestPrint();
};

5) SerialConsole.cpp


formula weight of aluminum sulfate

#include "SerialConsole.h"
SerialConsole::SerialConsole()
{
}
SerialConsole::~SerialConsole()
{
}
void SerialConsole::TestPrint()
{
	Serial.println("Test Message");
}

If you saw it, there's a problem. "Serial" is undefined. But I'll solve this problem at next steps.

formula weight of aluminum sulfate

6) Adding as a reference to Sketch1 Project


formula weight of aluminum sulfate


formula weight of aluminum sulfate

7) Now, problem in step 5 is solved


formula weight of aluminum sulfate

8 ) Time To Build !

formula weight of aluminum sulfate

**ERROR :frowning: :frowning: :frowning: :frowning: **

SerialConsole.cpp: 11:2: error: 'Serial' was not declared in this scope
   Serial.println("Test Message")
Error compiling libraries
Build failed for project 'Sketch1'

9 ) Add (#include "ESP8266WiFi.h") To SerialConsole.cpp and h


formula weight of aluminum sulfate


formula weight of aluminum sulfate

and happy end

Build Success...
Compiling 'Sketch1' for 'NodeMCU 1.0 (ESP-12E Module)'
Program size: 249.059 bytes (used 24% of a 1.044.464 byte maximum) (2,63 secs)
Minimum Memory Usage: 33084 bytes (40% of a 81920 byte maximum)

When I open Visual Studio and select New Project and click Visual C++ I don't see the list of Project types - see attached screen capture.

Thanks

ronb1949:
When I open Visual Studio and select New Project and click Visual C++ I don't see the list of Project types - see attached screen capture.

Thanks

You need to install Visual Micro For Visual Studio Extension. Its very usefull. I advice. Because Visual Studio is the best IDE in the world :slight_smile:

https://www.visualmicro.com/page/Arduino-Visual-Studio-Downloads.aspx