Search code examples
web-servicesazurearduino-unoazure-machine-learning-service

Arduino Uno - WebService (AzureML)


I'd like to connect to an AzureML Web Service. I have looked into the POST Method on the Arduino Homepage and also here https://iotguys.wordpress.com/2014/12/25/communicating-with-microsoft-azure-eventhub-using-arduino/

Here is my Setup method:

    void setup()
    {
      Serial.begin(9600);
      while (!Serial) {
      ; // wait for serial port to connect.
      }

     Serial.println("ethernet");

     if (Ethernet.begin(mac) == 0) {
       Serial.println("ethernet failed");
       for (;;) ;
     }
    // give the Ethernet shield a second to initialize:
    delay(1000);
 }

The Post Method is based on this: http://playground.arduino.cc/Code/WebClient

I just added sprintf(outBuf, "Authorization: Bearer %s\r\n", api_key); to the header, with char* api_key = "the ML Web Service API KEY"

Also, unlike specified in the WebClient I use the whole WebService URI as url and do not specify a page name.

This doesn't work.

The Network to which I am connecting has Internet Access.

What am I doing wrong?


Solution

  • Machine Learning Studio services that you create needs to receive requests from a device that has SSL capabilities to perform HTTPS requests. AFAIK, Arduino doesn't support SSL capabilities.

    One usual scenario is to attach the Arduino to a third device like Raspberry Pi 2 etc to use it as a gateway and do the call from the Pi itself.

    Here's a sample project from Microsoft Open Technologies team that utilizes Arduino Uno, Raspberry pi and Azure stuff.

    Hope this helps!