UDP in -> convert values to integer

Hello!

This are my first steps with ESP8266 + UDP + Touchdesigner, I’ve done some tutorial but I don’t know how to do this operation:

  • I have ESP8266 connected to a miniPad (x · y · button)
  • I read through ESP8266 analog pin the y-axis
  • I send via UDP that value (range: 1 to 1023) each 100ms
  • I create a UDP in component in TD
  • I get the value in TD in real time

But I would like to transform this values (I think they come in strings) to integer, to use it as inputs / parameters to other TD components (noise, level, camera, etc).

My main goal is to use y-axis to change in real-time parameters and values from other visual components.

Thank you very much!

Kind regards,
Luis

This can be done simply with Python’s build in int() method. It will convert any string or float input into an integer.

Thanks, Corbin. I got it!

def onReceive(dat, rowIndex, message, bytes, peer):
    op('table1').clear()

# Convert the received message to a number
    try:
        number = int(message)
    except ValueError:
        return

# Add the number to a Table DAT
    table = op('table1')
    table.appendRow([number])```