Java program on pc to esp

Hello, i want to send data from a java program/console trough serial to and esp conected via cable to the pc. i couldn't find any library that would work. i tried jSerialComm but i keep geting errors when i try to run

Could not locate or access the native jSerialComm shared library.
If you are using multiple projects with interdependencies, you may need to fix your build settings to ensure that library resources are copied properly.
Could not locate or access the native jSerialComm shared library.
If you are using multiple projects with interdependencies, you may need to fix your build settings to ensure that library resources are copied properly.

Using Library Version v2.9.1
Exception in thread "main" java.lang.UnsatisfiedLinkError: 'com.fazecast.jSerialComm.SerialPort[] com.fazecast.jSerialComm.SerialPort.getCommPorts()'
	at com.fazecast.jSerialComm.SerialPort.getCommPorts(Native Method)
	at com.fazecast.jSerialComm.SerialPortTest.main(SerialPortTest.java:87)
Exception in thread "Thread-0" java.lang.UnsatisfiedLinkError: 'void com.fazecast.jSerialComm.SerialPort.uninitializeLibrary()'
	at com.fazecast.jSerialComm.SerialPort.uninitializeLibrary(Native Method)
	at com.fazecast.jSerialComm.SerialPort$1.run(SerialPort.java:408)

Hi Alex,

how many times do you want to repeat to post a short question waiting a lot of hours for an answer?

This is a pure java problem. In no way related to arduino. So if you want to use java for the receiving you should ask in a java-user-forum.

You haven't told anything about your setup. How should anybody make any suggestion if you haven't even posted what computer Windows, Linux, MAC you are using and which java-version you are using? Do you expect that somebody will write a cover it all Windows, Linux, MAC Tutorial?

You haven't told anything about the final purpose of sending the data.
receiving the data is only the first step. What is your computer doing with the data?

me personally I prefer python over java because I find it easier to use.
So I did a quick googling for a demo-script and found this one
for python3 (don't try python 2.x python 2.x is incomaptible with python3

# python3-code
import serial
import time

ser = serial.Serial('/dev/ttyUSB0', 115200, timeout = 1) # ttyACM1 for Arduino board

readOut = 0   #chars waiting from laser range finder

print ("Starting up")
connected = False
commandToSend = 1 # get the distance in mm

while True:
    print ("Writing: ",  commandToSend)
    ser.write(str(commandToSend).encode())
    time.sleep(1)
    while True:
        try:
            print ("Attempt to Read")
            readOut = ser.readline().decode('ascii')
            time.sleep(1)
            print ("Reading: ", readOut) 
            break
        except:
            pass
    print ("Restart")
    ser.flush() #flush the buffer

As soon as you described this a lot of suggestions can be made.
You are using an ESP which offers much more and easy to use ways to communicate with a Computer

with an ESP (which one ESP8266? or ESP32?)
you could use UDP, or TCP with a wireless connection.
Though you haven't told anything about your project I don't know if this would be an option

best regards Stefan

is this a question about how to use java to send serial data or how to used an esp to do so?

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.