sketch works fine on MEGA on the PRO MINI not

I have problem running my sketch, which I developed, on the Arduino MEGA with my Arduino PRO MINI 5V 16Mhz . Below u can see some schematics.

With the MEGA, my sketch works fine. I’m getting data from the bus and the oled display shows me the data. I can also control other sensor. Sending is also possible.
The MEGA takes its voltage from the computer via usb.

With the PRO MINI the OLED shows me my main menu but does not display any data like there is no bus connection. Controlling other sensors is not possible. Perhaps the PRO MINI freezes here?
I already measured the voltage, which is 4.95V. The PRO MINI takes its power from the scooter itself.

I can compile and upload my sketch on both Arduinos on the PRO MINI it takes <50% of the memory.

Other components:
I2C OLED 0.96" Screen
1N4148 Diode
0.25w 120ohm Resistor

What do u think guys? Is it perhaps just a soldering problem?

MEGA:

PRO MINI:

sketch.ino (25.6 KB)

Please post your full sketch.

If possible, you should always post code directly in the forum thread as text using code tags:

  • Do an Auto Format (Tools > Auto Format in the Arduino IDE or Ctrl + B in the Arduino Web Editor) on your code. This will make it easier for you to spot bugs and make it easier for us to read.
  • In the Arduino IDE or Arduino Web Editor, click on the window that contains your sketch code.
  • Press “Ctrl + A”. This will select all the text.
  • Press “Ctrl + C”. This will copy the selected text to the clipboard.
  • In a forum reply here, click on the reply field.
  • Click the </> button on the forum toolbar. This will add the forum’s code tags markup to your reply.
  • Press “Ctrl + V”. This will paste the sketch between the code tags.
  • Move the cursor outside of the code tags before you add any additional text to your reply.
  • Repeat the above process if your sketch has multiple tabs.

This will make it easy for anyone to look at it, which will increase the likelihood of you getting help.

If the sketch is longer than the 9000 characters maximum allowed by the forum, then it’s OK to add it as an attachment. After clicking the “Reply” button, you will see an “Attachments and other settings” link.

When your code requires a library that’s not included with the Arduino IDE please post a link (using the chain links icon on the forum toolbar to make it clickable) to where you downloaded that library from or if you installed it using Library Manger (Sketch > Include Library > Manage Libraries in the Arduino IDE or Libraries > Library Manager in the Arduino Web Editor) then say so and state the full name of the library.

sketch is now included.
library to controll the oled display: GitHub - greiman/SSD1306Ascii: Text only Arduino Library for SSD1306 OLED displays

in a few days i will upload the code as an open source project in github.

sketch.ino (25.6 KB)

Now I could be wrong, but suspect that a sketch that is vastly too long to post in a message here, quite possibly generates code that is too long to fit on an ATmega328. :astonished: :astonished:

Paul__B:
Now I could be wrong, but suspect that a sketch that is vastly too long to post in a message here, quite possibly generates code that is too long to fit on an ATmega328. :astonished: :astonished:

there are similar projects in github with much more logic build in like this one: GitHub - augisbud/m365_dashboard: Xiaomi M365 Display V0.2.
I have one those here and they work just fine with a PRO MINI controller with the same scooter

I just dont get it why my code is running without any problem with the MEGA but not the PRO MINI :confused:

Only thing that I find questionable is that you are disabling the serial receive, sending a serial message, then re-enabling the serial receive, before making sure the serial transmit is finished. But you have stated the sketch works properly on a mega, so apparently that isn't a problem.

Are you certain you have a 16MHz pro min? Although that would probably affect both the serial and I2C and your display would not work properly.

Did you make any changes between the mega and mini version of the sketch, besides changing the serial port?

david_2018:
Only thing that I find questionable is that you are disabling the serial receive, sending a serial message, then re-enabling the serial receive, before making sure the serial transmit is finished. But you have stated the sketch works properly on a mega, so apparently that isn't a problem.

Are you certain you have a 16MHz pro min? Although that would probably affect both the serial and I2C and your display would not work properly.

Did you make any changes between the mega and mini version of the sketch, besides changing the serial port?

100% sure its 5V 16Mhz bought new ones yesterday.
and also 100% sure that i just changed the serial port when swaping from MEGA to PRO MINI.

Im testing now with a breadboard.

Ok guys tested again. Took a new PRO MINI with a breadboard result is the same.. PRO MINI not working.
MEGA working...

Im just changing the Serial Port in my code when I take the PRO MINI...

Anyone an Idea ?

Does your display work with a basic example sketch of your library?

Same for the other peripherals you have connected.

Start there. Then enable one by one the other functions.

Learning about the F() and PSTR() macros can save you a lot of typing...