Welcome, Guest
Username: Password: Secret Key Remember me

TOPIC: Hacking my new SafePet Rotating Litter Box for Cats

Hacking my new SafePet Rotating Litter Box for Cats 3 months 3 weeks ago #18148

  • hop
  • hop's Avatar
  • Offline
  • Platinum Boarder
  • Posts: 526
  • Thanks received: 46
ALL TOO EASY!

It's moments like this where all the countless hours working on a simple frame work actually pay off!

All I needed to do to investigate my memory leak suspicion was to not only periodically gather that info, but to report it to the website. That would have been a daunting task, but not with the frame work I wrote.

All I had to do was gather the heap information, then send it to a channel so it could be routed to an element on the page. Since I already have a 1000ms timer period triggered using an IRQ handler, setting a timer_pulse flag to true every time it fires was simple. Then the loop acts on it, sends the websocket data, and it is displayed on the web page.

Of course I am not happy with just having that data in front of me. I want it to show difference over time, so I am setting it up to look at changes over the last 10 seconds, minute, hour, and since restart. The only question now is whether to have the client figure that out or the ESP8266. I am thinking that it should be the client, since it has time keeping ability too, it can calculate all that and control displaying it. Then all the ESP8266 has to do is send the data once per update period.

This opens yet another little can of worms. I should ponder changing the periodic timer IRQ handler to fire every 10th of a second instead of every second, adjust all the other variable timing, and then I can increase the resolution of updates if needed. This will also allow me to test load and see how my clients react. All the other IRQ handling is GPIO pin state-changing-triggered so when things happen, they still will have real-time feel as they send their websocket messages when fired. This periodic timer pulse is just for updating/refreshing system status, etc.

Again, seems like a lot of effort and functionality for just a cat-litter-cleaning box controller, but then this is being designed for a much bigger picture. If I can successfully get all this into a class library, I can easily use it with ANY project. And I cannot tell you how exciting that is for me right now. YEARS in the need basket/ bucket list for me.

Hacking my new SafePet Rotating Litter Box for Cats 3 months 3 weeks ago #18149

  • hop
  • hop's Avatar
  • Offline
  • Platinum Boarder
  • Posts: 526
  • Thanks received: 46
It's coming along. This is the first pic of many.

This is the mobile smartphone web page served by the ESP8266 from SPIFFS.

Hacking my new SafePet Rotating Litter Box for Cats 3 months 2 weeks ago #18150

  • hop
  • hop's Avatar
  • Offline
  • Platinum Boarder
  • Posts: 526
  • Thanks received: 46
I know it may sound silly....

But here is the latest mobile client screen shot. I added loop() cycles per second on the system monitor section. System temperature and voltage/current draw will be about 30 days later because I had to order a part for that. :)

The timer IRQ section runs very well. I now have a pulse flag set every 10th of a second, and system stats update every second. I was worried about the IRQ handler getting too heavy, but it's just incrementing variables and doing simple tests to reset, etc. It's not hurting the overall execution at all. And the web page updates very well.

More when I do it. I am adding the Python server websockets handlers and database support for the sensors. That will run for a couple of days to give me data to tweak the trigger code. More when I get that installed and debugged.

Hacking my new SafePet Rotating Litter Box for Cats 3 months 2 weeks ago #18151

  • hop
  • hop's Avatar
  • Offline
  • Platinum Boarder
  • Posts: 526
  • Thanks received: 46
WATCH DOG TROUBLE!

I have had some trouble of late with software resets on the ESP8266. It HAS to be software related because the other Wemos D1 Pro Mini has been running for about 6 weeks without a hiccup, with a much simpler program of course.

I am sure it is some weird obscure thing I have not seen before, and anyone that has programmed for the ESP8266 knows... finding the cause is like finding a needle in a haystack of needles. Still, I will get to the bottom of it and fix it so I can move forward.

So far, I have been able to add several web-based GUI update features. In the process of doing this, I have also started cutting out old code and comments. Errors are expected as I retool it to a better stream-lined multi-project framework.

More when I do it! Stay tuned!

ADDITIONAL: I have also considered hardware causes for the software resets. After all, it would suck big time if I chased my tail about issues when it is a faulty board at the source of the problems. I have ordered 5 more of the same board from a different supplier to be able to test the software issues across more than just my 2nd prototype. Until I get those though, the only backup test platform I have is the working cat box controller I have in place with the older and simpler firmware. I am not anxious to pull that and use it as a back up. FYI
Last Edit: 3 months 2 weeks ago by hop.

Hacking my new SafePet Rotating Litter Box for Cats 3 months 1 week ago #18152

  • hop
  • hop's Avatar
  • Offline
  • Platinum Boarder
  • Posts: 526
  • Thanks received: 46
SLOWDOWN SOLVED >I HOPE<
I have been noticing all sorts of issues with my pin state interrupts (exceptions, restarts) and when the websocket client disconnects (massive slowdown). It looks like I need to switch to an asynchronous websocket server approach. I am in the middle of making that adjustment, but will post back on the effects.

When the webpage client is non-responsive, like if it is out of focus or whatever reason, the websocket loop function call in the main loop slows down with a 2ms timeout each call. This grinds the loop to a crawl. Also, when interrupts fire for my pin state changes, if they happen in an inopportune time while the websocket loop function is called, I get exception errors and sometimes restarts. Async mode is suppose to solve all this and yes I can understand why.

So I need a bit of setup for this, but I'm on it. More when I discover it.

Hacking my new SafePet Rotating Litter Box for Cats 3 months 1 week ago #18153

  • hop
  • hop's Avatar
  • Offline
  • Platinum Boarder
  • Posts: 526
  • Thanks received: 46
SLOWDOWN SOLVED >CONFIRMED<
Asynchronous Websockets Did the Trick!

After making a change to the Websockets.h library header file to enable asynchronous websocket operation, the slow down and other exception error and restart issues have going away. Even with motion sensor interrupts re-enabled and functioning. The motion sensor IRQ handling also seems to have very little effect to the timing either. I now have what I need to log motion sensor trips to a database while still controlling the cat box. The only issue that remains now is when more than one web interface instance is encountered. This is because my ping timing tests broadcast instead of targeting a specific web interface instance, understandably. This is certainly easy to fix and what I am working on today.

Another issue I have been going after is a new way to upload the website files. My code uses the typical approach of using a form 'post' to find and submit a file for upload. I would prefer to have more control over that process though and it is proving to be difficult, only to the point where it can be done but a bit larger of a task than I want to get sidetracked with. With the frequent uploads of files, specifically the main 'index.html', 'websocket.js', and 'main.css', taking time to click, select, then click again to upload, then click again to go back for another is adding up as wasted time. It would be nice if I could configure those file locations on the server then just one click update them in one shot. Without having to go through the monster task of reading up on the post/get HTML protocol for this, I am looking at uploading the files to the device's SPIFF area using a binary websocket event process. I will have to do this eventually anyway as I want to be able to send a command to all active devices and OTA updated website data to them all.

In the meantime however, I want to run my home server Python process and gather motion detection events over time to get a feel of what I am looking at with false triggers, range, etc. The microwave motion sensor has a large range and is hard to limit, and I might just scrap it and use the PIR sensor exclusively for now. The Python script I wrote also responds to queries to the database to be able to load data over time blocks for display on the web interface client. This conversation will have its own channel, and the queries will probably be made from the client over the channel, with the expected data using the same channel as a response. So far, this multi-channel scheme using websockets has proved extremely reliable and very fast, relatively speaking.
Time to create page: 0.257 seconds