diff --git a/arduino/builder/sketch.go b/arduino/builder/sketch.go
index d9ad4c50385..c3425b8d041 100644
--- a/arduino/builder/sketch.go
+++ b/arduino/builder/sketch.go
@@ -108,14 +108,31 @@ func SketchLoad(sketchPath, buildPath string) (*sketch.Sketch, error) {
 
 	var sketchFolder, mainSketchFile string
 
-	// if a sketch folder was passed, save the parent and point sketchPath to the main .ino file
+	// if a sketch folder was passed, save the parent and point sketchPath to the main sketch file
 	if stat.IsDir() {
 		sketchFolder = sketchPath
-		mainSketchFile = filepath.Join(sketchPath, stat.Name()+".ino")
+		// allowed extensions are .ino and .pde (but not both)
+		allowedSketchExtensions := [...]string{".ino", ".pde"}
+		for _, extension := range allowedSketchExtensions {
+			candidateSketchFile := filepath.Join(sketchPath, stat.Name()+extension)
+			if _, err := os.Stat(candidateSketchFile); !os.IsNotExist(err) {
+				if mainSketchFile == "" {
+					mainSketchFile = candidateSketchFile
+				} else {
+					return nil, errors.Errorf("more than one main sketch file found (%v,%v)",
+						filepath.Base(mainSketchFile),
+						filepath.Base(candidateSketchFile))
+				}
+			}
+		}
+		// check that .pde or .ino was found
+		if mainSketchFile == "" {
+			return nil, errors.Errorf("unable to find an sketch file in directory %v", sketchFolder)
+		}
 		// in the case a dir was passed, ensure the main file exists and is readable
 		f, err := os.Open(mainSketchFile)
 		if err != nil {
-			return nil, errors.Wrap(err, "unable to find the main sketch file")
+			return nil, errors.Wrap(err, "unable to open the main sketch file")
 		}
 		f.Close()
 		// ensure it is not a directory
diff --git a/arduino/builder/sketch_test.go b/arduino/builder/sketch_test.go
index 409e258d541..17ed07a016e 100644
--- a/arduino/builder/sketch_test.go
+++ b/arduino/builder/sketch_test.go
@@ -82,6 +82,34 @@ func TestLoadSketchFolder(t *testing.T) {
 	require.Equal(t, "helper.h", filepath.Base(s.AdditionalFiles[2].Path))
 }
 
+func TestLoadSketchFolderPde(t *testing.T) {
+	// pass the path to the sketch folder
+	sketchPath := filepath.Join("testdata", t.Name())
+	mainFilePath := filepath.Join(sketchPath, t.Name()+".pde")
+	s, err := builder.SketchLoad(sketchPath, "")
+	require.Nil(t, err)
+	require.NotNil(t, s)
+	require.Equal(t, mainFilePath, s.MainFile.Path)
+	require.Equal(t, sketchPath, s.LocationPath)
+	require.Len(t, s.OtherSketchFiles, 2)
+	require.Equal(t, "old.pde", filepath.Base(s.OtherSketchFiles[0].Path))
+	require.Equal(t, "other.ino", filepath.Base(s.OtherSketchFiles[1].Path))
+	require.Len(t, s.AdditionalFiles, 3)
+	require.Equal(t, "header.h", filepath.Base(s.AdditionalFiles[0].Path))
+	require.Equal(t, "s_file.S", filepath.Base(s.AdditionalFiles[1].Path))
+	require.Equal(t, "helper.h", filepath.Base(s.AdditionalFiles[2].Path))
+}
+
+func TestLoadSketchFolderBothInoAndPde(t *testing.T) {
+	// pass the path to the sketch folder containing two main sketches, .ino and .pde
+	sketchPath := filepath.Join("testdata", t.Name())
+	_, err := builder.SketchLoad(sketchPath, "")
+	require.Error(t, err)
+	require.Contains(t, err.Error(), "more than one main sketch file found")
+	require.Contains(t, err.Error(), t.Name()+".ino")
+	require.Contains(t, err.Error(), t.Name()+".pde")
+}
+
 func TestLoadSketchFolderSymlink(t *testing.T) {
 	// pass the path to the sketch folder
 	symlinkSketchPath := filepath.Join("testdata", t.Name())
@@ -128,7 +156,7 @@ func TestLoadSketchFolderWrongMain(t *testing.T) {
 	sketchPath := filepath.Join("testdata", t.Name())
 	_, err := builder.SketchLoad(sketchPath, "")
 	require.Error(t, err)
-	require.Contains(t, err.Error(), "unable to find the main sketch file")
+	require.Contains(t, err.Error(), "unable to find an sketch file in directory testdata")
 
 	_, err = builder.SketchLoad("does/not/exist", "")
 	require.Error(t, err)
diff --git a/arduino/builder/testdata/TestLoadSketchFolderBothInoAndPde/.#sketch.ino b/arduino/builder/testdata/TestLoadSketchFolderBothInoAndPde/.#sketch.ino
new file mode 100644
index 00000000000..71048175432
--- /dev/null
+++ b/arduino/builder/testdata/TestLoadSketchFolderBothInoAndPde/.#sketch.ino
@@ -0,0 +1,2 @@
+void setup()
+void loop) }
\ No newline at end of file
diff --git a/arduino/builder/testdata/TestLoadSketchFolderBothInoAndPde/TestLoadSketchFolderBothInoAndPde.ino b/arduino/builder/testdata/TestLoadSketchFolderBothInoAndPde/TestLoadSketchFolderBothInoAndPde.ino
new file mode 100644
index 00000000000..0d5e0f5ceb9
--- /dev/null
+++ b/arduino/builder/testdata/TestLoadSketchFolderBothInoAndPde/TestLoadSketchFolderBothInoAndPde.ino
@@ -0,0 +1,7 @@
+void setup() {
+
+}
+
+void loop() {
+
+}
\ No newline at end of file
diff --git a/arduino/builder/testdata/TestLoadSketchFolderBothInoAndPde/TestLoadSketchFolderBothInoAndPde.pde b/arduino/builder/testdata/TestLoadSketchFolderBothInoAndPde/TestLoadSketchFolderBothInoAndPde.pde
new file mode 100644
index 00000000000..0d5e0f5ceb9
--- /dev/null
+++ b/arduino/builder/testdata/TestLoadSketchFolderBothInoAndPde/TestLoadSketchFolderBothInoAndPde.pde
@@ -0,0 +1,7 @@
+void setup() {
+
+}
+
+void loop() {
+
+}
\ No newline at end of file
diff --git a/arduino/builder/testdata/TestLoadSketchFolderBothInoAndPde/doc.txt b/arduino/builder/testdata/TestLoadSketchFolderBothInoAndPde/doc.txt
new file mode 100644
index 00000000000..e69de29bb2d
diff --git a/arduino/builder/testdata/TestLoadSketchFolderBothInoAndPde/header.h b/arduino/builder/testdata/TestLoadSketchFolderBothInoAndPde/header.h
new file mode 100644
index 00000000000..0e7d3b1a6a9
--- /dev/null
+++ b/arduino/builder/testdata/TestLoadSketchFolderBothInoAndPde/header.h
@@ -0,0 +1 @@
+#define FOO "BAR"
\ No newline at end of file
diff --git a/arduino/builder/testdata/TestLoadSketchFolderBothInoAndPde/old.pde b/arduino/builder/testdata/TestLoadSketchFolderBothInoAndPde/old.pde
new file mode 100644
index 00000000000..e69de29bb2d
diff --git a/arduino/builder/testdata/TestLoadSketchFolderBothInoAndPde/other.ino b/arduino/builder/testdata/TestLoadSketchFolderBothInoAndPde/other.ino
new file mode 100644
index 00000000000..c426196c017
--- /dev/null
+++ b/arduino/builder/testdata/TestLoadSketchFolderBothInoAndPde/other.ino
@@ -0,0 +1,3 @@
+String hello() {
+  return "world";
+}
\ No newline at end of file
diff --git a/arduino/builder/testdata/TestLoadSketchFolderBothInoAndPde/s_file.S b/arduino/builder/testdata/TestLoadSketchFolderBothInoAndPde/s_file.S
new file mode 100644
index 00000000000..e69de29bb2d
diff --git a/arduino/builder/testdata/TestLoadSketchFolderBothInoAndPde/src/dont_load_me.ino b/arduino/builder/testdata/TestLoadSketchFolderBothInoAndPde/src/dont_load_me.ino
new file mode 100644
index 00000000000..46b07018d09
--- /dev/null
+++ b/arduino/builder/testdata/TestLoadSketchFolderBothInoAndPde/src/dont_load_me.ino
@@ -0,0 +1,2 @@
+#include <testlib4.h>
+#error "Whattya looking at?"
diff --git a/arduino/builder/testdata/TestLoadSketchFolderBothInoAndPde/src/helper.h b/arduino/builder/testdata/TestLoadSketchFolderBothInoAndPde/src/helper.h
new file mode 100644
index 00000000000..e69de29bb2d
diff --git a/arduino/builder/testdata/TestLoadSketchFolderPde/.#sketch.ino b/arduino/builder/testdata/TestLoadSketchFolderPde/.#sketch.ino
new file mode 100644
index 00000000000..71048175432
--- /dev/null
+++ b/arduino/builder/testdata/TestLoadSketchFolderPde/.#sketch.ino
@@ -0,0 +1,2 @@
+void setup()
+void loop) }
\ No newline at end of file
diff --git a/arduino/builder/testdata/TestLoadSketchFolderPde/TestLoadSketchFolderPde.pde b/arduino/builder/testdata/TestLoadSketchFolderPde/TestLoadSketchFolderPde.pde
new file mode 100644
index 00000000000..0d5e0f5ceb9
--- /dev/null
+++ b/arduino/builder/testdata/TestLoadSketchFolderPde/TestLoadSketchFolderPde.pde
@@ -0,0 +1,7 @@
+void setup() {
+
+}
+
+void loop() {
+
+}
\ No newline at end of file
diff --git a/arduino/builder/testdata/TestLoadSketchFolderPde/doc.txt b/arduino/builder/testdata/TestLoadSketchFolderPde/doc.txt
new file mode 100644
index 00000000000..e69de29bb2d
diff --git a/arduino/builder/testdata/TestLoadSketchFolderPde/header.h b/arduino/builder/testdata/TestLoadSketchFolderPde/header.h
new file mode 100644
index 00000000000..0e7d3b1a6a9
--- /dev/null
+++ b/arduino/builder/testdata/TestLoadSketchFolderPde/header.h
@@ -0,0 +1 @@
+#define FOO "BAR"
\ No newline at end of file
diff --git a/arduino/builder/testdata/TestLoadSketchFolderPde/old.pde b/arduino/builder/testdata/TestLoadSketchFolderPde/old.pde
new file mode 100644
index 00000000000..e69de29bb2d
diff --git a/arduino/builder/testdata/TestLoadSketchFolderPde/other.ino b/arduino/builder/testdata/TestLoadSketchFolderPde/other.ino
new file mode 100644
index 00000000000..c426196c017
--- /dev/null
+++ b/arduino/builder/testdata/TestLoadSketchFolderPde/other.ino
@@ -0,0 +1,3 @@
+String hello() {
+  return "world";
+}
\ No newline at end of file
diff --git a/arduino/builder/testdata/TestLoadSketchFolderPde/s_file.S b/arduino/builder/testdata/TestLoadSketchFolderPde/s_file.S
new file mode 100644
index 00000000000..e69de29bb2d
diff --git a/arduino/builder/testdata/TestLoadSketchFolderPde/src/dont_load_me.ino b/arduino/builder/testdata/TestLoadSketchFolderPde/src/dont_load_me.ino
new file mode 100644
index 00000000000..46b07018d09
--- /dev/null
+++ b/arduino/builder/testdata/TestLoadSketchFolderPde/src/dont_load_me.ino
@@ -0,0 +1,2 @@
+#include <testlib4.h>
+#error "Whattya looking at?"
diff --git a/arduino/builder/testdata/TestLoadSketchFolderPde/src/helper.h b/arduino/builder/testdata/TestLoadSketchFolderPde/src/helper.h
new file mode 100644
index 00000000000..e69de29bb2d