Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Log Weight Changes to EEPROM #5

Closed
alexanderkjones opened this issue Apr 26, 2016 · 6 comments
Closed

Log Weight Changes to EEPROM #5

alexanderkjones opened this issue Apr 26, 2016 · 6 comments
Assignees

Comments

@alexanderkjones
Copy link
Owner

Story
As a User, I want to measure pour data from a keg and store locally on the device, in order to capture data for batch analysis.

Desc
The device when monitoring a Keg is looking for changes in weight to signify a pour start and stop to calculate the pour size and timestamp. We've implemented a method for monitoring the keg for pours below. We want to store all readings locally ATC EEPROM not ESP EEPROM for batch export. Export will be a separate Story/Issue

Method
To measure keg pours we watch for stable weight readings in 5 second intervals. Every 5 seconds the weight is checked, if the weight is the same as the last reading the reading is considered stable. If the reading is different we know there is a pour occurring which may take more than one 5 second interval to complete so we begin a new comparison for a second stable reading. I've organized this using two setpoints in an array setpoint[0,1]. Once we have a second stable reading, we mesure the delta between the two points, reset setpointp[0] with the latest stable weight, and store the delta with timestamp as a pour to be transmitted to the system.

Acceptance Criteria

  • The device follows the method to store a pour data point ie delta/timestamp
  • The developer can execute a Serial.println() of the stored datapoints in EEPROM.

Code Example

int scaleSampleWeight(){
  scale.power_up();
  int sample = scale.get_units(25);
  //Throw away last bit
  sample = (sample/10)*10;
  scale.power_down();
  return sample;
}

void watch_keg(){
  int thisRead = scaleSampleWeight();

  Serial.println(thisRead);

  if(thisRead != setpoint[0]){

    if(thisRead == setpoint[1]){
      int delta = setpoint[1] - setpoint[0];

      if(abs(delta) > 10){
        trackpour(delta);
      }

      setpoint[0] = setpoint[1];

    }else{
      setpoint[1] = thisRead;
    }
  }

} 
@alexanderkjones
Copy link
Owner Author

@JLJTGR when's you're next availability for this issue?

@JLJTGR
Copy link
Collaborator

JLJTGR commented May 3, 2016

I'm still trying to figure out the usage of the HX711 library. So far the only values I get out of it are 2147483647 and -2147483648 (0b01111111 11111111 11111111 11111111 and 0b10000000 00000000 00000000 00000000)

JLJTGR added a commit that referenced this issue May 3, 2016
JLJTGR added a commit that referenced this issue May 4, 2016
#5
Missing actual scale data or logic
@alexanderkjones
Copy link
Owner Author

@JLJTGR Here's working code for initializing HX711. I think you may have pins incorrect.

#include "HX711.h"

/* Initialize Scale*/
HX711 scale(12, 13);

void setup() {

  Serial.begin(115200);
  delay(100);

  scale.set_scale(43.5);
  //scale.tare();

}

@JLJTGR
Copy link
Collaborator

JLJTGR commented May 5, 2016

I don't think that's quite it at all. Maybe the current library is fairly different than the one you were used to using. 14/12 are definitely the correct pins. Your previous sample code assumes an int where the function returns a float. You then decimate that truncated float by a power of ten, which causes any reading below 10 lbs to become zero. Your scale calibration value is vastly different than my working one.

In short, I didn't understand what your code did, so when I used it blindly it didn't work and I didn't know how to fix it. So I just did that portion from the ground up so I actually had an understanding of it.

JLJTGR added a commit that referenced this issue May 5, 2016
@JLJTGR
Copy link
Collaborator

JLJTGR commented May 5, 2016

Output example...

Sleeping for 5 seconds...
2016-05-04 | 18:21:56
TrackPour: -12
Sleeping for 5 seconds...
2016-05-04 | 18:22:06
Sleeping for 5 seconds...
2016-05-04 | 18:22:16
Starting local AP: ESP_01560E...
Local AP IP: 192.168.4.1
Web server started...
Connecting to SSID: JLJTGR...
Connected; WAN IP: 192.168.173.100
Exporting 4 packets....
2016-05-04 18:19:57 = -14
2016-05-04 18:20:47 = -11
2016-05-04 18:21:17 = -11
2016-05-04 18:21:58 = -12
Done.
Disconnecting...

@JLJTGR
Copy link
Collaborator

JLJTGR commented May 5, 2016

I should mention that this code requires Arduino 1.6.8 to compile properly by the default IDE. There is a bug that causes the ESP8266 libraries to crash the prototyping function of the default Arduino Builder and the compile will fail.
arduino/arduino-builder#68

@JLJTGR JLJTGR closed this as completed May 5, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants