Power Supply

Hi Guys,

just another Question from a Arduino Dummy.

After Uploading my Sketch and Plug in the Powersupply Batterypack i think the MKR dont run my Sketch.

I tried a 5V 2.5A PowerSupply from the Raspberry Pi 3, i also tried a RAVPOWER Pack but THIS one doesnt recognize a Arduino and Power off completely.

The Only possibility to Run the Sketch from The Arduino is Power from my Computer.

Any Idea?


Please post the sketch itself and ensure you use CODE TAGS ( </> )

Also what do you have connected to the MKR ? ( a schematic even if hand drawn will be useful.)

How and where are you powering the MKR ? ( pin numbers etc are vital information. )

Never heard of a ravpower so maybe add a working LINK to that ?

Hi @voltage_at,

Does the sketch you are using have a "while(!Serial);" statement? This will cause it to block until something connects to the Serial USB port.


Thanks for your Replys!
Down below all Informations which you need.

  #include <SPI.h>
  #include <WiFi101.h>
  #include <MySQL_Connection.h>
  #include <MySQL_Cursor.h>

//Sensor Definitionen
  int tempSensor1 = A1;
  int tempSensor2 = A2;
  int tempSensor3 = A3;
  int humiSensor1 = A4;
  int humiSensor2 = A5;
  int humiSensor3 = A6;
//Sensor Definitionen

//SQL Server Connection Data
  IPAddress server_addr(myip);  // IP of the MySQL *server* here
  char user[] = "voltage";              // MySQL user login username
  char password[] = "mypass";        // MySQL user login password
//SQL Server Connection Data

//WLAN Connection Data
  byte mac_addr[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
  char ssid[] = "arduino";    // your SSID
  char pass[] = "Arduino123";       // your SSID Password
//WLAN Connection Data

    WiFiClient client;
    MySQL_Connection conn((Client *)&client);

//Begin Function
    int readSensor(int sensorPin)
    return analogRead(sensorPin); 

    void writeToSQL(int plantID,int wert,char* art)
//End Function

    //Connect to DB 
        if (conn.connect(server_addr, 3306, user, password)) {
     //Connect to DB
    //Initiate the query class instance
        MySQL_Cursor *cur_mem = new MySQL_Cursor(&conn);
    //Initiate the query class instance
        char query[128];
        sprintf(query, "UPDATE plantdb.%s SET %s = %d WHERE plantid = %d",art,art,wert,plantID);
    //Execute the query
    //Execute the query

    //Delete query or Failure
        delete cur_mem;
        Serial.println("Data recorded.");
        Serial.println("Connection failed.");
    //Delete query or Failure

void setup() {
//Begin Serial Output
  while (!Serial); // wait for serial port to connect
//Begin Serial Output

//Connect to WLAN 
   int status = WiFi.begin(ssid, pass);
   if ( status != WL_CONNECTED) {
    Serial.println("Couldn't get a wifi connection");
//Connect to WLAN 

// print out info about the WLAN Connection:
  else {
    Serial.println("Connected to network");
    IPAddress ip = WiFi.localIP();
    Serial.print("My IP address is: ");
// print out info about the WLAN Connection:

void loop() {
  //writeToSQL(1,readSensor(tempSensor1),(char *)"temperature");
  //writeToSQL(2,readSensor(tempSensor2),(char *)"temperature");
  //writeToSQL(3,readSensor(tempSensor3),(char *)"temperature");
  writeToSQL(1,readSensor(humiSensor1),(char *)"humidity");
  //writeToSQL(2,readSensor(humiSensor2),(char *)"humidity");
  //writeToSQL(3,readSensor(humiSensor3),(char *)"humidity");
  delay (60000); //1 Minute warten.

This is the RavPower Power Bank:
Ravpower Powerbank

I powered my MKR1000 with USB!
With my Mega it Works fine!
Is there a difference between a MKR and a Mega?

This is my Hardware:


There is a great deal of difference between the MEGA which uses AVR architecture and the MKR which uses the SAMD architecture..

The MKR is also designed as primarily a 3.3 volt board and the mega a 5 volt board.

The specifications are both available in the board selection descriptions and I think you would do well to read up on both to avoid damaging one of them.

I presume you have some sort of ethernet or wifi board on the mega if you are trying to run the same sketch on both..

That being the case the sketch will probably have subtle differences between the boards.

You also have the "while serial statement" in the sketch.
That will pretty much STOP the board until it is connected to a proper USB connection to a computer.
You should remark that out or delete it. for external power use even if that power is supplied by a USB connection from a power bank or similar.