Automatic cat litter box.

Posted on
Page
of 2
Prev
/ 2
  • What happens if you set Puck.increaseMTU = false before connection? It's possible that earlier Espruino builds had issues with the increased MTU?

    The Puck.js lib will try and increase the MTU if it sees that it receives data in chunks of more than 20 bytes (because it assumes that for that to happen the MTU must have increased) and it's possible that it causes problems?

    It'd be well worth trying with a newer firmware though, as I know there were some instability issues that have been fixed - 2.14 is quite old now

  • just have a led blink on every loop on the device, and force a bad signal on the phone running the web page.

    which loop do you mean is there some specific looping code you can link (your code or that puck.js)? One idea is watchdog - if you have watchdog kicking in setInterval then any busy loop or delay in native code preventing intervals from running could trigger such reboot. Another issue causing this may be be overflowing the stack or memory - generating data faster than it could be sent filling memory or call stack (by somehow nesting calls when error happens?)

  • I will try if you cannot replicate it there, the version on dsd6 indeed only has standard BT packet length, but if the signal is good, it works fine for days connected. I only realized because I was getting random reboots, and could not figure out why. It turns out, I was not closing the connection from the phone, and when I was moving a floor down the toiler that was upstairs was rebooting :)

    I can demonstrate it for you if you like, I was able to make the empty cycle run slower just by placing the phone between my legs so that the signal got worse.

    I swiched to using characteristics and standard web bluetooth connection, and the problem is gone now for me, but I will make a small video if you believe it is usefull. If you are sure it does not affect newer vesions, then it is not problem.

  • I used the code Gordon has here(*), the write command I was sending to espruino for the loop was this one insted of the one on the example, so it was quite big, not as big as it looks ofcource, I was just returning the id and numbers,a json, but is was not a problem at all if the signal was ok, the script (http://www.puck-js.com/puck.js) was handling it nicely, only when signal was near lost the dsd6 was rebooting. 150 ms interval.

    if you use this github example on a phone with an espruino device, and add some code so that you can see a led go on and off at every interval run on the device, you will see it blinking slower as you make the make the signal worse. If not, then it is strange, maybe it is an older problem, but it sounds strange that it not known, even if solved.

    connection.write(
            "lal=setInterval(function(){Bluetooth.println(JSON.stringify({dt:Date().toString().split(' ')[4],uv:scata.state.def.auto.uvc,ps:scata.state.is.sys.pause,bs:scata.state.is.sys.busy,db:scata.state.def.is.dbg,ac:scata.state.def.auto.clean,ad:scata.state.def.auto.delay,rtod:scata.state.is.sys.run,pos:scata.state.is.pos.ball,pwr:scata.state.is.sys.pwr,lit:scata.state.is.volt.litres,pbv:ew.is.ondcVoltage(),ss:scata.state.def.sandType[scata.state.def.is.sand].speed,sp:scata.state.def.is.sand,cb:ew.is.batt(),pb:ew.is.ondcVoltage(1)}));},150);NRF.on('disconnect', function() {clearInterval(lal)});\n",
    

    (*)https://github.com/espruino/EspruinoDocs/blob/master/tutorials/Web%20Bluetooth%20Dashboard.md#realtime-dashboard

  • I will make an example and will upload a link so that you can both test if you like, it is easier, sory for the long posts.

  • you will see it blinking slower if you make the signal worse.

    Oh, ok - well that's expected I think. It's not really a crash.

    What's happening is you're writing a bunch of data, but because the signal strength is bad it's not able to send all of that data quickly, so at some point you call Bluetooth.println and rather than lose data it waits patiently until enough other data has been sent that it can fit the text in the buffer.

    Put another way, if you did Bluetooth.println with 10,000 characters of data, you'd hope that you would receive all that data - even though it wouldn't fit in the output buffer and the Bluetooth.println function might take a while to complete. It's the same sort of thing.

    Probably using raw characteristics fixes it for you because if you try and write when too much data is backed up, it just throws an exception and carries on (rather than waiting)

  • I'd replace setInterval by scheduled setTimeout, it is fixed to 100ms here
    https://github.com/espruino/EspruinoDocs/blob/master/tutorials/Web%20Bluetooth%20Dashboard.md?plain=1#L214
    so if sending (the Bluetooth.println(..)) takes longer than 100ms it may overflow and reboot(?). it is safer to schedule it again via setTimeout after println returns.

  • Oh, ok - well that's expected I think. It's not really a crash.

    nice, yes that is was I understood was happening, I was overdoing it, was gettting greedy because I was playing with your tiny dash and it was fun :)

    thanks, sory for not making my self clear, it is not a problem for me, I actually swiched to running NRF.updateServices 16 times per 1 sec, one variable after the other, and only send the ones I want to be instant every 100ms, while running all the rest of the code for the toilet empty cycle, and your amazing software is not breaking a sweat on the dsd6 :)

    https://github.com/enaon/sCat-a/blob/9109221dd977e7d7467cf9cbc1442445a11c7e53/app/main.js#L16

  • it is safer to schedule it again via setTimeout after println returns.

    actually I did not check how setInterval is done, but I always had issues when code in setInterval run longer than the interval. Since the interpreter is single threaded it won't run the code again if it did not finish but maybe it runs again right after previous one ends not giving chance to any other code or idle loop to run? So maybe GC is not done or other intervals may not run (pinging watchdog in this case) etc?

  • this is a run cycle I just recorded, I like your tiny dash :)

    when it starts the empty cycle, the main gauge goes from powerbank battery reporting to ball placement reporting, you can see the empty cycle movement. Thanks again

    https://www.youtube.com/watch?v=mo4dGIFlVFU

  • When the bt signal goes low or near lost, the espruino device reboots

    So is it that problem? That sounds a lot more serious than just a delay to me...

    I always had issues when code in setInterval run longer than the interval. Since the interpreter is single threaded it won't run the code again if it did not finish but maybe it runs again right after previous one ends not giving chance to any other code or idle loop to run?

    It should work ok - it tries to rechedule as soon as possible, but only after processing inputs and running through other intervals I believe. I guess it's possible if the first interval adds a timeout/interval itself it might trigger a re-run which might cause the behaviour you're having?

  • So is it that problem? That sounds a lot more serious than just a delay to me...

    I believe so, I was able to make the dsd6 run slower just by making the signal worse, and eventually it was rebooting when using puck.js.com script. But I did not want the cli to be exposed anyway, so the NRF.updateServices solution is better in any case for real use, I did not investigate further. I can try something if you like though, I have a nice visual feedback of the delays to reboot sequence, the ball moves slower and then stops :)

    but I do not have the probem anymore, the NRF.updateServices way solved it for me.

  • I can try something if you like though

    Thanks, but I wouldn't worry - it's older firmware so it'd be hard for me to track down here (it could already be fixed if it is an issue). Glad you found a way around it though!

    In a way it'd be nice to have a way to easily check how full the output buffer was, but doing setTimeout after as @fanoush suggested is nice and easy :)

  • Thanks, but I wouldn't worry - it's older firmware so it'd be hard for me to track down here (it could already be fixed if it is an issue). Glad you found a way around it though!

    nice, yes fanoush's solution sound fine, I will try it next time I want to use the puck.js script. I had one more problem with it though, in your git example there was not a disconnect on lost signal event, it was not disconnecting when signal was lost, so I used the google way to be sure, disconnect due to low signal works fine with the google example. Next time I will ask for info :)

    this is what I am using now
    https://github.com/enaon/sCat-a/blob/9109221dd977e7d7467cf9cbc1442445a11c7e53/index.html

    it is served from github from this page.
    https://enaon.github.io/sCat-a/

    sCat-a in greek sounds like shit, poop etc, in case someone wonders about the name :)

  • So maybe GC is not done or other intervals may not run (pinging watchdog in this case) etc?

    nice, most probaby this was the case, I do have a watchdog that only needs 5 secs to fire, because the button on the dsd6 resets every 6 seconds or so, and I want to trigger it manually if needed.

  • I found 3 pads on the back that were not listed on @fanoush's Magic3 pin table: D13 (unmarked, grouped with SXD,TXD,D+,D-), D28 (unmarked, to the far right of that cluster), and D27 (unmarked, to the near right, below and to the left of D28).

    thank you for this post, I had a look and I did found the pins you mentioned. D13 is the RxD I think, it is unmarked as you said but it is next to the TxD, so I guess it is the RxD.

    The TxD is pin D38, and pin D46 is active on the magic too, the one in the middle on the key connector, so 5 easy solder pins in total. Thanks.

  • pin D46 is active on the magic too
    Yes! It's the same board as the 2-button C16 (Kospet Rock), they just didn't bother giving a second button on the Magic3. Now you can ;-)

  • The toilets did fine during testing, so I've made some more, version 2 :)

    I have added:

    1. a magic3 for the controller, so there is now a touchscreen, settings etc,
    2. load cells and a hx711 for triggering and for sand level monitoring,
    3. an VL53L0X for waste drawer level monitoring
    4. and vibration.

    This last one is very important:

    The toilet can now handle pellets, a world's first I believe, it can scoop the solid waste and sift the sawdust at the same time.

    This is a game changer, it leads to less waste volume and sand loss, for a fixed available volume it almost doubles the time needed between refiling the ball with sand/emptying the waste drawer.

    It also makes the silicone lining most commercial solutions use not needed, when using a clumping sand type like betonite, 5 seconds of vibration is enough for everything to get unstuck.

    I will upload a demo during the weekend, but until then if one can guess where the vibration is applied, and how the sawdust exits the ball, I will be happy to read.

    ps.
    if one cares to think about it mechanically but has no cats and no idea about the pellets+automatic toilets problem, it goes like this:

    automatic toilets need a clumping type of sand, so that waste, solid or liquid, can form an object larger than the hole openings. The sand will trap it self and the waste will roll out.

    Pellets do not clump when liquid is present, they dissolve to sawdust. This means that the dust will get trapped along with the rest of the sand, it cannot exit the ball, till now :)

  • I had a problem with the Neakasa m1, the lid mechanism is a weak point, it got stuck, I had to disassemble the toilet and found a lot of sand inside, so I decided to make a lid that is cleaning friendly, as an extra.

    Big mistake, curves with precision are not easy to make, but I think I got it.

    https://www.youtube.com/watch?v=Yn0dCzyuroE

  • a small demo of the scale accuracy.

    It used a hx711 and 4 x 10kgr load sensors off aliexpress, the hx711 runs from battery voltage. I used the nordic PPK2 to test the hx711 at voltages from 3 volts to 4.2, readings were not affected by voltage, I read online that the hx711 modules are 5v only, but testing says they work fine from 3v upwards.

    there are tree BIC lighters in the video, blue=empty, green =almost empty, yellow=brand new.

    The scale is stable and can accurately tell which lighter is the full one, amazing espruino, I thought it would half work, instead it is the best scale I have in the house.

    https://www.youtube.com/watch?v=AOwwdRC4nEw

  • Hi @enaon, congratulations on this amazing project!

    I’ve been following this project both on the Greek forum and here in this thread. I’m the proud owner of two young cats, and I’ve noticed that the products available on the market don’t fully meet their needs (or mine). This has inspired me to consider building my own solution or even replicating your design.

    Would you mind sharing more details about your second version?
    I’m asking here because I believe it could help others trying to tackle similar challenges. It would be fantastic if you could share your code and a wiring diagram, as I know electronics can be tricky for some people.
    I'm a web dev but this is my first experience with Espruino (and thank you @Gordon @fanoush @yngv126399 and @atc1441 for what you brought to the community).

    In the meantime, do you have a link or recommendations for sourcing the electronic components, especially the servo motor and sensors? Aliexpress can be overwhelming, and I’ve had bad experiences with fake or even unsafe components in the past (be cautious with relays, even when buying from Amazon).

    I also tried finding the Bama flower pot at the price you mentioned (around €14), but the only ones I’ve come across are significantly more expensive. I’m based in France—did you purchase it directly from the manufacturer?

    Lastly, the resin-filled cardboard technique is truly ingenious. Would you consider documenting the process in a video if you create another piece in the future? It could be an excellent way to inspire and empower people to move away from 100% reliance on consumer products.

    Thank you again for this incredible project and for sharing your knowledge!

  • Hi @SamSam,

    thank you for the kind words, I will upload a per item photo-story on the greek forum for v2, I am waiting for some parts from alliexpres, the vibration requires a better way to secure the scooping part, it moves out of place. :)

    I will also upload all the code for the magic3 on github. This a list of the parts I used(some you can find cheaper on other stores, those link are from my past orders page, so I have used them without problems, but I can see some prices went a bit up):
    controler(magic3):
    https://www.aliexpress.com/item/1005005373233740.html
    servo for the ball( the 12V 270 version, it works very smooth at 5volts, and is way stronger at 5v than any other servo I have tried, and way more efficient, 6W max for the 12V model at 5volts to move 4Kg of sand, 14W for the 9V model at 5Volts):
    https://www.aliexpress.com/item/1005004934282252.html
    servo for the lock:
    https://www.aliexpress.com/item/1005005180487492.html
    main power module:
    https://www.aliexpress.com/item/1005006361300312.html
    controller/scale supply protection board
    https://www.aliexpress.com/item/1005006191578119.html
    load sensors( 10kg)
    https://www.aliexpress.com/item/32763839569.html
    rods for the scooping part (ABS 3x250mm 25pc)
    https://www.aliexpress.com/item/1005002115579949.html
    latch for ball lock/scooping part
    https://www.aliexpress.com/item/1005002679373408.html
    ToF sensor(VL53L0X)
    https://www.aliexpress.com/item/1005006160743016.html

    for the Bama flower pot, ~18 euros is the standard price here in Greece, I can see that on amazon.fr it costs 26 and not available. I am not sure if any of the Greek shops ships to France.

    on the resin-cardboard I agree that it is useful for diy, it was an experiment so this time I got better and can do things like curves with no special tools or mold/template, paper is very nice to work with :)

    I will make some comments on the procedure, unfortunately all 5 new ones are past the resin stage now, but I do have some photos. But over all it is super simple, the cardboard it self is important on how well it "drinks" the resin, I found out that cardboards that are somewhat soft, are not very resin friendly*. The cardboard on the bama pot is excellent, if you peel out the printed layer, it will "drink" all the resin you place on it, perfect to get a good idea on how strong resing/cardboard can be. Very strong. I am actually a bit lucky, as the first cardboard I used was the one from the bama pot, so I got very good results, had I first used some others I later tried, I maybe would have dismissed the idea as not useful.

    *For example, I made two toilets using the cardboard from the neakasa m1, same thickness as the cardoard I used from some solar panels I got, but the neakasa m1 was not "drinking " the resin as well, I think some cardboards may have some anti moisture treatment on the paper, I think you can figure them out by how soft they are.

    The resin I am using is this one, it is used in construction applications, but I think any low viscosity/high penetration epoxy resin will do. For reference, 1Lt costs 22 euros, and each toilet(base/scooping part/drawer) needs up to 1.5 lt to be very strong, or as low as 0.5lt to be good enough.

    On how to apply the resin on the cardboard, I do it in two stages, first I use a painting brush to paint the resin on both surfaces of the cardboard, wait for 6-7 hours, and then depending on how well the cardboard drank the resin ( the second part is not needed for some thin cardboards like the one on the bama pot), I use the brush doing what one should never do when painting something, I repeatedly run it on the top edge, so that the resin falls though the holes. You can do it the other way around the first time, to get an idea on how well yous cardboard works with the resin. Run the brush on the edge several times to force resin through the holes, and wait an hour, the resin will eventually find its way down and out and will make the outer surface dark/wet. The time from no resin to ready is over 4 days, 12 hours in it will be non stick and easy to work with, bend it a bit, make final adjustments etc, maybe apply some more, but it needs at least 4 days to reach full hardness.

    the paint is FLAME BLUE spray, 400ml – FB-834 (LIGHT GREY NEUTRAL), and is almost identical to the Ice (white) Bama sfera flower pot.

  • @enaon
    Thank you so much for all these details! My wife also ordered a CATLINK Pro-X self-cleaning litter box—apparently, she doesn’t have much faith in my DIY skills. 😅
    That said, this could be a great opportunity for me to draw some inspiration from it.

    Our main concern has been how long we can leave our cats alone. We were aiming for around 15 days, which really limits the available options on the market. This litter box has a 13L dirt capacity, which might work for us since our cats (and their poo) aren’t too big. However, I wouldn’t want to rely on it long-term.

    One feature I found interesting is the microwave radar sensor, which eliminates blind spots. It seems like a great idea to incorporate into a DIY project.

    I didn’t purchase their entrance step, though, because $99 for a piece of plastic feels excessive. Instead, it seems like a perfect opportunity to test your cardboard-resin method.
    You mentioned in the Greek forum that polyurethane resin is cheaper than epoxy and has a more plastic-like feel, whereas epoxy is closer to polycarbonate. Does polyurethane feel similar to ABS, or is it softer? Also, is it stiff enough to support a cat’s weight (assuming the design is similar to your tank as example)?

    I’m really looking forward to more details from you. Thanks again for your help!

  • My wife also ordered a CATLINK Pro-X self-cleaning litter box

    Good choice on the a CATLINK Pro-X self-cleaning litter box, we will pretend it was yours. :) 15 days is easy to achieve if you switch to crystal sand, or some other non clumping type for the period you are away. The 13L dirt capacity is not that important because if 13 lt of bentonite mixed waste is in the waste bin, no sand will be left inside the litter box, it will be empty, they will have no place to go. For 15 days you do not need just a huge waste bin, you also need a way for the the litter box to auto refill, or not loose too much sand. Crystal sand helps a lot on that part.

    You mentioned in the Greek forum that polyurethane resin is cheaper than epoxy and has a more plastic-like feel, whereas epoxy is closer to polycarbonate. Does polyurethane feel similar to ABS, or is it softer? Also, is it stiff enough to support a cat’s weight (assuming the design is similar to your tank as example)?

    You are right, you can use polyurethane resin too, it is not as penetrative, you will have to use the brush running along the edge technique a bit more, the end result is indeed ABS like. Not soft, just bendable a bit, but strong enough. Price wise the difference it small, If you have one or the other use what you have to test, but if you get one I think an epoxy resin like the clear-21 is best, the polyurethane will need extra care to store what is left once you open the can.

  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview
About

Automatic cat litter box.

Posted by Avatar for enaon @enaon

Actions