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 4 months 3 weeks ago #18154

  • hop
  • hop's Avatar
  • Offline
  • Platinum Boarder
  • Posts: 526
  • Thanks received: 46
FAST BATCH FILE UPLOADS SOLVED!
Curl to the Rescue!

"PREVIOUSLY... ON 'LOST'"
Another issue I have been going after is a new way to upload the website files.
After tons of searching and trying a half dozen different things, I finally happened upon a thread where the author used CURL to send HTTP REQUESTS to a web server. The code on the server has to handle the requests of course, but that was not too terribly hard in Arduino for ESP8266. I am looking to do the same thing in Python so I do not have to use Curl. But for now, with the aid of a bash script, I can upload to the board any file that has changed within the last couple of seconds. It's beautiful man!

The watchdog script just periodically checks files in a folder on my remote system for changes. When a change is found, it is uploaded via CURL and an HTTP REQUEST to the SPIFFS in the board system. I will have to add JS code to monitor file versions or sizes maybe to auto-update a page if the current page (or its components) have changed. This is just icing on the cake though.

NO MORE UPLOAD BUTTON!! NO MORE FILE PICKER BUTTON!!!! YAY!

It seems terribly helpful and convenient, until you do it a few thousand times!!

More is coming...
Last Edit: 4 months 3 weeks ago by hop.

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

  • hop
  • hop's Avatar
  • Offline
  • Platinum Boarder
  • Posts: 526
  • Thanks received: 46
WEMOS D1 MINI PRO UNABLE TO BOOT <SOLVED!>
Read the Effing Manual!

I had a bad issue with the WEMOS board not starting. It was periodic but happened enough to be an annoyance. Actually, happening even just ONCE is a concern because with my luck, it would be when I am away, after a power outage.

Well, if I had RTFM'd, expanded is READ THE 'EXPLICATIVE REMOVED' >EFFING< MANUAL, I would have known that GPIO 0, 2, and 15 are used in the boot up process. And GPIO 15 (D8 on the board) was connected to my PIR sensor. When this pin is high when reset and/or booting, the ESP8266 accesses a connected SD CARD to boot from. I do not have one connected, so the device would just HANG!

Moving the PIR to GPIO 16 (D0) fixed this completely.

In the meantime, my prototype that is in place controlling the cat box is still running strong and has not needed a reset since I placed it a few months ago. The prototype on my bench is way further in an upgrade, so I am hoping that it will be as stable.

The funny thing about this issue is that when I reached over to reset the device, my hand movement triggered the PIR and its output went HIGH, which triggered SD CARD boot mode. The more frustrated I got, the more my hand 'aggressively' clicked the reset, which continued to trigger the PIR. Had I reset the device in more of a ZEN fashion, the HANG would have been less frequent. lol

More is coming...

Hacking my new SafePet Rotating Litter Box for Cats 4 months 2 weeks ago #18156

  • hop
  • hop's Avatar
  • Offline
  • Platinum Boarder
  • Posts: 526
  • Thanks received: 46
HAVING A LITTLE FUN TODAY
Need for Connected Info to be Displayed

I already had the data available so adding connected info to the served web page was really no major trick. What the most tricky part was how it was asked for and how often. With all these pieces of data being asked for from the server, it became obvious that I needed some structured way to define how often each piece of data would be updated using timers from a core timer IRQ handler. What came from this realization was that I certainly needed to clean all that up and package it into either a library or at least stream line it.

To this point, I would just add a new timer variable and then duplicate the components. More on this in the next post.

For now, I needed to expand the HUD to display the connection information. SSID connected to, IP address and other network addresses, signal strength etc. This also does not need to be displayed often. Actually, just once and then again if anything changed. This is pretty simple stuff with the unclean framework I developed so that is what I am going after today.

Also, in addition to the need for event timing stream-lining, I also realized that frequent updates are really not needed for the loop iterations, the ram available, and ping results. The frequent once-per-second updates are an annoyance really and want them less frequent. Maybe every 5 seconds, or maybe an average of 1-second samples to be displayed every 10 seconds. Instead of changing several constants to make this happen, I decided to wait until I stream-line the events handler.

Everything else is extremely stable. The code runs without fail over long periods of time, recovers from network interruptions, and takes care of the processes it has to without fail at all. Everything I dreamed of going into this.

This is going to be a fantastic framework for all my IoT projects. Fairly light and configurable, stable, and full of reporting any server-based database handling script in python could ever dream of!

Hacking my new SafePet Rotating Litter Box for Cats 4 months 2 weeks ago #18157

  • hop
  • hop's Avatar
  • Offline
  • Platinum Boarder
  • Posts: 526
  • Thanks received: 46
HAVING MORE FUN TODAY, AND REVISIONS
Adding Current and Voltage Reporting, and… REVISIONS – YAY.

Everything is going perfect! So why not mess it up? Yeah, gotta break a few eggs to make an omelet and all that.

I have always wanted to have my IoT devices report supply voltage level and project current use which is why I decided to get a few INA219 breakouts to make that happen. I had to take it in the shorts to get 2 boards via Amazon Prime, they are easily 6 times the price I can get on AliExpress, but I do not want to wait 30 days to work with this board. The data from this breakout module will be displayed on the served web interface. I’m excited!!

Now the breaking of eggs… I decided to streamline the timer IRQ so I do not have so much heavy overhead with the timing of the various processes. I also decided to implement a command protocol for sending data to the various fields of the web interface. This is pretty simple stuff on the surface, but some changes need to be made. For one, I decided it is better to have stuff update every 5 seconds instead of every second. But I also wanted to smooth things out so decided to take an average of multiple data samples with each update. Since there is a larger group of data topics to display, I decided to use a simple command protocol that the web interface will parse and distribute the data. Although I hate using numbers to represent commands, I went with that here because I want to keep the code footprint down.

Every 5 seconds, adjustable, a stream of data will shoot from the core device (ESP8266) to the served web interface where the contents of the packet will be parsed and data distributed. The various parts of the packet will be built in the background and be ready when the event happens to avoid delays with the update interval.

There are timer (ticker) libraries out there but I just created and implemented a simple one for my use. There is a core pulse timer that happens the fastest, say every millisecond. Each slave timer will draw from that and trigger based on parameters, like interval, offset, and number of iterations. The offset will allow longer delays to fire at a given offset so similar delays do not all fire at once. So say I have 3 x 5 second interval timers… I want them to fire like 500 ms of each other (OFFSET) so the processing of their events is smoothed out over the period of the interval. It is probably overkill, but then I do not have idle hands standing around then not have enough workers when the load arrives to be worked. So to speak.

If all goes well, this should reduce the code footprint in the IoT device, except for the larger JS file in SPIFFS of course, and shift the processing more towards the web interface client.
Last Edit: 4 months 2 weeks ago by hop. Reason: Formatting, what else? :(

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

  • hop
  • hop's Avatar
  • Offline
  • Platinum Boarder
  • Posts: 526
  • Thanks received: 46
BACK FROM VACATION!
Getting Familiar with Python.

During a long-anticipated vacation that took us to Pinetop in the Arizona White Mountains, I decided to get acquainted with Python finally. As I usually do when I want to get quick-familiarity with a language I do not know or have any experience with, I go after writing some scripts or applications with it to do something I have always wanted to do. Then as I write the solution, I google search and in-depth read up on (if needed) on how to solve each hurdle I encounter. It is an awesome strategy as it teaches me how to set up an environment to write, debug, and deploy the work towards the solution. The giant flaw with this approach of course is that I leave massive holes in my knowledge of the language. So I give here a respective nod to those that have studied and mastered the language thoroughly and mean no disrespect at all. I have been doing this for years and it allows me to work with the language and do the work to fill in the holes later. Sometimes as-needed, and sometimes just to learn the rest that the language has to offer. I also get rewarded when I discover new ways to do what I already did, and new features of the language.

So that is what happened this week. And it is important to note that being able to at least write functional python scripts to support this project and so many others has totally changed my perspective of the involved components of my desired system. That of home server, autonomous control, and state-machine type thinking of my IoT network. Each feature I add to this system's end-game compliments everything I want to do, even projects that are not IoT related.

So now I am back home and a day removed from getting back to work at my real job, but I have fresh perspective on how this project, and all that is born from it, will evolve. And even a graphic card failure on my main machine the last day of my vacation cannot stop this, although it did set me back a day of evolving, and $182 USD. Grrrr. >X^O

In the meantime... my previous revision of the ESP8266 code and supporting web interface passed the autonomous test, working all week without a reboot, doing its cleaning and house keeping! And it also passed the simple end-user test by our daughter, definitely a non-techie, who accessed the web interface using her smart phone to initiate cleaning cycles on demand. Apparently, my cats eat and poop a lot more when I am away! lol

More when I code it, as I get back into the captain's chair. My new video card arrives tomorrow. A modest step up in my legacy gear replacing my failed 12-year-old Galaxy Geforce GTX 460 with a Gigabyte Geforce GTX 1050 Ti OC 4GB GDDR5 128 Bit PCI-E Graphic Card (GV-N105TOC-4GD) which I think I paid too much for. I'm limping along with a Geforce 210 but then that keeps me from gaming. ;)
Last Edit: 3 months 4 weeks ago by hop. Reason: Credit where Credit is Due
Time to create page: 0.243 seconds