title: GNU/Linux - Python3 - PySerial: How to send data over USB connection?
body: <p>I have 2 questions about Python3 and PySerial (serial module).</p>
  
  <p>I must send data over USB port to my IC's stand-alone ATMega32. A possible snippet code:</p>
  
  <pre><code>import serial
  data=serial.Serial(port, speed)
  
  first_data=99.7 # Float point data.
  second_data=100 # Only int data like 10, 345, 2341 and so on.
  third_data=56.7 # Float data
  
  ValueToWrite=????? # How to convert it?
  
  send=data.write(ValueToWrite)
  </code></pre>
  
  <p>Now if I try to send "first_data" with "ValueToWrite=firts_data" I have this error:</p>
  
  <pre><code>TypeError: 'float' object is not iterable
  </code></pre>
  
  <p>Well. Reading documentation about method <strong>write</strong> (class <strong>serial.Serial</strong> - <a href="http://pyserial.readthedocs.io/en/latest/pyserial_api.html" rel="nofollow">http://pyserial.readthedocs.io/en/latest/pyserial_api.html</a>) I see:</p>
  
  <blockquote>
    <p>Write the bytes data to the port. This should be of type bytes (or compatible such as bytearray or memoryview). Unicode strings must be encoded (e.g. 'hello'.encode('utf-8').</p>
  </blockquote>
  
  <ol>
  <li>My first question: I don't understand how to send my float and int data. How to convert them into string?</li>
  <li><p>My second question: I'd like to send data all together, a unique value like this:</p>
  
  <p>99.7F100S56.7T</p></li>
  </ol>
  
  <p>In this case, using ATMega's Firmware, I can split and update data in the corresponding variables, when encountered "F" character for the first data, "S" character for the second data and so on.</p>
  
  <p>How to do this in Python3 using pyserial?</p>