Write string to serial and read data back

Hi Guys,

I’m currently writing a sketch to control KH 810 Studio Subwoofer as I described here in another post:

A MAX232 is connected to pin 2 and 3 and I’m able to send commands to the subwoofer.
I succeeded to control the volume using a rotary encoder that sends a “setvol” command to the subwoofer. For that I created a function setvol().

I’m now trying to get a value from the subwoofer, in this example “getvol”. The idea would be to show this value on a LCD screen, but first I just want to print it on the serial monitor.

The value is in the same format than setvol and is contained between -95.00 and 20.00. I created a function getvol() that is sending the command getvol, but the returned value is always “-1.00” !

I tested that even if I do not send the getvol command, the value is stil the same, it looks like I cannot read the value at all.

I tested this using a simple USB to RS232 directly to the subwoofer and connected via PuTTY terminal.
When I type “getvol” carriage return the value is directly printed to a new line.


Any idea where I’m wrong here?


rotary.ino (1.31 KB)

int oldPosition  = -95.00;

You don't understand what an int is, do you?

if (currentMillis - previousGetVolMillis >= GetVolInterval); {

Can you find a single example of an if statement that ends in a ; that actually works?


Does the device actually understand this command? What does it actually reply with?

     currentvol = NeumannSerial.read();

How long did you wait for the device to receive the command, process it, and return a response? Do you think that was a reasonable amount of time?

The read() method returns an int. Why are you storing that int in a float?

If there is no data to read, the value of that int is -1.

but the returned value is always "-1.00" !

And now you know why!