Go Down

Topic: Standalone ATmega328p-pu (Read 503 times) previous topic - next topic

batista742k2

Jun 12, 2020, 12:12 am Last Edit: Jun 12, 2020, 12:55 am by CrossRoads
Hi.

I have built an electronic circuit that measures gases (natural gas, carbon monoxide, etc), just like the temperature and the humidity. This circuit shows the data on an "OLED 128x64 I2C" and sends it via Wifi for a mobile app and an SMS when the values get high. It has an alarm system as well, that consists of a buzzer and a led blinking.

Turns out that I have many thinks turned on in a (7.4v / 2.2A) battery, and I would like to know if my wiring is fine or if it is something that I may change.

I'm asking because sometimes, very rarely, I experience some crashes on the microcontroller, it may be a memory leak, so I'm letting the programme here too. But as I mentioned, with so many think turned on, it may be some kind of overload, I don't understand electronic that much, to be honest, just a beginner, have to study more.  :D


Thanks in advance.   ;)


Photo of the circuit: circuit.jpg (on the attachments)


Print of the schematics: schematics.png (on the attachments)

The code: (.ino) 382 lines (on the attachments)

CrossRoads

#1
Jun 12, 2020, 12:19 am Last Edit: Jun 12, 2020, 12:24 am by CrossRoads
Your .jpg is not attached.
For reasons I cannot explain, your .png cannot be posted with code tags, I'll try to recapture it as a .jpg and attach it.


And your code is too big, so that'll have to stay as an attachment.
Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

CrossRoads

Regarding the 328P crashing, I don't see any 0.1uF caps in your schematic.
You need one on each VCC and AVCC pin, located next to the pin and connecting to a nearby Gnd.
And a third separately from Aref to Gnd, not connected to 5V. That connection is made internally.
All the caps (decoupling capacitors) help to provide small bursts of surge current to the transistor switching that goes on inside the device.

Caps on the voltage regulators would help also. LM7805CT datasheet recommends caps on both input and output, 0.2nF I would say is woefully inadequate. I generally use 10uF on the input and 1uF on the output, mostly because I have them handy but also because I know that works well.

Your other sensors and devices would also benefit from caps on their power lines.
Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

batista742k2

Regarding the 328P crashing, I don't see any 0.1uF caps in your schematic.
Yes, you're right, my schematic is a little bit confusing and it's not completed, I made it this afternoon, sorry.

Thank you soo much, I'm seeing what you're saying, I was wondering about the capacitors too, as I add a 1000uF capacitor on the ESP8266 and a 2000uF capacitor on the SIM800L because I was experiencing some unexpected restarts due to power surges.

I will follow your suggestions and reply tomorrow, thanks again for your help and the speedy and clear response.


CrossRoads

Good luck. The additional caps should help.
Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

larryd

Appears your reset pin on the breadboard goes to a resistor but then 'not' to 5v.




No technical PMs.
If you are asked a question, please respond with an answer.
If you are asked for more information, please supply it.
If you need clarification, ask for help.

batista742k2

Appears your reset pin on the breadboard goes to a resistor but then 'not' to 5v.
You're right, I have taken it off accidentally. Thank you

pert

@batista742k2 opened another topic to discuss this issue as it might relate to issues in the code, but that is ending up also being about hardware, so it's probably best to just continue any discussion on either subject in that thread:
https://forum.arduino.cc/index.php?topic=689880

Go Up