Can I program microcontrollers in Kotlin?

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP



Can I program microcontrollers in Kotlin?



Is it possible somehow to program Arduino or ESP8266 microcontrollers on Kotlin?
Same question about single-board computers (i.e. Raspberry Pi).





kotlin-native only supports a few architectures. AVR- and Cortex M3-based Arduinos aren't supported, and I don't think ESP8266 will ever be since LLVM doesn't even support it. Even if they were, you'll have a hard time running anything bigger than a Hello World program given Kotlin's runtime, memory management, and the tiny amount of memory in an Arduino or a ESP8266. On the other hand, a Raspberry Pi is the same as any other ARM-based Linux computer so there's no issue running Kotlin and the JVM directly.
– Blender
Aug 10 at 5:16






Assuming your use of the term single-board computers implies something that it can run an operating system for example linux or windows, then you have the resources on board to do such a thing, yes. How much work you have to put in, might exceed the work needed to just learn a more natural language for baremetal work.
– old_timer
Aug 10 at 10:53





This is generally true for a number of non C/ASM languages, even C++ to some extent. The backend required which is generally handled by the system or various sized libraries on top of the system is more work to port than just using a language that is light on the system (ASM, C, Pascal, etc). Now some interpreted languages can be compiled (Pascal, Python, JAVA, kotlin, etc) but those languages may have built in system calls, that would then have to be supported by the baremetal backend and/or not supported and fault if encountered.
– old_timer
Aug 10 at 10:57




1 Answer
1



Yes. Microcontrollers are still computers. if python can be used in Raspberry. then Kotlin can also be used.



First you need compile, JVM(Open source e.g OpenJDK) with that microcontroller toolchain.
Then run the image in the microcontroller.
Now create a kotlin file, compile it and run it with that JVM.
Thats if the microcontroller runs on a kernel e.g linux



Make sure that microcontroller have enough memory.





The problem with microcontrollers is they are very resource limited, being able to squeeze a complete enough JVM is the problem, while you will find some big mcus, a large percentage of them will not work.
– old_timer
Aug 10 at 10:46





Note that while some flavors of Raspberry Pi are in the price range of an MCU eval/breakout board the broadcom chip is in no way a microcontroller. The board has more than enough resources, and you can if you so desire attempt to port a baremetal complete enough JVM, and then run on top of that.
– old_timer
Aug 10 at 10:49





In general it is FAR better to use languages that are more suited for the task C/asm being the most common by a very wide margin.
– old_timer
Aug 10 at 10:50






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

Firebase Auth - with Email and Password - Check user already registered

Dynamically update html content plain JS

How to determine optimal route across keyboard