Skip to content

Solar · Arduino Uno guide

Using CN3065 Solar Li-ion Charger Module with Arduino Uno

A 4.2 V single-cell Li-ion charger built for small solar panels: it eases off the current when the sun fades. It charges the cell only; it does not power your project.

Updated November 25, 2026 Arduino C++Also forESP32

What is the CN3065?

The CN3065 is a small linear charger for one 4.2 V lithium-ion or LiPo cell, designed to be fed by a solar panel (or 5 V from micro-USB). Most hobby boards carry a CN3065 chip, a charge-current resistor, two JST connectors for the panel and the battery, a micro-USB socket and a red/green status LED pair. It charges the cell and nothing else: there is no 5 V or 3.3 V output, and a basic module has no battery protection. To run an Arduino or ESP32 from it you add a protected cell and a boost converter such as the MT3608.

What sets it apart from a plain USB charger is how it behaves when the sun fades. If the panel cannot supply the set current, the chip's input monitor lowers the charge current instead of letting the panel voltage collapse, so charging continues at whatever the panel can give. This guide covers the specifications, every connection, how the charge cycle works, how to set the current, how to size a panel, how to power a project from it safely, and the faults you are most likely to meet. When you are ready to build, the Arduino Uno guide and the ESP32 guide add battery monitoring and a solar sensor node.

Specifications

ParameterValue
Input voltage4.4 to 6 V (absolute maximum 6.5 V)
BatteryOne Li-ion/LiPo cell
Charge voltage4.2 V ±1 %
Charge current500 mA typical, up to 1 A
Charge current formulaICH = 1800 / RISET (ohms, amps)
Precharge10 % of the set current, below about 3.0 V
TerminationAt 10 % of the set current
Recharge thresholdRestarts below about 4.1 V
Thermal regulationReduces current at about 115 °C
Sleep currentUnder 3 µA from the battery
Solar behaviourLowers the charge current when the input sags (not MPPT)
Status outputsCHRG and DONE, open-drain, drive the LEDs
Temperature inputTEMP pin for an NTC thermistor (disabled by tying it low)
Typical moduleAbout 40 × 20 mm, two JST PH2.0 connectors plus micro-USB

Pinout

PinNameDescription
1SOLAR+Panel positive (JST PH2.0). Open-circuit voltage must stay at or below 6 V
2SOLAR−Panel negative
3BAT+Battery positive (JST PH2.0). Connect the cell here, not a load
4BAT−Battery negative and common ground
5USBMicro-USB 5 V input, an alternative to the panel

Wiring & code

Setting up CN3065 with Arduino Uno

The CN3065 charges a cell; it does not power anything. This guide shows how to run an Arduino Uno from a solar-charged cell through a boost converter, and how to read the battery and panel voltage so the Uno knows how much energy is left. Three sketches build up from a battery-level readout to a sun-and-battery logger and a low-battery guard. For the module itself, specifications and panel sizing, read the CN3065 overview first.

What you need

  • 1Arduino Uno R3 (or Nano)

    Notes
    Any 5 V Arduino uses the same wiring
  • 1CN3065 solar charger module

    Notes
    Set to a charge current that suits your cell
  • 1Small solar panel

    Notes
    Open-circuit voltage under 6 V, about 1 to 3 W
  • 1Protected single Li-ion/LiPo cell

    Notes
    A protected 18650 or flat LiPo pack, 4.2 V full
  • 1MT3608 boost converter

    Notes
    Set to exactly 5.0 V with a meter before connecting the Uno
  • 4100 kΩ resistors

    Notes
    Two voltage dividers: battery on A0, panel on A1
  • 2100 nF capacitors

    Notes
    One from each analog pin to GND, steadies the readings
  • 1Breadboard and jumper wires

Wiring

  • Cell → CN3065 BAT+/BAT−—

    Notes
    Connect the protected cell to the module's battery connector, polarity checked
  • Panel → CN3065 SOLAR+/SOLAR−—

    Notes
    Check polarity and Voc (below 6 V) before plugging in
  • Cell BAT+ → MT3608 IN+; BAT− → IN−—

    Notes
    Powers the converter from the cell
  • MT3608 OUT+ (5.0 V)5V

    Notes
    Into the 5V pin, not VIN. Bypasses the Uno's regulator, so set 5.0 V first
  • MT3608 OUT− and BAT−GND

    Notes
    All grounds joined
  • BAT+ → 100 kΩ → A0 → 100 kΩ → GNDA0

    Notes
    Divider halves the cell voltage (4.2 V reads as 2.1 V). Add a 100 nF capacitor from A0 to GND
  • SOLAR+ → 100 kΩ → A1 → 100 kΩ → GNDA1

    Notes
    Halves the panel voltage (up to 6 V reads as 3 V). Add a 100 nF capacitor from A1 to GND

Warning

Set the MT3608 output to 5.0 V with a multimeter before it is connected to the Uno. These modules often ship with the trimmer near maximum (up to roughly 28 V), which would destroy the board. Feed the 5 V into the 5V pin, never VIN, and never connect USB and the boost converter to the Uno at the same time.

How the readings work

The Uno's ADC reads 0 to 5 V, but a full cell is 4.2 V and a panel can reach 6 V, so each is divided by two with two equal resistors. The sketch multiplies the reading back by two. With the 5 V rail at exactly 5.00 V, A0 = 430 means 2.1 V at the pin, so the cell is at 4.2 V.

Two details make the readings trustworthy:

  • Calibrate VREF. The ADC measures against the 5 V rail, which the boost converter holds only roughly. Measure the rail with a multimeter and enter the value as VREF.
  • Add the capacitor and average. A 100 kΩ divider has high source impedance, so the 100 nF capacitor and averaging 16 samples stop the reading wandering.

The divider also draws a small current: 4.2 V ÷ 200 kΩ ≈ 21 µA, constantly. For a long-life battery node use 1 MΩ resistors (about 2 µA), at the cost of a little accuracy.

Sketch 1 - Battery level readout

Prints the cell voltage and an estimated percentage every two seconds. The percentage is an estimate from a resting-cell lookup, so it reads low under heavy load and high just after charging.

sketch.ino
const int BAT_PIN = A0;
const float R_TOP = 100000.0;      // BAT+ to A0
const float R_BOTTOM = 100000.0;   // A0 to GND
const float VREF = 5.00;           // measure the 5V pin with a multimeter and enter it here

// Resting-cell lookup: approximate, depends on the cell and the load
const float V_TABLE[] = {3.30, 3.50, 3.60, 3.70, 3.80, 3.90, 4.00, 4.10, 4.20};
const int   P_TABLE[] = {   0,   10,   20,   35,   50,   65,   80,   90,  100};
const int   N = 9;

int percentFromVolts(float v) {
  if (v <= V_TABLE[0]) return 0;
  if (v >= V_TABLE[N - 1]) return 100;
  for (int i = 1; i < N; i++) {
    if (v <= V_TABLE[i]) {
      float f = (v - V_TABLE[i - 1]) / (V_TABLE[i] - V_TABLE[i - 1]);
      return P_TABLE[i - 1] + f * (P_TABLE[i] - P_TABLE[i - 1]);
    }
  }
  return 100;
}

float readBatteryVolts() {
  long sum = 0;
  for (int i = 0; i < 16; i++) { sum += analogRead(BAT_PIN); delay(2); }
  float adc = sum / 16.0;
  float vPin = adc * VREF / 1023.0;
  return vPin * (R_TOP + R_BOTTOM) / R_BOTTOM;
}

void setup() {
  Serial.begin(9600);
}

void loop() {
  float v = readBatteryVolts();
  Serial.print("Battery: ");
  Serial.print(v, 2);
  Serial.print(" V  (about ");
  Serial.print(percentFromVolts(v));
  Serial.println(" %)");
  delay(2000);
}

Sketch 2 - Sun and battery logger

Prints the panel and battery voltages in the format the Serial Plotter understands, so you can watch a charge as it happens. Open Tools > Serial Plotter and cover or uncover the panel.

sketch.ino
const int BAT_PIN = A0;
const int PANEL_PIN = A1;
const float VREF = 5.00;           // measure the 5V pin with a multimeter

float readDivided(int pin) {
  long sum = 0;
  for (int i = 0; i < 16; i++) { sum += analogRead(pin); delay(2); }
  return (sum / 16.0) * VREF / 1023.0 * 2.0;   // both dividers are 1:2
}

void setup() {
  Serial.begin(9600);
}

void loop() {
  float bat = readDivided(BAT_PIN);
  float panel = readDivided(PANEL_PIN);
  Serial.print("Panel:");
  Serial.print(panel, 2);
  Serial.print(",Battery:");
  Serial.println(bat, 2);
  delay(1000);
}

Reading the graph. In full sun the panel line sits well above the battery line (5 V or more against 3.7 to 4.2 V) and the battery line creeps upward as it charges. In shade the panel line drops towards the battery voltage and the battery stops rising. At night the panel reads near zero. If the panel line collapses below about 4.4 V whenever the charge current rises, the panel is too weak for the set current.

Sketch 3 - Low-battery guard

Flashes the onboard LED when the cell drops low, with hysteresis so it does not flicker around the threshold. This is a warning, not protection: a protected cell is still required.

sketch.ino
const int BAT_PIN = A0;
const int LED_PIN = 13;
const float VREF = 5.00;
const float LOW_ON = 3.50;        // warn below this
const float LOW_OFF = 3.70;       // clear above this
bool low = false;

float readBatteryVolts() {
  long sum = 0;
  for (int i = 0; i < 16; i++) { sum += analogRead(BAT_PIN); delay(2); }
  return (sum / 16.0) * VREF / 1023.0 * 2.0;
}

void setup() {
  pinMode(LED_PIN, OUTPUT);
  Serial.begin(9600);
}

void loop() {
  float v = readBatteryVolts();
  if (!low && v < LOW_ON) low = true;
  if (low && v > LOW_OFF) low = false;

  if (low) {
    digitalWrite(LED_PIN, HIGH); delay(100);
    digitalWrite(LED_PIN, LOW);  delay(100);
    Serial.println("Battery LOW: shut loads down");
  } else {
    digitalWrite(LED_PIN, LOW);
    Serial.print("Battery OK: ");
    Serial.println(v, 2);
    delay(1000);
  }
}

Uno power notes

  • An Uno draws roughly 45 mA when running, so a 2,000 mAh cell lasts about two days without sun, before converter losses. For longer runs use the Uno's sleep modes or move to a low-power board.
  • The 5V pin feeds the board directly. There is no polyfuse or reverse-polarity protection on that path, so double-check the polarity at the MT3608 output.
  • If the Uno resets when a motor or relay starts, the boost converter or cell cannot supply the surge. Add a 470 µF capacitor across the 5 V rail.
  • See the Arduino Uno pinout guide for analog pin numbers and limits.

Uno-specific problems

  • Battery reads half the real voltage, or double

    Likely cause
    Divider ratio does not match the sketch
    Fix
    Check both resistors are 100 kΩ, and that the sketch multiplies by 2
  • Reading jumps around

    Likely cause
    High-impedance divider without a capacitor
    Fix
    Add 100 nF from the analog pin to GND; keep the averaging
  • Reading is a few percent off

    Likely cause
    5V rail is not exactly 5.00 V
    Fix
    Measure the 5V pin and set VREF
  • Uno does not power up

    Likely cause
    MT3608 not set to 5 V, or polarity reversed
    Fix
    Check the converter output with a meter before connecting
  • Uno resets under load

    Likely cause
    Boost converter or cell cannot supply the surge
    Fix
    Add a 470 µF capacitor; check the cell and wiring
  • Percentage seems wrong under load

    Likely cause
    Voltage sags while the Uno is running
    Fix
    Treat the percentage as an estimate; log voltage for a fuller picture

Arduino Uno FAQ

Why not connect the module straight to the Uno? The CN3065 has no regulated output. It charges a cell; the cell voltage (3.0 to 4.2 V) is below what the Uno needs, so a boost converter brings it to 5 V.

Can I use the VIN pin? No. VIN expects 7 to 12 V and feeds the Uno's own regulator. Feed regulated 5 V into the 5V pin.

Can I measure the panel voltage safely? Yes, with the divider shown. Keep the panel under 6 V and never connect it straight to an analog pin.

Does this work with a Nano? Yes. The wiring and code are the same, using the Nano's A0 and A1.

Next: the CN3065 overview covers panel sizing and the charge cycle. For a node that sleeps and reports over Wi-Fi, see the ESP32 guide.

Keep learning

Related guides & projects