Go Down

Topic: Cannot upload sketch OTA over wifi with MKR1010  (Read 910 times) previous topic - next topic

wershbersh

I need to be able to upload sketches OTA over wifi because for my project the arduino will be located in a remote location and I need to be able to upload updates to the code remotely. However I can't figure out how to make it work...

I have tried a couple different libraries but from what I've read, the ArduinoOTA library is what should be used for this board. https://github.com/jandrassy/arduinoota

I am already able to connect to wifi, can successfully communicate and receive data from the arduino over wifi. However, I still cannot upload a sketch OTA.

I'm using the example sketch from github, but changing to WiFiNINA library:

Code: [Select]
/*
 This example connects to an WPA encrypted WiFi network.
 Then it prints the  MAC address of the Wifi shield,
 the IP address obtained, and other network details.
 It then polls for sketch updates over WiFi, sketches
 can be updated by selecting a network port from within
 the Arduino IDE: Tools -> Port -> Network Ports ...
 Circuit:
 * WiFi shield attached
 created 13 July 2010
 by dlf (Metodo2 srl)
 modified 31 May 2012
 by Tom Igoe
 modified 16 January 2017
 by Sandeep Mistry
 */
 
#include <SPI.h>
#include <WiFiNINA.h>
#include <ArduinoOTA.h>


///////please enter your sensitive data in the Secret tab/arduino_secrets.h
/////// Wifi Settings ///////
char ssid[] = "myssid";      // your network SSID (name)
char pass[] = "wifipassword";   // your network password

int status = WL_IDLE_STATUS;

void setup() {
  //Initialize serial:
  Serial.begin(9600);

  // check for the presence of the shield:
  if (WiFi.status() == WL_NO_SHIELD) {
    Serial.println("WiFi shield not present");
    // don't continue:
    while (true);
  }

  // attempt to connect to Wifi network:
  while ( status != WL_CONNECTED) {
    Serial.print("Attempting to connect to SSID: ");
    Serial.println(ssid);
    // Connect to WPA/WPA2 network. Change this line if using open or WEP network:
    status = WiFi.begin(ssid, pass);
  }

  // start the WiFi OTA library with internal (flash) based storage
  ArduinoOTA.begin(WiFi.localIP(), "Arduino", "password", InternalStorage);

  // you're connected now, so print out the status:
  printWifiStatus();
}

void loop() {
  // check for WiFi OTA updates
  ArduinoOTA.poll();

  // add your normal loop code below ...
}

void printWifiStatus() {
  // print the SSID of the network you're attached to:
  Serial.print("SSID: ");
  Serial.println(WiFi.SSID());

  // print your WiFi shield's IP address:
  IPAddress ip = WiFi.localIP();
  Serial.print("IP Address: ");
  Serial.println(ip);

  // print the received signal strength:
  long rssi = WiFi.RSSI();
  Serial.print("signal strength (RSSI):");
  Serial.print(rssi);
  Serial.println(" dBm");
}



This sketch uploads successfully over USB but then if I try to re-upload this sketch, or any other sketch from IDE after selecting the network port, it compiles but then just hangs indefinitely on:

"Sketch uses 63804 bytes (24%) of program storage space. Maximum is 262144 bytes.
Global variables use 4360 bytes of dynamic memory."

No error message or anything. If I connect USB and select the serial port, the sketch uploads fine.

Am I doing something wrong?


Juraj

please, turn on upload logging verbose mode in IDE Preferences and copy the logged output of arduinoOTA tool here

wershbersh

#2
Apr 02, 2020, 07:32 pm Last Edit: Apr 02, 2020, 07:39 pm by wershbersh
please, turn on upload logging verbose mode in IDE Preferences and copy the logged output of arduinoOTA tool here
I turned on upload logging verbose mode in IDE and all I get is:

"Sketch uses 25524 bytes (9%) of program storage space. Maximum is 262144 bytes.
Global variables use 3952 bytes of dynamic memory.
C:\Users\admin\Documents\ArduinoData\packages\arduino\tools\arduinoOTA\1.2.1/bin/arduinoOTA -address 192.168.86.149 -port 65280 -username arduino -password -sketch C:\Users\admin\AppData\Local\Temp\arduino_build_935012/ArdunioOTAWiFi101.ino.bin -upload /sketch -b "


Maybe I have a firewall issue? Is there a good way to check that?

Juraj

value for password is missing after -password
didn't the IDE ask for password?

wershbersh

value for password is missing after -password
didn't the IDE ask for password?
Yes - the first time I try to upload OTA I get a dialog popup that says "Type board password to upload a sketch." But if I type a password it keeps popping back up. If I just hit OK without typing anything, it seems to accept that. I don't know what the 'board password' is or how to set it, but it seems like it's currently set to null.

Juraj

Yes - the first time I try to upload OTA I get a dialog popup that says "Type board password to upload a sketch." But if I type a password it keeps popping back up. If I just hit OK without typing anything, it seems to accept that. I don't know what the 'board password' is or how to set it, but it seems like it's currently set to null.
password is the second string parameter in
ArduinoOTA.begin(WiFi.localIP(), "Arduino", "password", InternalStorage);

so it is: password

Go Up