sparkfun / OpenLog_Artemis

The OpenLog Artemis is an open source datalogger the comes preprogrammed to automatically log IMU, GPS, serial data, and various pressure, humidity, and distance sensors. All without writing a single line of code!
https://www.sparkfun.com/products/15846
Other
88 stars 47 forks source link

Feature Request: log negative weights from loadcell-nau7802 #176

Closed gmkado closed 8 months ago

gmkado commented 1 year ago

Subject of the issue

I can't get my loadcell to work with openlog artemis. Not sure if its due to the load cell reporting negative raw values, but I'm just getting empty entries (not zeros in compression + values in tension like I would expect if that were the case). Read on for details

Your workbench

Steps to reproduce

Make all connections and open serial port using arduino IDE.

One strange thing to note, initially in the weight field I was getting weird characters like ⸮. So I initially thought it was a text encoding issue, (but everything else was printing out fine). So I tried another serial port monitor that allowed me to change the encoding to e.g. UTF-8, 16, etc but nothing there worked.

After that I tried removing datalogging, and I think at that point it stopped printing out weird characters and just prints out empty entries like in the snippet below. So I thought it might be a rate issue and slowed the polling down to 1Hz. I also tried the baud rate at 115200 and 9600, made no difference.

Expected behavior

Values are logged in the "weight" column of the output

Actual behavior

This is what's logged:

SD init failed (second attempt). Is card present? Formatted?
Please ensure the SD card is formatted correctly using https://www.sdcard.org/downloads/formatter/
Config file read failed: SD offline
Artemis OpenLog v2.4
SD card offline
Datalogging offline
Serial logging offline
IMU offline - or not present
Identifying Qwiic Muxes...
Identifying Qwiic Devices...
Autodetect complete
Device config file read failed: SD offline
LoadCell-NAU7802 online at address 0x2A
Content-Type: text/csv

rtcDate,rtcTime,weight(no unit),output_Hz,
01/01/2000,02:29:14.04,,100.0,
01/01/2000,02:29:15.05,,1.961,
01/01/2000,02:29:16.05,,1.485,
01/01/2000,02:29:17.06,,1.320,
01/01/2000,02:29:18.06,,1.241,
01/01/2000,02:29:19.07,,1.190,
01/01/2000,02:29:20.07,,1.159,
01/01/2000,02:29:21.08,,1.135,

I also ran this example off a spare arduino and am able to see the values update.

This led me to discover I was getting zeros for "compression" and actual values for "tension", which led me to this forum post, which led me here.

Following the advice on that post, I changed the "allowNegativeWeights" to true in the sketch, and I get the following output:

Reading: -190173    Weight: 1.73    AvgWeight: 1.71 Scale not calibrated. Press 'c'.
Reading: -192422    Weight: 1.71    AvgWeight: 1.71 Scale not calibrated. Press 'c'.
Reading: -188475    Weight: 1.70    AvgWeight: 1.72 Scale not calibrated. Press 'c'.
Reading: -184800    Weight: 1.68    AvgWeight: 1.71 Scale not calibrated. Press 'c'.
Reading: -183763    Weight: 1.64    AvgWeight: 1.68 Scale not calibrated. Press 'c'.
Reading: -179378    Weight: 1.59    AvgWeight: 1.65 Scale not calibrated. Press 'c'.
Reading: -172773    Weight: 1.57    AvgWeight: 1.62 Scale not calibrated. Press 'c'.
Reading: -172112    Weight: 1.55    AvgWeight: 1.59 Scale not calibrated. Press 'c'.

(Side note, I could not get the scale calibration to "pass", it always says scale not calibrated...)

So I went back to the OLA and thought maybe it would log data if I kept it in tension (aka positive values) but that doesn't seem to work.

Would appreciate any help getting this thing to log. Thanks!

PaulZC commented 1 year ago

Hi @gmkado ,

You need to calibrate the NAU7802 through the OpenLog Artemis menus. Open the serial Menu and select option 6 "Detect / Configure Attached Devices". Select the NAU7802 from the list. From the NAU7802 sub-menu, select option 2 "Calibrate Scale". It will guide you through setting the zero point and then calibrating with a known weight.

Unfortunately you need to do this each time the OLA restarts. The firmware is not able to save the zero point and calibration factor - as this depends on whether the NAU7802 is connected through a mux. The DataLogger IoT is able to save the configuration - but currently does not support muxes...

Let me know if you need more help.

Best wishes, Paul

PaulZC commented 1 year ago

OK. I just saw your Forum post:

https://forum.sparkfun.com/viewtopic.php?p=243322#p243322

I will change this to a "negative weight" feature request.

gmkado commented 1 year ago

@PaulZC thanks for the help! I just tried what you suggested but I can't get past the sensor menu:

image

Pressing 1 and enter doesn't do anything. Any idea why?

Also regarding this statement:

Unfortunately you need to do this each time the OLA restarts. The firmware is not able to save the zero point and calibration factor - as this depends on whether the NAU7802 is connected through a mux. The DataLogger IoT is able to save the configuration - but currently does not support muxes..

Does this mean I can save calibration If I'm not using a mux? Also, there's no way to just log the raw values?

PaulZC commented 1 year ago

Hi,

For the sensor menu: check your line endings (how you have the enter key configured). If you are using the Arduino IDE Serial Monitor, set the line ending to Newline. If you are using a terminal emulator, dig around in the settings for new-line. You need to send a New Line '\n' (ASCII 10 (decimal)) - or Carriage Return '\r' (ASCII 13 (decimal)) - or both. (Some menus respond to a single character - the '1' on its own. Some need the terminator. That menu needs the terminator.)

Sorry, no, you cannot save the calibration at all at present. To do it properly, the firmware would need to record the mux address and port (if connected), or NULL values if connected on the main I2C bus. That requires new code... You could 'cheat' and record the zero point and calibration factor for only a single device on the main bus. That would be much easier but again still requires new code. Sorry, no, it is not possible to record raw values.

Best wishes, Paul

gmkado commented 1 year ago

Okay so it seems like the OLA in its current implementation won't work for my application since it requires some user interaction on power cycle.

I'm going to switch to using the pro-micro along with the arduino library. You can close this ticket

PaulZC commented 8 months ago

Hi @gmkado ,

It may be too little too late, but this issue is resolved in firmware v2.6. I found a bug which was preventing the NAU7802 from being configured correctly when connected through a mux. This is now resolved. And you can log negative weights too. The configuration for each device is stored on SD Card and is now restored correctly on power-up or wake. Please check the v2.6 release notes for more details.

Best wishes, Paul