Closed baqwas closed 4 years ago
Good Morning :wave: ☕ Currently there is no support for ethernet via e.g. MKR ETH shield, it should not be too hard to add though. Do you think you could prepare a PR for this? I'll be available for guidance, testing and merging. Cheers, Alex
Hello @aentinger,
Thank you for looking into this topic. I will gladly prepare something for you in as much detail as I can provide (with the obvious interest in seeing a future solution). I understand the prevailing priorities that may be imposed upon you owing to the popularity of some of the other options.
Please allow me a day or two to DRAFT something. In the interim if you have any suggestion/template please let me know; I'm truly a novice in matters related to GitHub. Thanks again.
Kind regards.
That sounds great :rocket: Meanwhile I've gotten myself 2 MKR ETH shields for testing :wink:
Arduino PR Cloud MKR ETH library.docx
Hello @aentinger,
Here is my 1st DRAFT of the proposal. Please correct me if I am not on the right track. Thanks again for all your help and guidance:
This document was prepared in response to a suggestion. It is intended for review by Arduino development staff to provide support for future extensions to Arduino IoT Cloud solutions.
There are many industrial environments where WiFi is impractical or LAN connectivity is well established. Some examples of these environments are very diverse indeed from petrochemical plants to multi-storied buildings with robust infrastructure. In order to facilitate rapid deployment of Arduino boards it is desirable to leverage the existing infrastructure from simple proof-of-concept to full-fledged production use. This approach has been proven in the use basic Arduino libraries by porting sketches from WiFi examples to Ethernet demonstrations.
The primary objective is to support the Arduino MKR ETH shield in Arduino IoT Cloud solutions. A key goal would be to support TCP and UDP connectivity along the same lines as supported presently with MKR1000 board for use external to Arduino IoT Cloud.
The request is limited to support for MKR ETH shield. There are many chip-sets that may merit future consideration but since these chip-sets do not meet the security considerations for Arduino IoT Cloud, there is no requirement to support these chip-sets (e.g. Wiznet W5500 series with Arduino Nano).
The following use cases are annotated below:
The basic scenario requires support for:
WiFiConnectionHandler ArduinoIoTPreferredConnection(SSID, PASS);
ArduinoCloud.begin(ArduinoIoTPreferredConnection);
The assumption being that ArduinoCloud
methods (e.g. update
, printDebugInfo
) would recognize the new interface. Any initialization required to use these methods would be the responsibility of user code (e.g. static IP address allocation or DHCP lease) subject to availability of corresponding methods/functions.
Currently a standard example has the following declaration:
WiFiClient client;
The ensuing client
entity is used in the remaining code extensively. Changing the instantiation to the following does not require complete change to the remaining code:
Ethernet client;
The thinking here is that Arduino IoT Cloud “could” support MKR ETH Shield in a similar way. (pardon my ignorance here, please)
There is a simple example in the Arduino Ethernet library that illustrates the use UDP for NTP synchronization. The author has embed the concepts from this example to support a Stratum peer server in a local infrastructure. While this use has no bearing on Arduino IoT Cloud directly it is hoped that UDP support should not be a handicap for any enhancements.
On a personal note, using a stationary GPS with PPS signal will improve time synchronization tasks in my infrastructure. I am using an Arduino board to leverage a low cost ublox GPS chip-set that does not have PPS signal. The IoT applications will benefit from this data.
EthernetClient LANclient; // instantiate Ethernet network client
PubSubClient MQTTclient(LANclient); // partially initialized client instance
EthernetUDP Udp; // for NTP use to avoid TCP overhead
…
Udp.beginPacket(address, 123); // send request using default port 123
Udp.write(packetBuffer, NTP_PACKET_SIZE);
Udp.endPacket();
For some sites it may be preferable to route messages to Arduino IoT Cloud through an on-site MQTT service broker. The library should permit the equivalent of the following declaration:
Ethernet LANclient;
PubSubClient MQTTclient(LANclient);
such that MQTTclient
can be used freely for user’s custom purposes. There may not be a need to do anything here specific towards MQTT as long as Arduino IoT Cloud libraries support the instantiation of LANclient in the above example. In the simple case, interaction between Arduino IoT Cloud and a local MQTT service broker is not being requested (but may be something to think about for Edge Computing purposes for the roadmap).
This document was prepared owing to a note from Alexander Entinger. Errors and omissions in this document arise solely from the author's limited experience in these matters.
Hi @baqwas :wave: :coffee:
Thank you very much for your detailed request and reasoning behind your desire to have Ethernet support for Arduino IoT Cloud ;) I've got to be honest, I was rather expecting a code contribution but all in all it should not be too difficult to extend Arduino_ConnectionHandler
for the Ethernet shield. Let me prepare a small PR and maybe you can help me by testing it?
Cheers, Alex
Hello @aentinger,
Thanks for the super fast turnaround. As I had mentioned previously, I am a total newbie with GitHub operations (that is why I completely misunderstood your acronym PR). I can follow your instructions with some more details, please. Thanks for your patience.
What you have described will work very nicely for me if I can have access to the Arduino_EthernetConnectionHandler .cpp and .h files, please. Which branch do I need to clone? Thanks for your understanding.
Kind regards.
Hi,
The work-in-progress code for adding Ethernet support to Arduino_ConnectionHandler
is to be found here.
If you use this link you directly download the version including the Arduino_EthernetConnectionHandler
source files and store it at your Arduino installation library folder.
What board are you typically using for this? It must be a MKR ZERO because all other MKR boards have some form of connectivity and you just need Ethernet - am I right?
@baqwas I've not heard from you anymore but your wish has been partially implemented in #41. I'm therefore closing this issue and suggest to continue the discussion over there.
Hello!
Is there any equivalent statement for the MKR ETH shield for the MKR1000 WiFi mode:
WiFiConnectionHandler ArduinoIoTPreferredConnection(SSID, PASS);
Need to use MKR1000 with already tested MKR ETH shield. Thanks.
Kind regards.