Closed heidepiek closed 1 month ago
Hey there...
there is an error receiving the data from the moonraker instance.
Please try to open http://<IP to your printer>:7125/printer/objects/query?webhooks&virtual_sdcard&print_stats&heater_bed&extruder
in your browser and send me the output.
Hello rackrick (i think rick😉 ) ,
this is what i get when i put this line in the explorer ( http://192.168.1.221:7125/printer/objects/query?webhooks&virtual_sdcard&print_stats&heater_bed&extruder ) :
{"result": {"eventtime": 115.681244333, "status": {"webhooks": {"state": "ready", "state_message": "Printer is ready"}, "virtual_sdcard": {"file_path": null, "progress": 0.0, "is_active": false, "file_position": 0, "file_size": 0, "first_layer_stop": false, "layer": 0, "layer_count": 0, "run_dis": 0.0}, "print_stats": {"filename": "", "total_duration": 0.0, "print_duration": 0.0, "filament_used": 0.0, "state": "standby", "message": "", "info": {"total_layer": null, "current_layer": null}, "power_loss": 0, "z_pos": 150.0}, "heater_bed": {"temperature": 15.57, "target": 0.0, "power": 0.0}, "extruder": {"temperature": 14.61, "target": 0.0, "power": 0.0, "can_extrude": false, "pressure_advance": 0.04, "smooth_time": 0.04}}}}
I hope you can use this info to help me out.
Harrie
Hey Harrie, correct, its rick =)
ok. the json comming from moonraker looks good.
This line deserializeJson() failed: NoMemory
makes me curious. I can't reproduce it on my end. So I cant really put a finger on it right now.
Hello rick, i have tried multiple d1 mini`s i got at aliexpress. Also tried some nodemcu esp8266. Uploaded it with your flash files. And also tried it with visual studio. I have a k1max that is rooted. Maybe the problem lies there? This is what i get in the serial of visual studio:
���set up filesystem... loading configuration... {"general":{"wifi":"xxxxxxxxx","password":"xxxxxxxxxxxxx","display":0,"utcoffset":2},"printers":[{"name":"k1max","host":"192.168.1.221","led":1}],"led":{"numleds":5,"brightness":10,"statusled":0}} set up leds... set up display... Starting Webserver... set up wifi... .....*.Connected! Monitor initialized! IP: 192.168.1.219HTTP Error: 404 Printer Host: 192.168.1.221 idle screen: k1max Error:404
That is when i use 192.168.1.221 that`s the ip off the printer. But when i change that in 192.168.1.221:4409 (mainsail) than i get this in the serial:
{"general":{"wifi":"xxxxxxxxxx","password":"xxxxxxxxxx","display":0,"utcoffset":2},"printers":[{"name":"k1max","host":"192.168.1.221:4409","led":1}],"led":{"numleds":5,"brightness":10,"statusled":0}} set up leds... set up display... Starting Webserver... set up wifi... .....*.Connected! Monitor initialized! IP: 192.168.1.219deserializeJson() failed: NoMemory idle screen: k1max jsonError ���set up filesystem...
And the board keeps rebooting. Now i am not a programmer, but i asked chatgpt for help. With chat i came up with this in the serial:
���set up filesystem... loading configuration... {"general":{"wifi":"xxxxxxxxx","password":"xxxxxxxxxx","display":0,"utcoffset":2},"printers":[{"name":"k1max","host":"192.168.1.221:4409","led":1}],"led":{"numleds":5,"brightness":10,"statusled":0}} set up leds... set up display... Starting Webserver... set up wifi... .....*.Connected! Monitor initialized! IP: 192.168.1.179Payload size: 730 Payload: {"result": {"eventtime": 16731.7443755, "status": {"webhooks": {"state": "ready", "state_message": "Printer is ready"}, "virtual_sdcard": {"file_path": null, "progress": 0.0, "is_active": false, "file_position": 0, "file_size": 0, "first_layer_stop": false, "layer": 0, "layer_count": 0, "run_dis": 0.0}, "print_stats": {"filename": "", "total_duration": 0.0, "print_duration": 0.0, "filament_used": 0.0, "state": "standby", "message": "", "info": {"total_layer": null, "current_layer": null}, "power_loss": 0, "z_pos": 150.0}, "heater_bed": {"temperature": 17.98, "target": 0.0, "power": 0.0}, "extruder": {"temperature": 18.48, "target": 0.0, "power": 0.0, "can_extrude": false, "pressure_advance": 0.04, "smooth_time": 0.04}}}} ␚3��P9���kz�ӊ��set up filesystem...
Chat and i altered the MoonrakerClient.cpp like this (chat chatted over payload and who nows what?!)
WiFiClient wifiClient;
using namespace RP;
PrinterStatus MoonrakerClient::getData(String host) {
// try get data from moonraker
http.begin(wifiClient, "http://" + host + "/printer/objects/query?webhooks&virtual_sdcard&print_stats&heater_bed&extruder");
int httpCode = http.GET();
// on http OK (200) parse JSON
if (httpCode == 200) {
// Haal de payload op
String payload = http.getString();
// Voeg deze debugregel toe om de grootte van de payload te printen
Serial.println("Payload size: " + String(payload.length()));
Serial.println("Payload: " + payload); // Voeg deze regel toe
// allocate json buffer (verhoog de buffer indien nodig)
DynamicJsonDocument doc(4096); // Verhoog de buffer indien nodig
// Probeer de JSON te deserialiseren
DeserializationError jsonError = deserializeJson(doc, payload);
// Fout bij het deserialiseren van JSON?
if (jsonError) {
// Print fout voor debugging
Serial.print(F("deserializeJson() failed: "));
Serial.println(jsonError.f_str());
// Retourneer printerstatus met foutmelding
PrinterStatus errorResult;
errorResult.connectionState = "jsonError";
return errorResult;
}
// Deserialisatie geslaagd, verwerk JSON naar PrinterStatus struct
PrinterStatus result;
result.connectionState = "success";
result.bedTemp = doc["result"]["status"]["heater_bed"]["temperature"].as<String>().toFloat();
result.bedTarget = doc["result"]["status"]["heater_bed"]["target"].as<String>().toFloat();
result.extruderTemp = doc["result"]["status"]["extruder"]["temperature"].as<String>().toFloat();
result.extruderTarget = doc["result"]["status"]["extruder"]["target"].as<String>().toFloat();
result.isActive = (doc["result"]["status"]["virtual_sdcard"]["is_active"] == true);
result.progress = doc["result"]["status"]["virtual_sdcard"]["progress"].as<String>().toFloat();
result.state = doc["result"]["status"]["print_stats"]["state"].as<String>();
result.filename = doc["result"]["status"]["print_stats"]["filename"].as<String>();
result.printDuration = doc["result"]["status"]["print_stats"]["print_duration"].as<String>().toInt();
return result;
} else {
// Print HTTP-foutmelding voor debugging
Serial.println("HTTP Error: " + String(httpCode) + " Printer Host: " + String(host));
PrinterStatus httpErrorResult;
httpErrorResult.connectionState = "Error:" + String(httpCode);
return httpErrorResult;
}
}
With this i had a little progress, but the board keeps rebooting?!
This is a screenshot of the config in the http :
I hope you can make something of this. Now of to bed! It`s almost 23.00 pm I have to go to work at 6.00 am Thanks for the support👍 First thing when i come home tomorrow is check the mail! (arround 17.00 The netherlands)
regards Harrie
hey Harrie...
i think I know the problem. Try setting your host to 192.168.1.221:7125
To point directly to your moonraker instance. I am bit spoiled from the mainsailOS image. Where nginx is setup to forward traffic to moonraker on the default http port 80. Creality most likely did not do something like this.
The solution of chat gpt tries to adress the NoMemery error and increases the buffer. The issue is simply we did not call the right endpoint to get the correct data.
Have been tinkering for 3 hours now to get this beautiful project going😳 , but the courage is starting to get the better of me now. This is the output of an uploaded firmware with your moonwatch-flash.bat file and the input from host to 192.168.1.221:7125
$�5��S�set up filesystem... loading configuration... {"general":{"wifi":"xxxxxxxxxx","password":"xxxxxxxxx","display":0,"utcoffset":2},"printers":[{"name":"k1max","host":"192.168.1.221:7125","led":1}],"led":{"numleds":5,"brightness":10,"statusled":0}} set up leds... set up display... Starting Webserver... set up wifi... ...........Connected! Monitor initialized! IP: 192.168.1.143deserializeJson() failed: NoMemory idle screen: k1max jsonError deserializeJson() failed: NoMemory idle screen: k1max jsonError Try to switch idle screen: k1max jsonError deserializeJson() failed: NoMemory idle screen: k1max jsonError idle screen: k1max jsonError deserializeJson() failed: NoMemory idle screen: k1max jsonError
This is the output of an uploaded firmware with your moonwatch-flash.bat file and the input from host to 192.168.1.221:4409
{"general":{"wifi":"xxxxxxxxx","password":"xxxxxxxx","display":0,"utcoffset":2},"printers":[{"name":"k1max","host":"192.168.1.221:4409","led":1}],"led":{"numleds":5,"brightness":10,"statusled":0}} set up leds... set up display... Starting Webserver... set up wifi... .........*Connected! Monitor initialized! IP: 192.168.1.143deserializeJson() failed: NoMemory idle screen: k1max jsonError deserializeJson() failed: NoMemory idle screen: k1max jsonError idle screen: k1max jsonError Try to switch deserializeJson() failed: NoMemory idle screen: k1max jsonError idle screen: k1max
This is the output of an uploaded firmware with your moonwatch-flash.bat file and the input from host to 192.168.1.221:4408
loading configuration... {"general":{"wifi":"heidepiek","password":"harkebosgraaf","display":0,"utcoffset":2},"printers":[{"name":"k1max","host":"192.168.1.221:4408","led":1}],"led":{"numleds":5,"brightness":10,"statusled":0}} set up leds... set up display... Starting Webserver... set up wifi... ......Connected! Monitor initialized! IP: 192.168.1.143deserializeJson() failed: NoMemory idle screen: k1max jsonError deserializeJson() failed: NoMemory idle screen: k1max jsonError idle screen: k1max jsonError deserializeJson() failed: NoMemory idle screen: k1max jsonError Try to switch idle screen: k1max jsonError deserializeJson() failed: NoMemory idle screen: k1max jsonError idle screen: k1max jsonError deserializeJson() failed: NoMemory
This is the output from an uploaded firmware with your moonwatch-flash.bat file and the input from host to 192.168.1.221
loading configuration... {"general":{"wifi":"heidepiek","password":"harkebosgraaf","display":0,"utcoffset":2},"printers":[{"name":"k1max","host":"192.168.1.221","led":1}],"led":{"numleds":5,"brightness":10,"statusled":0}} set up leds... set up display... Starting Webserver... set up wifi... ......Connected! Monitor initialized! IP: 192.168.1.143HTTP Error: 404 Printer Host: 192.168.1.221 idle screen: k1max Error:404 HTTP Error: 404 Printer Host: 192.168.1.221 idle screen: k1max Error:404 idle screen: k1max Error:404 HTTP Error: 404 Printer Host: 192.168.1.221 idle screen: k1max Error:404 idle screen: k1max Error:404 Try to switch HTTP Error: 404 Printer Host: 192.168.1.221 idle screen: k1max Error:404 idle screen: k1max Error:404 HTTP Error: 404 Printer Host: 192.168.1.221 idle screen: k1max
Have been digging in the root with help from the https://guilouz.github.io/Creality-Helper-Script-Wiki/helper-script/helper-script-installation/ and chatgpt. Everything you need to get the data off the printer is there. But are in a completely different place than where mainsail or moonraker have it otherwise according to chat. So we did try to make some adjustments, but I'll stop otherwise I'm afraid I'll brick my printer. What I find strange is, if I paste this line into the browser http://192.168.1.221:7125/printer/objects/query?webhooks&virtual_sdcard&print_stats&heater_bed&extruder Then I get an output:
I understand that you can't mimic all this, so it's hard I guess to come up with something for my setup. Very sorry, nice project and a nice enclosure. I still have a few ender 3v2`s that I use qrome's printer monitor for. I wanted that for my k1max too, hope you have some other tips. Otherwise I have to put this project on hold for now unfortunately.
Regards Harrie 👊
Hey Harrie...
thanks for your feedback. The Output from the :7125
is the moonraker instance and thats what we need.
As I said I am a bit spoiled from regular printer os like mainsailOS. Creality did a lot of wild stuff and which causes a lot of issues. Anyways thats not the reason the moonwatch is not working here since we get the correct output from that link I sent you.
Let me do another test tonight...
later rick
Been tinkering again, and learned something. So when I use platformio to upload the sketch, it only loads the sketch and not the littlefs. I didn't know that! I connected a screen tonight and all I got was gibberish! So I did something wrong! Uploaded the code again with platformio with the result that the d1 mini went crazy. But when I used your moonwatch-flash.bat file to upload the d1 mini I had a clock with the right time at once! Then tried again with platformio, everything on the screen inverted and strange colors. Also the d1 mini restarts every time. So now I found out that with platformio you have to first erase the d1 mini with pio run --target erase and then upload the sketch with pio run --target upload and then upload the littlefs with pio run --target uploadfs. Then everything will be uploaded the right way. But I think your source file does not match your bin file. Because when I empty the d1 with platformio and upload as it should, the d1 mini starts up. Logs into the router and then the same message deserializeJson() failed: NoMemory but then the d1 mini restarts every few seconds. And the image is inverted with not the right colors and dimensions. If I use your moonwatch-flash.bat then I have a clock nicely and the d1 stays on too! How nice it would be if the data from the k1 max came on the screen as well. Have great hopes that you figure that out rick.
Harrie
hey @heidepiek, the source code is fine... it's just the libray for the display I am using is a bit odd. Because it keeps the display setup inside the library folder and thats outside my repo. So if you download the dependencies you get a wrong display setup and it looks all messed up.
I can fix this if I add the build flags again. I removed then in a step to make the display more configurable to change hardware and stuff with the same image. Well kinda did the opposite :D
Anyways this has nothing to do with the jsonError
. Today I did a thorough analaysis of your issue and I noticed creality added a few fields to the json output of moonraker. With the additional fields my allocated memory was not big enoug to hold the complete json.
I adjusted that now and build a image for you attached here to test. You just need to replace the firmware.bin
inside the moonwatch-flash bin folder. Then run the moonwatch-flash-update.bat
to write the new firmware to the watch. It should show version 0.1.5 on bootup then.
if this works fine. I update the repo. firmware.zip
edit: please remember to setup the host with the moonraker port :7125
greetings
Thanks rick, tonight after work i wil try the New file and report back. Hopefully with a working watch :)
Harrie
Yesss rick! whoohoe, the screen is running with the info from the printer😁 .
https://github.com/user-attachments/assets/06e372bf-4f82-4c6c-abfd-4cfb3ce6a167
Don't know what you did? But to me you are a magician!💪 It would be nice if you also adapt the source file to this version. Then maybe I can learn something, what I said I am not a programmer. But I am eager to learn, I will never be as good as a real programmer but I find it very interesting how you do it. What strikes me about the ST7735 screens is that they twitch a bit. Do you notice that too? I also have a printer monitor from Nospig https://github.com/nospig/3d-print-monitor which uses an ili9341 screen. That one is a bit more stable I think. It does not twitch. But only for marlin unfortunetly🙈
https://github.com/user-attachments/assets/55785d84-05ff-4a65-9bdb-b1e8924e313e
But now i have the smartwatch monitor, and it works great now! Nice addition to my collection. The k1 is now printing the faceplate of your nice enclosure. Thank you kindly rick for the support,it really is appreciated . Super project!
Regards harrie
Hey harrie, happy its now working for you. Well your chat gpt prompt was right... you had to increase the json buffer. What chat gpt didn't know was the request to the wrong endpoint you did before.
Yeah I know it's twiching. This is not an issue of the ST7735 display, thats software related. I had some trouble with artifacts remaining on value changes. To solve this I recreate the whole screen and that causes the twitching. It's not the best solution but it did work. There are still a few other things I don't like and these need to be addressed but I am a bit short on time for such stuff.
to be honest I am still surprised there are people building the moonwatch.
Rick, I hope that if you have some free hours, you still spend some time on this useful project. At least I find it useful, I can monitor the printers from my workstation in front of my PC. And it looks nice too! I am sure there are more people who feel the same way. It won't be millions, but still. In the first post I sent a link from another person who has modified the qrome printer monitor so that it also gets data from moonraker. So there are people who do care about this after all. I hope that over time there will be some updates, in the meantime this moonwatch stands next to the other monitors!
Greetz Harrie
Sorry rick, hope you don't mind me bothering you again. Why can't I get a working watch myself with platformio? I have text on screen, it says the version and that I need to log in to the app. Logging in also works. But when it connects to wifi and I have the printer off I get black screen with no clock. And a few seconds later the d1 mini reboots and does this over and over. If I use your new bin then after connecting to wifi I get a clock. What am I doing wrong? 😟
Harrie
I have a k1 max, and i would like to use this nice monitor. I installed it and connected it to my wifi. I entered the ip adres of my rooted k1 max and i get this in the serial:
idle screen: k1max jsonError deserializeJson() failed: NoMemory idle screen: k1max jsonError idle screen: k1max jsonError
What am i doing wrong? If i try this printer-monitor https://github.com/truckershitch/printer-monitor Than it works. So i know that the printer is capable of sending files. Please some help?! I really like this monitor with its case
Greetz Harrie