Collecting weight scale data in my… fridge.

Weight scales - engineer’s cat feeder’s worst nightmare

As mentioned before I’m chasing 0.4g of missing food in my over-engineered cat feeder. This post will focus on capturing and saving datapoints (measures) for subsequent analysis.

Data Collector

With some parts lying around and a bunch of modules delivered from the Internet, I’ve constructed a simple data logger - aka. my shoe box based “black box”:

Top view of the whole data logger. On the left majority of the electronics, on the right load cell with ADC (temporarily disconnected). Top view of the whole data logger. On the left majority of the electronics, on the right load cell with ADC (temporarily disconnected).
Boards from left to right: BME280, ADS1115, ESP8266. Generic breadboard behind. Boards from left to right: BME280, ADS1115, ESP8266. Generic breadboard behind.
Top view of tested load cell. Top view of tested load cell.
Side view of tested load cell. Side view of tested load cell.

My collector includes a couple components which will are relevant only for the research phase - I want to know if/how different environment variables impact load cell reading. The data collector consists of:

  • microcontroller - ESP8266 - had lying it around & needed internet based timestamp for post processing
  • ADS1115 - 4channel, 16bit ADC to read reference voltages
  • BME280 - I2C/SPI temperature, humidity, pressure sensor
  • SD card - to store captured data
  • [optionally] small fan to distribute heat evenly in the environment
  • [optionally] designated reference voltage for cell sensor ADC
  • [variation of] different power supplies
  • [variation of] different ADC sensors (HX711, NAU7802)
  • shoe box with a lid, some wood, and a bunch of wires

The shoe box housing with a power bank inside will allow me to put the whole apparatus to a fridge and capture weight scale measures over broader range of temperatures.

For simplicity and to save pins on ESP8266 I connected what I could by I2C interface. I don’t have any circuit diagrams available, but here is a useful website to get started with ESP8266 and you will find there also the module pinout. Together, that should allow you to connect your sensors to the microcontroller.

In my case the connections look like this:

Mini electronics spaghetti. Mini electronics spaghetti.

Interested in Cat Feeder updates? Perhaps you are just interested in the finished product? Anyways, feel free to sign up, I'll let you know.

We respect your email privacy

Firmware

I’ve written some ugly C code to capture different measures (like: timestamp, input voltage, iteration, scale reading, …), store up to a few kB of them in ESP8266 memory, and then flush periodically to an SD card. This way of saving metrics allows me to capture every variable (time, temperature, scale, etc.) over 100 times per second, given all sensors are fast enough. By periodically flushing to the SD card I’m avoiding wearing the card out. To make the resulting data easy to post-process, I’m including epoch time of every measure iteration. This is only an approximate time, which I’m getting by retrieving the current epoch time from the internet upon the start of the experiment. Then I turn the Wi-Fi off to reduce potential noise.

A sample resulting file PiPower_NoShield_0g_noADS_wBME280_wFAN_FirstRunIter1_1643096721.csv might look like the following:

iteration,timestamp,testName,millis,freeHeap,vIn,vHX711ref,temperature,humidity,pressure,scale,scaleGain
1,1643096721411,PiPower_NoShield_0g_noADS_wBME280_wFAN_FirstRunIter1,4411,38648,4.614847,0.014483,21.309999,45.722656,981.940186,291309,128
2,1643096721437,PiPower_NoShield_0g_noADS_wBME280_wFAN_FirstRunIter1,4437,37992,4.613843,0.009739,21.309999,45.722656,981.940186,291355,128
3,1643096721503,PiPower_NoShield_0g_noADS_wBME280_wFAN_FirstRunIter1,4503,37992,4.613341,0.011986,21.309999,45.676758,981.943726,291380,128
4,1643096721594,PiPower_NoShield_0g_noADS_wBME280_wFAN_FirstRunIter1,4594,37992,4.603307,0.012985,21.309999,45.676758,981.963135,291292,128
5,1643096721683,PiPower_NoShield_0g_noADS_wBME280_wFAN_FirstRunIter1,4683,37992,4.617857,0.011737,21.309999,45.653320,981.976746,291267,128
6,1643096721772,PiPower_NoShield_0g_noADS_wBME280_wFAN_FirstRunIter1,4773,37992,4.606317,0.011986,21.309999,45.653320,981.973267,291256,128
7,1643096721862,PiPower_NoShield_0g_noADS_wBME280_wFAN_FirstRunIter1,4862,37992,4.611084,0.011487,21.309999,45.630859,981.971619,291208,128

Firmware code

You can see the code on GitHub - weight_scale_data_collection.

Next steps

Crunching & graphing tons of data. Learn & repeat! Stay tuned!

Please note: the views I express are mine alone and they do not necessarily reflect the views of Amazon.com.