"Pause and Resume" Printer with Light Sensor Data
Hello!
I am pretty new to messing around with 3d printers, but that's what I need to do... So please help me out here!
I am working on a project where I control a 3d printer with Repetier connected through a USB and what I need to do is sending commands to pause and resume a printer based on sensor data I get real-time from a light-meter.
For example, I use a light sensor that reads Lux value real-time and if the number goes below 10,000, pause the printer and resume the printer when it goes back up 10,000.
I currently read the sensor from the light-meter and pause/resume the printer manually through Repetier.
I would like to automate this part by calling a command based on input data from the light-meter.
I am logging/reading Lux on my computer and the printer is connected to the same computer through Repetier.
Please let me know if you have any suggestions to implement the system through Repetier (Or any other methods).
Any advice would be appreciated.
Thanks!
I am pretty new to messing around with 3d printers, but that's what I need to do... So please help me out here!
I am working on a project where I control a 3d printer with Repetier connected through a USB and what I need to do is sending commands to pause and resume a printer based on sensor data I get real-time from a light-meter.
For example, I use a light sensor that reads Lux value real-time and if the number goes below 10,000, pause the printer and resume the printer when it goes back up 10,000.
I currently read the sensor from the light-meter and pause/resume the printer manually through Repetier.
I would like to automate this part by calling a command based on input data from the light-meter.
I am logging/reading Lux on my computer and the printer is connected to the same computer through Repetier.
Please let me know if you have any suggestions to implement the system through Repetier (Or any other methods).
Any advice would be appreciated.
Thanks!
Comments
https://www.repetier-server.com/manuals/programming/API/index.html
To make a pause use the send command with "@pause some message" as gcode. To continue use the "continueJob" command.
I have been using Host and now switching to Server to use the web API.
So when I use the serial connection, I had no problem.
But I am having an unstable connection with TCP/IP connection. Constantly connected and disconnected.
Getting this in the console. Mesg:17:30:17.692: Connection started (29)
Even when it's connected just for a few seconds, I cannot send a command and operate my printer.
I tried different internet connections for different IP addresses. The connection issue was the same.
Do you have any thoughts on why I am getting this connection problem?
Thanks.
With usb it means it did not get a communicating connection. Maybe wrong firmware selected. Also right choice of DTR/RTS seems to be important here.
I might completely misunderstand the concept of using my laptop as a server.
Please see the video here and let me know if I am doing something wrong.
https://youtu.be/qQNx0lLD2Ck
(I used the Api key for the Host.)
As you can see, when I connected my computer through the Serial Port, it's working just fine.
But when I switched it to the TCP/IP connection, it's unstable.
Basically, the reason why I am trying to use the TCP/IP connection is to use the Repetier web API you suggested for my problem in this thread. If it's possible to use the web API through just the serial connection with Repetier-server. Please let me know.
If I should have the IP connection to use the web API, I need to resolve this connection problem.
I am repurposing HE3D K200 Delta printer and using Repetier as a firmware.
Thanks again!
http://localhost:3344/printer/api/deltaHyperreal?apikey=blahblahblah&a=send&data={"cmd":"G1 X10 Y10 Z10"}
This is done through the serial connection which means I don't need to try to solve the TCP/IP connection issue for my purpose. (Although I still want to know what causes the problem)
Now I am playing with the API demo.
I filled the ACTION with send and JSON Payload with {"cmd":"G1 X10 Y10 Z10"}
But this didn't work. I assume that's because I didn't put API-key somewhere?
I was able to retrieve some information with listFirmwareNames, testPushMessage
So I know it's communicating where it doesn't require API-key.
But most of the functions either do not work at all or give me empty responses.
How can I solve this problem? Am I using the demo in the correct way??
Thanks!
The link it self is not correct - you need to urlencode the json string or parts get interpreted wrong.
For tthe payload you can use https://jsonlint.com/ to verify the json syntax is correct. For me it looks correct so demo should work if you are authenticated or do not need authentication.
I am still having hard time to make it work. I think I am authenticated. When I call userlist, I am getting this response. { "loginRequired": true, "users": [ { "apikey": "blahblah-9ae7-4860-8748-a79edb5a6064", "id": 1, "login": "ss2432", "permissions": 1023, "uuid": "" } ] }
The strange thing is when I tried Action with a command login and the right JSON payload to double-check if I am authenticated. I am getting this. { "error": "Login or password invalid!"}
It's weird because I can retrieve the information with the userlist?
But when I tried to operate the printer with babystep, the response I am getting is {"ok":false}
I am expecting true but the reason I am getting false is I assume I still have an authentication problem?
Probably stupid question... the username and password are the credential for the Repetier-server account?
Update event list continues to print this line which I assume normal. { "data": { "O": 0, "S": 0, "T": -20, "id": 0, "t": 1598550770860 }, "event": "temp", "printer": "deltaHyperreal" } }
Do you have any idea why it's not working? loginRequired should be false in case I am already logged in?
I am confused...
Thanks for your prompt reply! Please let me know!
The vent list what you see are the temperature updates.
When I connected, I am receiving this message
Although I put the API key, I was unsure if I am authenticated. So I send login with my repetier server username and password that I use for the server frontend. But I am getting this error message.
Why is this saying it's invalid? Is that the reason why some of the important requests such as send, move, stopJob, and continueJob do not work?
In most cases I am getting something like this. "permissionDenied":true
That should work. When you late ruse login/passwort remember that we never send passwords in plain text. You need to create a hash as described in api:
Authenticates a user. Password is MD5(sessionId + MD5(login + password)) so it never goes in clear text over the line. If authentication is required, you get a loginRequired event directly after connecting to the socket.
I guess it has to be updated.
For the authentication, PW is pretty much MD5 of MD5? Please let me know.
Anyways, I got what I need for this post! I have another question regarding the printing speed. I will make a new post for that. Thanks again for the prompt support!