That depends on your own risk tolerance. My personal minimum threshold for a self connection is 4 hours, more if there are extra "difficulties".
BKK is fairly straight forward to maneuver and since you have only carry-on luggage, 4 hours feel quite safe . It's a long hike to the domestic terminal go through immigration & security but typically lines are not too long and move at a decent pace. Worst case numbers reported seem to hover around 1 hour. You can accelerate this by paying extra for VIP service https://www.klook.com/activity/11690-suvarnabhumi-airport-immigration-fast-track-service-bangkok/
The main problem with a self connection is that you may lose your second ticket if you are late. Since even same day flights from BKK to Chiang Mai are plentiful and cheap and you have full day of flights options, you can also cut it closer. If you miss, just buy a new ticket on the spot. Roundtrip tickets for tomorrow start at US$62 dollars. You may also be able to sweet talk the domestic airline to rebook for free or for a small fee.