Access Temperature sensor data of 3D printer via Serial connection I want to access the bed and nozzle temperature sensor data of a 3D printer via serial connection. Could someone please guide me in the right direction?

Thanks!

Edit: Response from printer:

Connecting to printer...
Connection response from printer:
6R7�P)��h&gt;L�JO� � ��V�\��`�r��T �� SK�&lt;ʪ� �&gt;�Vw^$���|���R n�I, o�!����H&gt;�
                                                                          mx�}M#
                                                                                 �LYԣPh���^@ ��rp � TP�j�~1�� V6     6 � f� 6�k#���&amp;�H".��k K2���ek�(��&amp;��^K�k2����Ul�(� ���~N�ʈ*.�&gt;Z��k#d$�����(� ��
��(� ��� v��
���
Asking for temperatures (M105)...
Temperature response from printer:
^CTraceback (most recent call last):
  File "printer_files/serialaccess.py", line 15, in &lt;module&gt;
    response = ser_printer.readline()
  File "/usr/lib/python2.7/dist-packages/serial/serialposix.py", line 446, in read
    ready,_,_ = select.select([self.fd],[],[], self._timeout)
KeyboardInterrupt


After the code asks the printer for temperature values, there is no output on the terminal anymore. I waited for a while and then killed it using control+c. It is clear that the printer is responding to the connection response but I am not sure why it is not returning the temperature values. Again, thanks a lot for your help, Demetris!
Assuming your printer accepts conventional G-code flavor, extruder and bed temperature can be retrieved by sending M105 through the serial port. The printer will respond with ok T:XXX.X B:XXX.X where T is the nozzle temperature and B is the bed temperature.

You can read more about the specific G-code in the RepRap wiki.

EDIT:
I am editing the answer to include information for connecting to the printer using a simple python script.

The following script, first opens a serial connection to the printer. For Marlin firmware, when you first connect to the printer, it needs some time to initialize and respond back. That is why some delay is needed before reading the response. After printing the response, the script sends the M105 command, waits for 100ms, then reads the response of the serial buffer and prints it on the screen. 

Note /dev/ttyUSB0 is the serial port name and in your case it may be different. Also 250000 is the baud rate of the connection; 250000 is the default value of my printer so you need to replace this with the baud rate that your printer uses.

import serial
import time

ser_printer = serial.Serial('/dev/ttyUSB0', 250000)
print "Connecting to printer..."
time.sleep(30)  # Allow time for response
buffer_bytes = ser_printer.inWaiting()
response = ser_printer.read(buffer_bytes)  # Read data in the buffer
print "Connection response from printer:"
print response
print "Asking for temperatures (M105)..."
ser_printer.write('M105\n')
time.sleep(0.1)  # Allow time for response
print "Temperature response from printer:"
response = ser_printer.readline()
print response