Go Down

Topic: Power Supply (Read 984 times) previous topic - next topic

voltage_at

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?

Thanks!

ballscrewbob

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 ?
It may not be the answer you were looking for but its the one I am giving based on either experience, educated guess, google or the fact that you gave nothing to go with in the first place so I used my wonky crystal ball.

sandeepmistry

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.

voltage_at

#3
Apr 06, 2017, 09:09 am Last Edit: Apr 06, 2017, 09:21 am by voltage_at
Hi,

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

Code: [Select]

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

//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

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

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

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

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

    //Delete query or Failure
        delete cur_mem;
        Serial.println("Data recorded.");
        }
        else
        Serial.println("Connection failed.");
        conn.close();
        }
    //Delete query or Failure
//SQL END

void setup() {
//Begin Serial Output
  Serial.begin(115200);
  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");
    while(true);
  }
//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: ");
    Serial.println(ip);
  }
// print out info about the WLAN Connection:
 
}


void loop() {
  Serial.println(readSensor(tempSensor1));
  //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:


Thanks!



ballscrewbob

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.
It may not be the answer you were looking for but its the one I am giving based on either experience, educated guess, google or the fact that you gave nothing to go with in the first place so I used my wonky crystal ball.

Go Up