MKR Wifi 1010 dropping off of wifi when unplugged from USB

Edit: I forgot to add that I connected my MKR 1010 to the Cloud thing. That updated the NINA firmware to the latest version for me so I did make sure of that.

Hey guys. Got my first Arduino with wifi built (MKR Wifi 1010) in and using the online editor tools and this thing is super cool!

Running into a problem, however. My project is working great when connected to the USB, but as soon as I disconnect the USB it drops off of the wireless (I can see this when looking in my router at connected devices). I plug the USB back in and it reconnects. Unplug and it disconnects.

I have the 1010 powered by a 3.7v LiPo battery through the VIN and GND. And there is a DHT22 temp/humidity sensor plugged in, but that is all. Testing the battery says it is putting out about 3.8v.

Is this an issue of not enough power maybe? I didn't want to use 2 of these batteries because I thought it might ruin the whole board!

I never restart the Arduino or reload the sketch. I simply plug it into USB and it shows on my router, then unplug and it drops off of my router. Plug it in and it connects, repeat. The sketch is running the entire time in its loop.

Here is my code. Any help is appreciated. I am so excited to get this project working and getting so close after a crazy amount of hours that I shouldn't admit publicly lol. Lots to learn. =)

  Repeating WiFi Web Client

 This sketch connects to a a web server and makes a request
 using a WiFi equipped Arduino board.

 created 23 April 2012
 modified 31 May 2012
 by Tom Igoe
 modified 13 Jan 2014
 by Federico Vanzati
 This code is in the public domain.

#include <SPI.h>
#include <WiFiNINA.h>
#include <Adafruit_Sensor.h>
#include <DHT.h>

// Set DHT pin:
#define DHTPIN 2
#define DHTTYPE DHT22   // DHT 22  (AM2302)

// Initialize DHT sensor for normal 16mhz Arduino:

///////please enter your sensitive data in the Secret tab/arduino_secrets.h
char ssid[] = SECRET_SSID;        // your network SSID (name)
char pass[] = SECRET_PASS;    // your network password (use for WPA, or use as key for WEP)
int keyIndex = 0;            // your network key index number (needed only for WEP)

int status = WL_IDLE_STATUS;

// Initialize the WiFi client library
WiFiClient client;

// server address:
char server[] = "";
//IPAddress server(192,168,50,211);

unsigned long lastConnectionTime = 0;            // last time you connected to the server, in milliseconds
const unsigned long postingInterval = 10L * 1000L; // delay between updates, in milliseconds

void setup() {
  //Initialize serial and wait for port to open:
  //while (!Serial) {
  //  ; // wait for serial port to connect. Needed for native USB port only

  // check for the WiFi module:
  if (WiFi.status() == WL_NO_MODULE) {
    Serial.println("Communication with WiFi module failed!");
    // don't continue
    while (true);

  String fv = WiFi.firmwareVersion();
    Serial.println("Please upgrade the firmware");

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

    // wait 10 seconds for connection:
  // you're connected now, so print out the status:
  //Initialize sensor

void loop() {
  // if there's incoming data from the net connection.
  // send it out the serial port.  This is for debugging
  // purposes only:
  while (client.available()) {
    char c =;

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

    // wait 10 seconds for connection:
    // you're connected now, so print out the status:
  // if ten seconds have passed since your last connection,
  // then connect again and send data:
  if (millis() - lastConnectionTime > postingInterval) {


// this method makes a HTTP connection to the server:
void httpRequest() {
  // close any connection before send a new request.
  // This will free the socket on the NINA module
  //Read the humidity
  float h = dht.readHumidity();
  // Read the temperature as Fahrenheit:
  float f = dht.readTemperature(true);

  // if there's a successful connection:
  if (client.connect(server, 80)) {

    String body = "{\n    \"Humidity\": \"" + String(h) + "\",\n    \"Temperature\": \"" + String(f) + "\",\n    \"DataSourceId\": \"1\"\n}";

    // note the time that the connection was made:
    lastConnectionTime = millis();
  } else {
    // if you couldn't make a connection:
    Serial.println("connection failed");

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

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

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

void postData(String body) {
// send HTTP request header
  client.println("POST /api/DataSensors/AddDht22SensorData HTTP/1.1");
  Serial.println("POST /api/DataSensors/AddDht22SensorData HTTP/1.1");
  client.println("Host: " + String(server));
  Serial.println("Host: " + String(server));
  client.println("Content-Type: application/json");
  Serial.println("Content-Type: application/json");
  client.println("Accept: */*");
  Serial.println("Accept: */*");
  client.println("User-Agent: ArduinoWiFi/1.1");
  Serial.println("User-Agent: ArduinoWiFi/1.1");
  client.println("Cache-Control: no-cache");
  Serial.println("Cache-Control: no-cache");
  client.println("Accept-Encoding: gzip, deflate");
  Serial.println("Accept-Encoding: gzip, deflate");
  client.println("Accept-Language: en-us");
  Serial.println("Accept-Language: en-us");
  client.println("Content-Length: " + String(body.length())); //ANSWER: body.length() needs to be wrapped as a string, see above
  Serial.println("Content-Length: " + String(body.length()));
  client.println("Connection: close");
  Serial.println("Connection: close");
  client.println(); // end HTTP request header

Going to reply here to myself in case anyone out there reads this and is in the same boat as I am. Coincidentally I had a 5v voltage regulator show up today. I popped that little guy on there and am now getting wireless as I want to using a 12v wall plug -> the new 5v regulator - > VIN and GND pins on the Arduino MRK Wifi 1010.

Important: I also got it to work with 2 of the 3.7v LiPo batteries -> regulator -> Arduino MKR Wifi 1010.

The voltage regulator is a Pololu 5V, 2.5A Step-Down Voltage Regulator Model D24V25F5.

Feel free to rip off my code. You will need to either use a secrets file or just put your SSID and password for your wireless in there. Use pin 2 for the DHT22 temperature/humidity sensor.

I now need to see how reliable the wireless is when it drops off and if it can reconnect. I have seen some other forum posts about using a state machine like this - MKR1010 WIFI won't stay online for more than 20hrs

And I need to do some low power mode. Good news is I have a temp/humidity wireless monitor now and I am super excited about it.

Hello. Thanks for your updating. I think I am having a similar problem to you when I unplug my mkr1010 and power it with batteries. Actually I have this error:
at cc.arduino.packages.uploaders.SerialUploader.uploadUsingPreferences(
at cc.arduino.UploaderUtils.upload(
Caused by: Error touching serial port 'COM3'.
at cc.arduino.packages.uploaders.SerialUploader.uploadUsingPreferences(
... 5 more
Caused by: jssc.SerialPortException: Port name - COM3; Method name - openPort(); Exception type - Port not found.
at jssc.SerialPort.openPort(
... 6 more

I am considering also to buy the regulator you are talking about. I would like to know if your Arduino showed also this input as an error before you fixed it with the regulator.

Thanks in advance :smiley:

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.