Need help fault finding a custom PCB
I was wondering if you could see something wrong that I couldn't. (Hopefully it's not something glaringly obvious :-) )

Summary: Yes, there are a few problems that I can see. You might find more as you fix these, or afterwards.

Your current 20 April 2021 version of the schematic shows an ATmega328P with 32 pins, so that looks like the TQFP package. Then it shows you supplying power on VCC pin 4 and AVCC on pin 18. That means you aren't powering all the required pins. You must also power the other VCC pin 6, for reliable operation.

Similarly for GND, your schematic shows only GND on pin 3 being used. You must connect the other GND pins 5 and 21, for reliable operation.

On the schematic, the only decoupling capacitors are for the voltage regulator - none shown for the MCU. That apparent lack of decoupling could also affect reliable operation.

It seems that you have a power switch SW1 that can connect VCC (5 V from a 7805) to VCCIN which is the battery voltage. Connecting 5 V to the LiPo battery is a very bad idea and could result in the battery overheating, rupturing or exploding, fire, personal injury, property damage etc.

The charging circuit is also incorrect - details below.

There are too many issues for me to provide images &amp; fixes for all of them, but I have given some pointers at least.


In short: As you see, there are several problems. Instead of trying to debug it all in one go, I recommend you simplify &amp; divide your work. For example (and there are many possible debugging approaches here): Get just the MCU running (e.g. a blink LED program), from a bench power supply, with the battery &amp; charging circuit removed / disconnected. Cut related PCB traces if you have to, to disconnect the battery &amp; charging circuit from the MCU. When the MCU on its own is reliable, then add the I2C display, and get that working reliably. Check and understand its power rails, its expected I2C voltage and any I2C pull-up resistors used on the display board. Then fix the errors with the charging circuit, and only when that charging IC and the STAT LED are tested &amp; working correctly, connect that part of the system to the working MCU. (As I said, other approaches are possible - that is just one of them.)

Details of problems with the charging circuit:
Some problems can be seen in charging circuit on the current 20 April 2021 version of the schematic pdf file.
It shows the STAT output connected to the VBAT output. I have marked the problem here:

The block diagram in the MCP73831 datasheet shows that STAT on the MCP73831 can be driven up to VDD i.e. about 5 V (to indicate &quot;charge complete&quot;) - but on your schematic STAT is also connected to VBAT e.g. 3 V (dead battery) up to 4.2 V (fully charged battery). I don't know what will happen exactly, but excessive current could flow between the two voltage sources (VDD and VBAT), through the &quot;upper&quot; P-channel MOSFET on the STAT pin, when the device tries to drive STAT high. Conversely, when it tries to drive STAT low during charging, excessive current could flow through the &quot;lower&quot; N-channel MOSFET on the STAT pin. I would not be surprised if the MCP73831 device could be damaged by this error.
Also, the LED (D2 in your schematic) is intended to be driven from VDD. Here is the schematic from the MCP73831 datasheet:

Comparing those two images, we also see there is a small decoupling capacitor missing at the VDD pin on your schematic (but you cannot exceed 10 uF, which is a limit for USB devices - stick with the 4.7 uF shown on the Microchip datasheet).