Serial Port programming Tutorial using Java SE for Embedded Developers
A short tutorial on how to communicate with an Arduino or ATmega328P microcontroller from your Windows or Linux PC using JavaSE.
Here we will learn about programming the serial port using a commonly used cross platform library called jSerialComm.
If you are tring to communicate with other microcontrollers like MSP430 ,Please use a USB to Serial Converter like the one shown below.
Please note that MSP430 is 3.3v volt tolerant.
You can find the link to the library and source codes below.
The Tutorial teaches you to
- How to use jSerialComm JAR to build your own java serial port program
- How to Check for available serial ports on a Windows using Java
- How to Open a Serial Port connection to an Arduino using Java
- How to receive data from Arduino using a Java Serial Port program
Once you have downloaded the jSerialComm JAR file in a directory of choosing, you can compile the source code as shown below.
javac -cp .;jSerialComm-2.9.0.jar YourSerialSourceCode.java
resulting class file can be run as
java -cp .;jSerialComm-2.9.0.jar YourSerialSourceCode
Here are a couple of images of java serial port in action on a Windows10