0

Solar panel and battery recommendations for Arduino Uno
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Solar panel and battery recommendations for Arduino Uno

by jdetka on Tue Dec 22, 2020 12:09 am

Hello Everyone,
Can anyone provide some suggestions on a solar panel and rechargable battery set-up for the an Arduino Uno.
I've built a little datalogger with the Arduino Uno R3, DHT-11 Temp/RH, and YL-83 Rain sensor. My build is posted in Project Arduino
https://create.arduino.cc/projecthub/jdetka/solar-powered-datalogger-plant-disease-weather-conditions-f8cd38

I installed an Adafruit Datalogging Shield to store data to an SD card with with a datetime stamp.

Any suggestions welcome.

~ JD

jdetka
 
Posts: 8
Joined: Tue Dec 22, 2020 12:02 am

Re: Solar panel and battery recommendations for Arduino Uno

by millercommamatt on Tue Dec 22, 2020 1:05 pm

What's your power draw?

millercommamatt
 
Posts: 586
Joined: Tue Jul 31, 2018 4:57 pm

Re: Solar panel and battery recommendations for Arduino Uno

by jdetka on Tue Dec 22, 2020 1:15 pm

Hi millercommamatt,
I'm not completely sure but it ran a 9v battery down to 5v in less 2.5 hours.
I tried putting an ammeter between the + lead and when logging it read 1873 mA. I think I may have had my ammeter set wrong.

jdetka
 
Posts: 8
Joined: Tue Dec 22, 2020 12:02 am

Re: Solar panel and battery recommendations for Arduino Uno

by adafruit_support_bill on Tue Dec 22, 2020 1:29 pm

A 9v battery is not a particularly efficient power source - especially since the Arduino's regulator is a linear type, so the extra 4v is just burned off as heat.

An UNO typically draws about 25-30mA. The sensor data sheets should have typical current draws for those. Mike has an informative guide on how to calculate energy budgets here: https://learn.adafruit.com/energy-budgets

For solar power, you need to consider The current draw from your load and storage capacity of your battery. And you also need to consider the available sunlight hours and the charge rate of your system.

One simple improvement to make your system more efficient would be to replace the UNO with a 3.3v processor like a Metro M0. That way, you could use a simple 3.7v LiPo cell and not have the inefficiency of a boost converter to get you to 5v.
https://www.adafruit.com/product/3505

This is our latest solar charger here: https://www.adafruit.com/product/4755

adafruit_support_bill
 
Posts: 80362
Joined: Sat Feb 07, 2009 10:11 am

Re: Solar panel and battery recommendations for Arduino Uno

by jdetka on Tue Dec 22, 2020 2:14 pm

Thank you so much adafruit_support_bill!

I checked out Mike's guide and it was helpful conceptually. I'm new to Arduinos and not sure where and how to measure the draw. I attached my ammeter inline on the + terminal of the DC power source (9V battery). I've got the Adafruit SD/RTC Datalogger connected to the Uno and it successfully collects from a DHT-11 Temp/RH sensor and FC-37 Raindrop sensor. But, I was getting strange current measurements when I used the same approach. I'll take a look at the datasheets and do the math.

Thanks for the suggestion on the Metro M0. This literally my first build and so I started with an UNO but it sounds like I should set up a metro.
Will the Metro M0 work with the Adafruit SD/RTC datalogger too?

Thank you for the link to the latest solar charger. It looks like it is currently out of stock but I got on the contact list. I also wasn't sure if I could connect the 4755 solar charger as a battery manager. I'm aiming to make an inexpensive datalogger that can stay in the field and manage recharging.

I was successful getting this to work with some old Campbell CR500 datalogger systems I rescued from the trash but they are cumbersome and I won't be able to fabricate more.

Thank you again for your help. I am enjoying learning and the Adafruit community is awesome!

~ JD

jdetka
 
Posts: 8
Joined: Tue Dec 22, 2020 12:02 am

Re: Solar panel and battery recommendations for Arduino Uno

by jdetka on Tue Dec 22, 2020 2:19 pm

I realized I can just attach the ammeter inline on the VCC of the sensor. Learning. :-)

DHT-11 Temperature / Relative Humidity: Measure 0.3mA Standby 60μA

jdetka
 
Posts: 8
Joined: Tue Dec 22, 2020 12:02 am

Re: Solar panel and battery recommendations for Arduino Uno

by adafruit_support_bill on Tue Dec 22, 2020 3:54 pm

The M0 will work fine with the data logger shield - as well as your sensors. The solar charger will charge the battery during sunlight hours and divert any excess solar energy to your logger system. When the sun goes down it will automatically switch over to battery power.

adafruit_support_bill
 
Posts: 80362
Joined: Sat Feb 07, 2009 10:11 am

Re: Solar panel and battery recommendations for Arduino Uno

by jdetka on Tue Dec 22, 2020 4:23 pm

Fantastic news! Thank you.
I'll keep an eye out for when the solar charging unit is available again.
I'm planning to build 10 (potentially 20) of these datalogger rigs with my undergraduate interns and deploy them across my 600 acre research site.

One more question if you have a moment. I've followed your tutorial setting up the SD / RTC Datalogger shield and I was curious if there is a way to replace the delay() with a function that integrates some power saving code where the RTC triggers a power up (wake) --> data collect --> power save (sleep) cycle on a 10 minute interval. I'm new to coding in Arduino but I've build a delay() based working sketch. Any recommendations are extremely welcome.

Thank you again for your time.

~ JD

Code: Select all | TOGGLE FULL SIZE
// Arduino Plant Disease Ecology Weather Station with Sleep Mode
// Available at https://github.com/jdetka/arduino_sensors/blob/main/digital_dht_fc-37_sleep_sd_rtc_201220.ino

#include <SD.h>
#include <Wire.h>
#include <dht.h>
#include "RTClib.h"

// how many milliseconds between grabbing data and logging it.
#define LOG_INTERVAL  600000 // mills between entries.

// how many milliseconds before writing the logged data permanently to disk
// set it to the LOG_INTERVAL to write each time (safest)
// set it to 10*LOG_INTERVAL to write all data every 10 datareads, you could lose up to
// the last 10 reads if power is lost but it uses less power and is much faster!
#define SYNC_INTERVAL 1000 // mills between calls to flush() - to write data to the card
uint32_t syncTime = 0; // time of last sync()

#define ECHO_TO_SERIAL   1 // echo data to serial port
#define WAIT_TO_START    0 // Wait for serial input in setup()
 
// Define temperature & relative humidity sensor DHT_11
dht DHT;
#define dhtPin 2       // Data Digital Pin 2
#define dhtPower 3     // Data Digital Pin 3

// Define wetness sensor FC-37 with potentiometer
#define leafPin 8    // Data Digital Pin 8
#define leafPower 9  // Power Digital Pin 9

RTC_PCF8523 RTC; // define the Real Time Clock object

const int chipSelect = 10; // Set to pin 10 for Arduino R3 Uno

// the logging file
File logfile;

void error(char *str)
{
  Serial.print("error: ");
  Serial.println(str);
 
  // red LED indicates error
  // digitalWrite(redLEDpin, HIGH);

  while(1);
}

// Intial settings;
void setup(void)
{
    Serial.begin(9600);
    Serial.println();
   
  pinMode(leafPower,OUTPUT);
  pinMode(dhtPower, OUTPUT);
 
  pinMode(LED_BUILTIN,OUTPUT);
  digitalWrite(LED_BUILTIN,LOW);
 
  digitalWrite(leafPower, LOW);
  digitalWrite(dhtPower, LOW);

  #if WAIT_TO_START
    Serial.println("Type any character to start");
    while(!Serial.available());
  #endif //WAIT_TO_START

  // initialize the SD card
  Serial.print("Initializing SD card...");
  // make sure that the default chip select pin is set to
  // output, even if you don't use it:
  pinMode(10, OUTPUT);

// see if the card is present and can be initialized:
  if (!SD.begin(chipSelect)) {
    error("Card failed, or not present");
  }
  Serial.println("card initialized.");
 
  // create a new file
  char filename[] = "LOGGER00.CSV";
  for (uint8_t i = 0; i < 100; i++) {
    filename[6] = i/10 + '0';
    filename[7] = i%10 + '0';
    if (! SD.exists(filename)) {
      // only open a new file if it doesn't exist
      logfile = SD.open(filename, FILE_WRITE);
      break;  // leave the loop!
    }
  }
 
  if (! logfile) {
    error("couldnt create file");
  }
 
  Serial.print("Logging to: ");
  Serial.println(filename);

  // connect to RTC
  Wire.begin(); 
  if (!RTC.begin()) {
    logfile.println("RTC failed");
#if ECHO_TO_SERIAL
    Serial.println("RTC failed");
#endif  //ECHO_TO_SERIAL
  }
 
  logfile.println("datetime,lw,temp,rh");   
#if ECHO_TO_SERIAL
  Serial.println("datetime,lw,temp,rh");
#endif //ECHO_TO_SERIAL
 
  // If I want to set the aref to something other than 5v
  analogReference(EXTERNAL);
}

void loop(void)
{
  DateTime now;

  // delay for the amount of time we want between readings
  delay((LOG_INTERVAL -1) - (millis() % LOG_INTERVAL));
 
  // digitalWrite(greenLEDpin, HIGH);
 
  // log milliseconds since starting
  // uint32_t m = millis();
  // logfile.print(m);         // milliseconds since start
  // logfile.print(", ");   
#if ECHO_TO_SERIAL
  // Serial.print(m);         // milliseconds since start
  // Serial.print(", "); 
#endif

  // fetch the time
  now = RTC.now();
  // log time
  // logfile.print(now.unixtime()); // seconds since 1/1/1970
//  logfile.print(", ");
//  logfile.print('"');
  logfile.print(now.year(), DEC);
  logfile.print("/");
  logfile.print(now.month(), DEC);
  logfile.print("/");
  logfile.print(now.day(), DEC);
  logfile.print(" ");
  logfile.print(now.hour(), DEC);
  logfile.print(":");
  logfile.print(now.minute(), DEC);
  logfile.print(":");
  logfile.print(now.second(), DEC);
//  logfile.print('"');
  logfile.print(", ");
#if ECHO_TO_SERIAL
  //Serial.print(now.unixtime()); // seconds since 1/1/1970
  //Serial.print(", ");
  //Serial.print('"');
  Serial.print(now.year(), DEC);
  Serial.print("/");
  Serial.print(now.month(), DEC);
  Serial.print("/");
  Serial.print(now.day(), DEC);
  Serial.print(" ");
  Serial.print(now.hour(), DEC);
  Serial.print(":");
  Serial.print(now.minute(), DEC);
  Serial.print(":");
  Serial.print(now.second(), DEC);
  //Serial.print('"');
  // Serial.print(", ");
#endif //ECHO_TO_SERIAL

// Get data from DHT-11
  //  digitalRead(dhtPin);
  //  delay(2000);
  // int dhtReading = DHT.read11(dhtPin); // DHT11

  // float t = DHT.temperature;
  // float h = DHT.humidity;

digitalWrite(LED_BUILTIN,HIGH); // Flash the light!
int dhtData = dhtRead();    // Read DHT sensor
 
// Take leaf wetness reading
//  delay(2000);
//  int val = digitalRead(leafPin);

// Take leaf wetness reading
  int val = readSensor();
 
// Determine status of leaf wetness sensor
  if (val) {
    Serial.print(", ");
    Serial.print("Dry");
   
    logfile.print("Dry");
    logfile.print(", ");
   
  } else {
    Serial.print(", ");
    Serial.print("Wet");
   
    logfile.print("Wet");
    logfile.print(", ");
  }
   
//  logfile.print(dhtReading); 
  logfile.print(DHT.temperature);
  logfile.print(", ");
  logfile.print(DHT.humidity);
  logfile.println();
 
#if ECHO_TO_SERIAL

//  Serial.print(dhtReading);
  Serial.print(", ");
  Serial.print(DHT.temperature);
  Serial.print(", ");
  Serial.print(DHT.humidity);
  Serial.println();
 
#endif //ECHO_TO_SERIAL

  // digitalWrite(greenLEDpin, LOW);

  // Now we write data to disk! Don't sync too often - requires 2048 bytes of I/O to SD card
  // which uses a bunch of power and takes time
  if ((millis() - syncTime) < SYNC_INTERVAL) return;
  syncTime = millis();
 
//  // blink LED to show we are syncing data to the card & updating FAT!
//  digitalWrite(redLEDpin, HIGH);
logfile.flush();
//  digitalWrite(redLEDpin, LOW);
 
}

//  Function to wake-up leaf wetness sensor and return digital value (0 = wet, 1 = dry).
int readSensor() {
  digitalWrite(leafPower, HIGH);  // Turn the sensor ON
  delay(10);              // Allow power to settle
  int val = digitalRead(leafPin); // Read the sensor output
  digitalWrite(leafPower, LOW);   // Turn the sensor OFF
  return val;             // Return the value
}

//  Function to return DHT-11 Temperature & RH digital values
int dhtRead() {
  digitalWrite(dhtPower, HIGH);      // Turn the sensor ON
  delay(2000);                       // Allow time for sensor to collect.
  int dhtData = DHT.read11(dhtPin); // Read the sensor output
  digitalWrite(dhtPower, LOW);   // Turn the sensor OFF
  return dhtData;             // Return the values
  return DHT.temperature;
  return DHT.humidity;
}

jdetka
 
Posts: 8
Joined: Tue Dec 22, 2020 12:02 am

Re: Solar panel and battery recommendations for Arduino Uno

by adafruit_support_bill on Tue Dec 22, 2020 5:23 pm

Yes. Most microcontrollers have some sort of power-saving mode. These tend to be fairly processor specific. The M0 is a more modern processor design than the UNO and has more advanced power management capabilities. The SleepyDog library supports power management on several differentprocessor types. https://github.com/adafruit/Adafruit_SleepyDog

adafruit_support_bill
 
Posts: 80362
Joined: Sat Feb 07, 2009 10:11 am

Re: Solar panel and battery recommendations for Arduino Uno

by jdetka on Tue Dec 22, 2020 5:50 pm

Very cool. I will definitely put an Metro M0 on my shopping list too.

Thanks for the tip on the Sleepy_Dog library.

jdetka
 
Posts: 8
Joined: Tue Dec 22, 2020 12:02 am

Please be positive and constructive with your questions and comments.