As mentioned above, it can be very difficult or impossible to prevent people from reverse engineering or otherwise duplicating your product, most especially if you have limited resources for legal protection and enforcement of your rights. So instead of wasting a bunch of effort on that, you might consider a different paradigm.
Make your code and hardware design open source. Design the product so that it can be easily programmed with custom firmware. Welcome contributions from the community to your code and designs.
This can add significant value to your product. You may find that you will get customers who are specifically interested in the product due to the ability to tinker and customize. You may find that customers will give preference to your product over the copycats because you are the "good guy". Publishing innovations in this manner can convey an impression of "ownership" in the eyes of the community that keeping it a trade secret or patenting never would.
And if you study the licenses of any code or hardware designs you are using, you might discover that you are legally obligated to do this sharing in any case.