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

  • hop
  • hop's Avatar
  • Offline
  • Platinum Boarder
  • Posts: 524
  • 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: 3 weeks 4 days ago by hop.

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

  • hop
  • hop's Avatar
  • Offline
  • Platinum Boarder
  • Posts: 524
  • 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 2 weeks 2 days ago #18156

  • hop
  • hop's Avatar
  • Offline
  • Platinum Boarder
  • Posts: 524
  • 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 2 weeks 22 hours ago #18157

  • hop
  • hop's Avatar
  • Offline
  • Platinum Boarder
  • Posts: 524
  • 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: 2 weeks 22 hours ago by hop. Reason: Formatting, what else? :(
Time to create page: 0.235 seconds