Skip to content

Meowton software

Edwin Eefting edited this page Aug 9, 2020 · 36 revisions

Meowton software

Overview

A few screenshots of the webinterface:

It looks and feels like an app, but its an actual webinterface. (so you dont need any software, thanks to https://onsen.io/)

Before you can use the webinterace you offcourse need to do a few things.

You can follow the first few steps of this tutorial without connecting the extra hardware. Just a single ESP32 is fine.

ESP32 microcontroller

Meowton is controlled by a single ESP32 controller. Its recommend to use a version with 4MB PSRAM although currently we seem to have ~40kb memory left in the normal ESP.

However its possible we add some features that take up more memory in the future.

I use the Lolin D32 pro usually: https://www.aliexpress.com/item/32883116057.html?spm=a2g0s.9042311.0.0.27424c4dcXoHtP

Flashing Micropython

First make sure your ESP32 has the correct Micropython version.

Follow the instructions here: https://micropython.org/download/esp32/

Currently i'm using: esp32spiram-idf3-20191220-v1.12.bin

Sometimes an ESP comes with micropython already installed, but i recommend reflashing it to the latest stable version.

Getting meowton

You can either choose to clone the master or get a release.

I just released 1.0, so for now its the same as master. But i might make some huge changes in master for the next big release at any moment offcourse.

Uploading meowton to your ESP32

Notes:

  • I use vscode with the pymakr extension to upload the files to the ESP32.
  • Make sure you only open the micropython directory, and not the whole repository.

First copy config.py.example to config.py and edit it.

Its important you enter your WIFI-settings. The other settings are not important right now.

Now press the upload button in the bar to actually upload the files. You'll see something like this:

NOTE: pymakr or the esp sometimes have issues after you uploaded a few times. In that case a reset via the actual reset button usually helps. Or press ctrl-c a few time. Or close the window by clicking the trashcan.

First boot

After this MEOWTON should boot and you should see something like this:

The errors are normal, since the hardware isn't configured yet.

It should connect to your wifi and it should tell you where to reach the webinterface.

At this point you can check and see if you can reach the webinterface.

Configuring the pins

For the next steps you need to actually connect the ESP32 to the rest of the electronics and hardware.

The pins you use are configurable via the Hardware settings page:

The test-button will actually test if it sees the loadcells, therefore its important you connect the loadcells to the HX711 boards before testing. (The software will test by checking for noise)

If your pins are not in the list, add them to config.py. If you find any pins that cause crashes, please inform me so i can remove them from the default pin list.

Scale calibration

To calibrate the scales, it best to get a simple calibration kit:

(Find it on Ali by searching for 'calibration weight' and sort on Orders.)

This way you can also test the scale with different weights after calibrating.

Yolo?

Otherwise you can always YOLO it and use sugarcubes as calibration weights or something else you know the approximate weight of.

Eventually everything will be relative: The correct amount of food is trial and error anyway, so its just a number you change. Just make sure you calibrate it with the same calibration weight every time.

Calibrating the food scale

You need a calibration weight of 10g. (or edit scalefood.py)

Food scale calibration procedure

  • Make sure food bowl is complete (doesnt have to be empty)
  • Select recalibrate cat food from the menu. (typeo :)
  • The status screen should show calibration messages.
  • Follow the instructions on the screen.

Now test if its accurate by using different weights.

If it doesn't seem to be accurate, make sure the scale isn't jamming.

It should be able to differentiate between food pellets of approx 0.2g each.

Calibrating the cat scale

The sensors of the cat-scale are calibrated individually. The software is configured for a 200g calibration weight. (or edit scalecat.py)

Make sure the scale-joints are flat enough so you can put that weight on. (or remove the joints)

Cat scale calibration procedure

  • Make sure scale plate is removed.
  • Select recalibrate cat scale from the menu.
  • Follow the instructions on the screen:
    • The order of the cells isn't important, as long as you calibrate them all.
    • You can also calibrate a cell multiple times if you think you made a mistake.

Testing

Its imporant to test the cat scale a few times. I've had some incorrect calibrations with gave me incorrect results, due to one loadcell being calibrated in the wrong way. This will show too much different between your cats weight on different days.

With or without the plate, the scale should be able to measure the 200g calibration weight with a +/- 2g variation.

If the variation is like +/- 10g, there might be something wrong.

Tips:

  • Try without the plate and test the cell individually.
  • Add the scale plate and move the weight to all corners and in the middle. The result should be accurate each time. (+/- 2g)
  • If you're sure the individual calibration is ok, the scale plate might be jamming/rubbing a bit. Try shifting it to the middle so it doesnt touch any of the corners.
  • Also test with a huge weight of a few KG, and THEN add the 200g weight, to see if it still correct. Usually the cells aren't perfectly linair, so it will probably show a incorrect. This isn't a huge problem, as long as its still the same value on all corners. We want precision, not accuracy: We want to precisely measure the CHANGE in weight and don't care as much about the accurate weight.

In practice a bit of rubbing is no problem, since a cat is much heavier than 200g. It shouldn't actually jam tough.

Calibrating the servo

Since not all servo's are the same, a calibration to find the "middle" of the servo is needed. This value depens on the brand/type it seems.

NOTE: Use 360 degress freely rotating servos, as is mentioned in the Food dispenser .

Never press the test servo button when there is food in the dispenser!

Servo calibration procedure

  • Go to the feeder setting menu
  • Make sure the servo can rotate freely and without any food.
  • Press Test Servo:
    • The servo should rotate to the right (if you look on top), and then rotate back again.
    • If it turns the wrong way, invert the speed from negative to postive.
    • It should end up at the same position that it started from.
    • Keep adjusting the sliders until it does this.
    • Usually you can configure the servo for max speed.

Configuring feed cycle.

Now its time to actually time to tell the system how much to feed every time.

The goal is to have it feed a decent amount every time, not overflowing the bowl.

The amount and variation between individual portions doesn't matter that much: The system will measure how much the cats actually eat anyway.

Its good to have the servo retract just a little bit to further prevent jams, although this isnt always needed it seems.

Meaning of the parameters:

  • Ramp up/down time: In order to reduce noise and wear of the mechanism, we can ramp up the motor slowly. Usually around 250mS is ok.
  • Feed time: The amount of time to keep the servo running, after ramping up. I use around 100mS, since the ramp-up time is already pretty long.
  • Retract time: Run the motor in reverse for this long after feeding. If its 0 it wont reverse at all. If its bigger than 0, dont forget to take into account the ramp up/down time as well!

After you're fairly confident it seems to run well, add food and try to see if the portions are the right size. The bottom of the bowl covered in food is the right amount.

Trial and error a few times so you get it right for your food and situation.

Add cats \o/

Now you can finally add your cats and let the system do its work!

If you set a cats weight to 0 it will learn it the first time a cat steps onto the scale.

After that every measurement is averaged out. (Each stable measurement is averaged with a moving average factor of 1%)

The system should keep feeding a cat, as long as its on the scale and the current quota is above 0. (and the food scale is below 0.5g)

The current quota will be gradually increased over a period of 24h, so the cat gets the daily quota.

If all cats have a current quota of over 10g, the system will feed one portion to "lure" the cats. (will make this configurable in a later version)

Troubleshooting

I keep having upload problems in pymakr.

If you keep having problems uploading/writing files your flash filesystem may be corrupt.

Use this to reformat it: You will lose all your data stored on the ES32

import os
import flashbdev
os.VfsFat.mkfs(flashbdev.bdev)
Clone this wiki locally