Closed winniiew closed 2 years ago
#include "Adafruit_seesaw.h"
Adafruit_seesaw ss;
void setup() {
while (!Serial);
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);
}
You shouldn't have to do any of that. You should be able to just define the STEMMA sensor in the config.h and call Feather.measure() to get the data: Config.h:
"{\ 'general':\ {\ 'name':'Device',\ 'instance':1,\ 'interval':2000\ },\ 'components':[\ {\ 'name':'STEMMA',\ 'params':'default'\ }\ ]\ }"
Code:
// Include configuration const char* json_config =
;
// In Tools menu, set: // Internet > Disabled // Sensors > Enabled // Radios > Disabled // Actuators > Disabled // Max > Disabled
using namespace Loom;
Loom::Manager Feather{};
void setup() { Feather.begin_serial(true); Feather.parse_config(json_config); Feather.print_config();
LPrintln("\n ** Setup Complete ** ");
}
void loop() { Feather.measure(); Feather.package(); Feather.display_data(); Feather.pause(); }
(please disregard the broken formatting on this comment)
soil_sensor sketch
#include "Adafruit_seesaw.h"
Adafruit_seesaw ss;
void setup() {
while (!Serial);
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();
Serial.print("Temperature: "); Serial.print(tempC); Serial.println("*C");
uint16_t capread = ss.touchRead(0);
Serial.print("Capacitive: "); Serial.println(capread);
delay(100);
}
serial monitor output
seesaw Soil Sensor example!
seesaw started! version: FBA278F
Temperature: 21.33*C
Capacitive: 353
Temperature: 21.43*C
Capacitive: 352
Temperature: 21.33*C
Capacitive: 352
Temperature: 21.33*C
Capacitive: 352
Temperature: 21.54*C
Capacitive: 350
Temperature: 21.43*C
Capacitive: 351
Temperature: 21.33*C
Capacitive: 351
Temperature: 21.22*C
Capacitive: 350
Temperature: 21.33*C
Capacitive: 350
Temperature: 21.22*C
Capacitive: 350
Temperature: 21.43*C
Capacitive: 350
Temperature: 21.33*C
Capacitive: 350
Temperature: 21.22*C
Capacitive: 350
Temperature: 21.43*C
Capacitive: 350
Temperature: 21.43*C
Capacitive: 349
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;
}
seesaw Soil Sensor example! ERROR! seesaw not found