OPEnSLab-OSU / Loom

Arduino library for Internet of Things Rapid Prototyping in environmental sensing
GNU General Public License v3.0
26 stars 3 forks source link

STEMMA Inits, but reports only 65535 #139

Closed udellc closed 2 years ago

udellc commented 3 years ago

Describe the bug STEMMA inits okay. Temp value is good. But reports only 65535 for Capacitance value. Old STEMMA sensors work, but no new STEMMA sensors work

Hardware in Use STEMMA, Adalogger M0

To Reproduce Steps to reproduce the behavior:

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

Expected behavior Sensor val should report 300 something as nominal value and go up to about 1000 when held in hand. Code

include "Adafruit_seesaw.h"

Adafruit_seesaw ss;

void setup() { Serial.begin(115200);

Serial.println("seesaw Soil Sensor example!");

if (!ss.begin(0x36)) { Serial.println("ERROR! seesaw not found"); while(1); } else { Serial.print("seesaw started! version: "); Serial.println(ss.getVersion(), HEX); } }

void loop() { float tempC = ss.getTemp(); uint16_t capread = ss.touchRead(0);

Serial.print("Temperature: "); Serial.print(tempC); Serial.println("*C"); Serial.print("Capacitive: "); Serial.println(capread); delay(100); }

Config No config here, just example code

Additional context It seems we need to update library and add new one https://github.com/adafruit/Adafruit_BusIO (Links to an external site.) https://github.com/adafruit/Adafruit_Seesaw (Links to an external site.)

Need to update Board profile to include these libraries and delete old Seesaw

BGoto808 commented 2 years ago

Seems that the library itself is the issue because testing the sensor with the Adafruit's example code produces the same problem (https://forums.adafruit.com/viewtopic.php?t=162556). Someone pointed out that there was an error with the touchread function and they modified it and got it working.

''' /*!


winniiew commented 2 years ago

Commented out the touchRead() and replaced with

uint16_t Adafruit_seesaw::touchRead(uint8_t pin) {
uint8_t buf[2];
uint8_t counter=0;
uint8_t p = pin;
uint16_t ret = 65535;

do {
  delay(1);
  this->read(SEESAW_TOUCH_BASE, SEESAW_TOUCH_CHANNEL_OFFSET + p, buf, 2,
5000); //increasing the length of the buffer time
ret = ((uint16_t)buf[0] << 8) | buf[1];

counter++;
} while ((ret == 65535) & (counter<3));
return ret;
}