From 00dc8106298dade11d50075fcb59629cb336b7b9 Mon Sep 17 00:00:00 2001 From: Inssomniak <47230872+Inssomniak@users.noreply.github.com> Date: Mon, 13 May 2024 23:15:20 -0400 Subject: [PATCH 1/8] Initial Update --- marantz.ino | 71 +++++++++++++++++++++++++++++------------------------ 1 file changed, 39 insertions(+), 32 deletions(-) diff --git a/marantz.ino b/marantz.ino index 6e236b5..0fbae9e 100644 --- a/marantz.ino +++ b/marantz.ino @@ -1,14 +1,16 @@ // marantz wired remote control web server // inspired by https://github.com/Arduino-IRremote/Arduino-IRremote +// Ported code by samm-git for esp8266. Added mDNS capability, some code modifications. +// Module used here was a Wemos D1 Mini Pro. // see https://smallhacks.wordpress.com/2021/07/07/controlling-marantz-amplifier-using-arduino-via-remote-socket/ -#define IR_TX_PIN 12 // pin to use for tx, connect via diode to "remote in" socket +#define IR_TX_PIN 4 // pin to use for tx, connect via diode to "remote in" socket // Replace with your network credentials const char* ssid = ""; const char* password = ""; // bssid of the wifi AP if you want to connect to fixed base -byte bssid[] = {0x01,0x02,0x03,0x04,0x05,0x06}; +// byte bssid[] = {0x01,0x02,0x03,0x04,0x05,0x06}; /* some definitions from the IRremote Arduino Library */ #define RC5_ADDRESS_BITS 5 @@ -24,11 +26,10 @@ byte bssid[] = {0x01,0x02,0x03,0x04,0x05,0x06}; #define RC5_REPEAT_SPACE (RC5_REPEAT_PERIOD - RC5_DURATION) // 100 ms // Import required libraries -#include -#include -#include -#include +#include +#include #include +#include // Include the mDNS library #include "html.h" // Create AsyncWebServer object on port 80 @@ -76,7 +77,7 @@ int sendRC5(uint8_t aAddress, uint8_t aCommand, uint_fast8_t aNumberOfRepeats) sLastSendToggleValue = 0; } - uint_fast8_t tNumberOfCommands = aNumberOfRepeats + 1; + uint_fast8_t tNumberOfCommands = aNumberOfRepeats; while (tNumberOfCommands > 0) { @@ -158,6 +159,7 @@ int sendRC5_X(uint8_t aAddress, uint8_t aCommand, uint8_t aExt, uint_fast8_t aNu Serial.print("

"); #endif // space marker for marantz rc5 extension + digitalWrite(IR_TX_PIN, LOW); delayMicroseconds(RC5_UNIT *2 *2); } } @@ -228,38 +230,37 @@ void setup() // GET input1 value on /update?output=&state= if (request->hasParam("button")) { inputMessage1 = request->getParam("button")->value(); - if (strcmp ("standby", inputMessage1.c_str()) == 0) { - sendRC5(16, 12, 1); + if (strcmp("standby", inputMessage1.c_str()) == 0) { + sendRC5(16, 12, 1); } - if (strcmp ("phono", inputMessage1.c_str()) == 0) { - sendRC5(21, 63, 1); + if (strcmp("phono", inputMessage1.c_str()) == 0) { + sendRC5(21, 63, 1); } - if (strcmp ("cd", inputMessage1.c_str()) == 0) { - sendRC5(20, 63, 1); + if (strcmp("cd", inputMessage1.c_str()) == 0) { + sendRC5(20, 63, 1); } - if (strcmp ("tuner", inputMessage1.c_str()) == 0) { - sendRC5(17, 63, 1); + if (strcmp("tuner", inputMessage1.c_str()) == 0) { + sendRC5(17, 63, 1); } - if (strcmp ("aux1", inputMessage1.c_str()) == 0) { - sendRC5_X(16, 0, 6, 1); + if (strcmp("network", inputMessage1.c_str()) == 0) { + sendRC5_X(25, 63, 10, 1); } - if (strcmp ("aux2", inputMessage1.c_str()) == 0) { - sendRC5_X(16, 0, 7, 1); + if (strcmp("optical", inputMessage1.c_str()) == 0) { + sendRC5_X(16, 1, 40, 1); } - if (strcmp ("dcc", inputMessage1.c_str()) == 0) { - sendRC5(23, 63, 1); + if (strcmp("dcc", inputMessage1.c_str()) == 0) { + sendRC5(23, 63, 1); } - if (strcmp ("tape", inputMessage1.c_str()) == 0) { - sendRC5(18, 63, 1); + if (strcmp("tape", inputMessage1.c_str()) == 0) { + sendRC5(18, 63, 1); } - if (strcmp ("volume_up", inputMessage1.c_str()) == 0) { - sendRC5(16, 16, 1); + if (strcmp("volume_up", inputMessage1.c_str()) == 0) { + sendRC5(16, 16, 1); } - if (strcmp ("volume_down", inputMessage1.c_str()) == 0) { - sendRC5(16, 17, 1); + if (strcmp("volume_down", inputMessage1.c_str()) == 0) { + sendRC5(16, 17, 1); } - } - else { + } else { inputMessage1 = "No message sent"; } Serial.print("Button: "); @@ -267,11 +268,17 @@ void setup() Serial.print("\n"); request->send(200, "text/plain", "OK\n"); }); - + + + if (!MDNS.begin("amp")) { // Start the mDNS responder for amp.local + Serial.println("Error setting up MDNS responder!"); + } + Serial.println("mDNS responder started"); + MDNS.addService("http", "tcp", 80); // Start server server.begin(); } -void loop() -{ +void loop() { + MDNS.update(); } From ee145e0c3fb2b71afec6629b24b26c8574cea46e Mon Sep 17 00:00:00 2001 From: Inssomniak <47230872+Inssomniak@users.noreply.github.com> Date: Mon, 13 May 2024 23:16:24 -0400 Subject: [PATCH 2/8] Update html.h --- html.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/html.h b/html.h index 57afd06..2b7bf12 100644 --- a/html.h +++ b/html.h @@ -81,7 +81,7 @@ const char index_html[] PROGMEM = R"rawliteral(

Inputs

-
ProjectorProjector
RadioTurntable
-
Audio INOptical 1/2
From 3ba2dba58ee5c320f5a70a28dea62cbd0f05d285 Mon Sep 17 00:00:00 2001 From: Inssomniak <47230872+Inssomniak@users.noreply.github.com> Date: Mon, 13 May 2024 23:18:25 -0400 Subject: [PATCH 3/8] Update README.md --- README.md | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 9db9e28..caaa9ea 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,11 @@ -# Marantz ESP32 based remote control +# Marantz ESP8266 based remote control with mDNS. Codes for "optical" and "network" remote buttons on newer amplfiifers -Web based remote control for Matantz amplifier using ESP32. +Web based remote control for Matantz amplifier using ESP8266. ## About -This project implements web interface usable from mobile/tablet/desktop for my old Marantz amplifier. -It is using "Remote IN" socket and ESP32 GPIO output. +This project implements web interface usable from mobile/tablet/desktop for PM series of Marantz amplifiers but likely will work with any?. +It is using "Remote IN" socket and ESP8266 GPIO output. I had to connect it via diode (i used **1N5408** but +- any should work) to avoid current from amplifier to the board when infrared RC is used. You can find more about Marantz remote socket and wire protocol in my [blog post](https://smallhacks.wordpress.com/2021/07/07/controlling-marantz-amplifier-using-arduino-via-remote-socket/). @@ -15,7 +15,6 @@ You can find more about Marantz remote socket and wire protocol in my [blog post Project is using [ESPAsyncWebServer](https://github.com/me-no-dev/ESPAsyncWebServer) to provide HTTP and implements 2 endpoints: `/` to output HTML web page (with all embedded images and simple js) and `/update?button=` which allows to send commands to the device. Supported ID-s are "standby, phono, cd, tuner, aux1, aux2, dcc, tape, volume_up, volume_down". All SVG icons are embedded to the source code, you can use SPIFFS if you prefer them to be served as files. -Initially device WIFI latency was very unstable, so power manager was disabled to fix that. In my code there is also bssid selection, to ensure that device always connects to the room AP. Remove it if you have only one AP or set according to your BSSID value. HTML source could be found in the [html.h](html.h) header, it is using some rudimentary scripting (e.g. `onclick` instead of DOM listeners) to be compatible with my older iPad. Protocol is one-way, so its not possible to grab device status. HTTP was choosen as it is compatible with any web browser. From 9a43f9e9671ae7cadaac7cd5a83accbe03996a42 Mon Sep 17 00:00:00 2001 From: Inssomniak <47230872+Inssomniak@users.noreply.github.com> Date: Mon, 13 May 2024 23:19:43 -0400 Subject: [PATCH 4/8] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index caaa9ea..36e826d 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,7 @@ You can find more about Marantz remote socket and wire protocol in my [blog post ## Some implementation notes Project is using [ESPAsyncWebServer](https://github.com/me-no-dev/ESPAsyncWebServer) -to provide HTTP and implements 2 endpoints: `/` to output HTML web page (with all embedded images and simple js) and `/update?button=` which allows to send commands to the device. Supported ID-s are "standby, phono, cd, tuner, aux1, aux2, dcc, tape, volume_up, volume_down". All SVG icons are embedded to the source code, you can use SPIFFS if you prefer them to be served as files. +to provide HTTP and implements 2 endpoints: `/` to output HTML web page (with all embedded images and simple js) and `/update?button=` which allows to send commands to the device. Supported ID-s are "standby, phono, cd, tuner, optical, network, dcc, tape, volume_up, volume_down". All SVG icons are embedded to the source code, you can use SPIFFS if you prefer them to be served as files. HTML source could be found in the [html.h](html.h) header, it is using some rudimentary scripting (e.g. `onclick` instead of DOM listeners) to be compatible with my older iPad. Protocol is one-way, so its not possible to grab device status. HTTP was choosen as it is compatible with any web browser. From c73fecc541ca14bcbb87afe9cee0c90d5299a5f1 Mon Sep 17 00:00:00 2001 From: Inssomniak <47230872+Inssomniak@users.noreply.github.com> Date: Mon, 13 May 2024 23:20:35 -0400 Subject: [PATCH 5/8] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 36e826d..acf4a7f 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ This project implements web interface usable from mobile/tablet/desktop for PM s It is using "Remote IN" socket and ESP8266 GPIO output. I had to connect it via diode (i used **1N5408** but +- any should work) to avoid current from amplifier to the board when infrared RC is used. -You can find more about Marantz remote socket and wire protocol in my [blog post](https://smallhacks.wordpress.com/2021/07/07/controlling-marantz-amplifier-using-arduino-via-remote-socket/). +You can find more about Marantz remote socket and wire protocol in this [blog post](https://smallhacks.wordpress.com/2021/07/07/controlling-marantz-amplifier-using-arduino-via-remote-socket/). ## Some implementation notes From ab1a0dce69fc5814d2a08a725d6400713f0ec6a5 Mon Sep 17 00:00:00 2001 From: Inssomniak <47230872+Inssomniak@users.noreply.github.com> Date: Mon, 13 May 2024 23:21:16 -0400 Subject: [PATCH 6/8] Update README.md --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index acf4a7f..c9e00f5 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,7 @@ -# Marantz ESP8266 based remote control with mDNS. Codes for "optical" and "network" remote buttons on newer amplfiifers +# Marantz ESP8266 based remote control with mDNS. Web based remote control for Matantz amplifier using ESP8266. +Codes for "optical" and "network" remote buttons on newer amplfiifers. ## About From be9d1573d13f0d952d995ac30b1308123481aaed Mon Sep 17 00:00:00 2001 From: Inssomniak <47230872+Inssomniak@users.noreply.github.com> Date: Wed, 15 May 2024 22:29:02 -0400 Subject: [PATCH 7/8] Define mDNS hostname variable --- marantz.ino | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/marantz.ino b/marantz.ino index 0fbae9e..5dc4daf 100644 --- a/marantz.ino +++ b/marantz.ino @@ -24,6 +24,7 @@ const char* password = ""; #define RC5_DURATION (15L * RC5_UNIT) // 13335 #define RC5_REPEAT_PERIOD (128L *RC5_UNIT) // 113792 #define RC5_REPEAT_SPACE (RC5_REPEAT_PERIOD - RC5_DURATION) // 100 ms +#define MDNS_HOSTNAME "amp" // Import required libraries #include @@ -270,7 +271,7 @@ void setup() }); - if (!MDNS.begin("amp")) { // Start the mDNS responder for amp.local + if (!MDNS.begin(MDNS_HOSTNAME)) { // Start the mDNS responder for amp.local Serial.println("Error setting up MDNS responder!"); } Serial.println("mDNS responder started"); From d9132717d821cb774515a4ec2e16b4dbe24f893d Mon Sep 17 00:00:00 2001 From: Inssomniak <47230872+Inssomniak@users.noreply.github.com> Date: Wed, 15 May 2024 22:30:20 -0400 Subject: [PATCH 8/8] Set #DEFINE for mDNS hostname. --- marantz.ino | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/marantz.ino b/marantz.ino index 5dc4daf..129e863 100644 --- a/marantz.ino +++ b/marantz.ino @@ -24,7 +24,7 @@ const char* password = ""; #define RC5_DURATION (15L * RC5_UNIT) // 13335 #define RC5_REPEAT_PERIOD (128L *RC5_UNIT) // 113792 #define RC5_REPEAT_SPACE (RC5_REPEAT_PERIOD - RC5_DURATION) // 100 ms -#define MDNS_HOSTNAME "amp" +#define MDNS_HOSTNAME "amp" // mDNS hostname http://amp.local // Import required libraries #include