Access Temperature sensor data of 3D printer via Serial connection

  • Access Temperature sensor data of 3D printer via Serial connection KDK

    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?


    Edit: Response from printer:

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

    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 =  # Read data in the buffer
    print "Connection response from printer:"
    print response
    print "Asking for temperatures (M105)..."
    time.sleep(0.1)  # Allow time for response
    print "Temperature response from printer:"
    response = ser_printer.readline()
    print response

extruder heated-bed nozzle
Related questions and answers
  • I want to access the bed temperature of the 3D printer. I am able to get the temperatures using serial connection (Thanks to Demetris's help (Access Temperature sensor data of 3D printer via Serial connection)). The problem that I am facing now is that as soon as I give the command, I get the temperature values, however the print job stops. Is there a way around it? I want to get the temperature values as the print job goes on. TIA!

  • I have been using a software called OctoPrint that allows you to control your printer in your Browser. For sake of simplicity I have used Octopi, a preinstalled image with OctoPrint, but now I would... - octoprint.plugin.core - INFO - Found 6 plugin(s) providing 6 mixin implementations, 3 hook handlers 2016-07-11 03:09:20,533 - - INFO - Initializing the file metadata for /home/pi...) = /home/pi/OctoPrint/venv/lib/python2.7/site-packages/OctoPrint-1.2.13-py2.7.egg/octoprint/plugins/virtual_printer 2016-07-11 03:09:23,628 - octoprint.filemanager - INFO - Adding backlog items from

  • I'm a newb and don't know much about 3D printers. In visual basic I can create vector data of 3d objects,that can be loaded into a binary or text file. Can files like this be used with a 3d printer? Example: This is a very simplified example of how the code generates 3d vector data. ju jv jw determine the size and dimensions of the object ru, rv, rw are the vector lenghts The incrementors... = (rv * Cos(angle v)) For k3 = 0 To Jw rw=rw+1 xw = (rw * Sin(angle w)) yw = (rw * Cos(angle w)) Output xu, yu, xv, yv, xw, yw file in the order produced on this line Next k3

  • Before the question, here is my setup; Prusa i3 (with mainboard Mks Gen v1.2) Repetier as slicer Marlin source code My main task is to convert my 3D printer into a chocolate printer. I have..._HOME_POS 0 #define MANUAL_Y_HOME_POS 10 &lt;&lt;&lt; (tested with 10 or -10) #define MANUAL_Z_HOME_POS 0 I have also played with the slicer tool (Repetier) settings where homing related values... 20x20 cm bed. The other X and Z axes are OK. So, I have played with the #defines explained below, but I couldn't even make any single mm difference by homing. They are all ignored when the printer

  • F7800.000 G1 X128.476 Y125.548 E7.92045 F1800.000 Does the absence of an E command in the second line mean that no material is to be extruded from line 1 to line 2? As I understand it, the E parameter controls how much material has been extruded up to that line. The reason why I am asking is because I'm trying to understand on the code level how to identify when a printer will travel without... to believe that the absence of an E command means that when moving to the given position from the previous line, no material will be extruded. I've tried quite a few different queries online to try

  • I started to write an application that calculates the estimated total print time from the G-code file for an already sliced model. The program works and it's pretty accurate. It works as follows: It scans the entire G-code file to identify all of the movements It calculates the time for each move by dividing segment distance by the speed in mm/s. Let's assume this is the G-code: G28... Acceleration X, Acceleration Y, Acceleration Z, Jerk, and Z-Jerk. I'd like to make it possible to use those values to more accurately calculate print time; however, I don't understand how those

  • I'm currently using Marlin firmware (1.1.0-RC7 - 31 July 2016) and would like to experiment with print speed. In the file Marlin_main.cpp I see in the process_next_command() function, there is a variable called current_command which (supposedly) holds the G-Code values for travel distance and feedrate(speed). I'm expecting the actual command for travelling to look something like this: G1 X50 Y25.3 E22.4 F1500 but I'm getting tied up figuring out exactly where it is. I'm assuming if I can change F1500 to F200, I can effectively slow down the print speed. I'm aware of line 753

  • -menu. I couldn't find any description of what the "printer head" X and Y offset values mean there, nor what the "Z-gantry" value does either. I'm running from the SD card; no USB connection. ...I seem to be observing a couple problems w/ Cura2.3 OSX . It seems to be placing the sliced data (gcode) over to negative X by a cm or so. Further, the X- and Y-axes displayed in Cura definitely map to Y and X when the printer starts up. I've verified that I have the printer's X and Y end stops and motors connected to the correct outputs. Now, I can just rotate my parts before slicing, but I'd

  • using an MK8 extruder and do not receive temperature readings from the thermo-sensor - no matter how I connect it. However, on APrinter firmware it works flawlessly. In configuration.h, I have tried most of the options, but found "1" is the best one for me. Executing m105 on Marlin, I get following result: ok T:0.0 /0.0 B:0.0 /0.0 T0:0.0 /0.0 @:0 [email protected]:0 On APrinter, the result is different: ok B... T3000.00 echo:Advanced variables: S=Min feedrate (mm/s), T=Min travel feedrate (mm/s), B=minimum segment time (ms), X=maximum XY jerk (mm/s), Z=maximum Z jerk (mm/s), E=maximum E jerk (mm/s) echo: M205

Data information