Black Lives Matter - Action and Equality.
0

soil sensor feather io
Moderators: adafruit_support_bill, adafruit

Forum rules
If you're posting code, please make sure your code does not include your Adafruit IO Active Key or WiFi network credentials.
Please be positive and constructive with your questions and comments.

soil sensor feather io

by xraymike on Wed Apr 29, 2020 3:34 pm

Folks,
I've gotten the stemma soil sensor to work with Arduino and the Feather Huzzah and would like to send the capacitance to io.adafruit. I've also gotten the DHT temperature sensor to talk to io.adafruit using Arduino so thought it would be trivial to port the io part over to the soil sensor. Silly me.
I've added
#include "config.h" //borrowed from the dht code
io.connect() to setup()
io.run() to loop()
but when I try to upload the capacitance to io.adafruit:
capread->save(capread);

on compile I get:
soilsensor_IO:53:10: error: base operand of '->' is not a pointer
capread->save(capread);
^
exit status 1
base operand of '->' is not a pointer

Any suggestions to what I should do?

xraymike
 
Posts: 8
Joined: Wed Oct 23, 2013 1:34 pm

Re: soil sensor feather io

by mikef137 on Wed Apr 29, 2020 11:03 pm

Can you post your full code?

Here is my code which is working well.



/************************** Configuration ***********************************/

// edit the config.h tab and enter your Adafruit IO credentials
// and any additional configuration needed for WiFi, cellular,
// or ethernet clients.

#include "config.h"
# include <SPI.h>
# include <WiFi101.h>

// include the Soil sensor library
#include "Adafruit_seesaw.h"

Adafruit_seesaw ss;

// Pin used to measure the battery voltage
#define VBATPIN A7

// Pin used to send done signal to the TPL5111 board
int donePin = 12;

// Moisture Sensor
uint16_t moistureData;
float vbatData;

int status = WL_IDLE_STATUS;


// set up the Adafruit IO feeds
AdafruitIO_Feed *plantmoisture1 = io.feed("plantmoisture1");
AdafruitIO_Feed *plantvbat1 = io.feed("plantvbat1");


/*
* *****************************************
* *****************************************
* ************ SETUP START ***************
* *****************************************
*/
void setup() {
//Configure pins for Adafruit ATWINC1500 Feather
WiFi.setPins(8,7,4,2);

// Pin used to tell the TPL5111 module to shutdown the board
pinMode(donePin, OUTPUT);

// start the serial connection
Serial.begin(115200);
delay(1000); // arbitrary delay to wait for port to open. May be able to reduce or eliminate this dealy to save a bit of power

// wait for serial monitor to open, disabled for now since it seems to make the program hang if no serial is connected
// while(! Serial);

Serial.println("IoT Plant Moisture Sensor 1");

// Checking for the presence of the moisture meter
if (!ss.begin(0x36)) {
Serial.println("ERROR! seesaw not found");
while(1);
} else {
Serial.print("seesaw started! version: ");
Serial.println(ss.getVersion(), HEX);
}

// Start Winced wifi stuff
// check for the presence of the shield:
if (WiFi.status() == WL_NO_SHIELD) {
Serial.println("WiFi shield not present");
// don't continue:
while (true);
}

// attempt to connect to WiFi network:
while (status != WL_CONNECTED) {
Serial.print("Attempting to connect to SSID: ");
Serial.println(WIFI_SSID);
status = WiFi.begin(WIFI_SSID, WIFI_PASS);
// wait 10 seconds for connection:
delay(10000); // wait 10 seconds for connection:
}

Serial.println("Connected to wifi");
printWiFiStatus();
// End Winced Wifi Stuff


// connect to io.adafruit.com
Serial.print("Connecting to Adafruit IO");
// io.connect();


// wait for a connection
while(io.status() < AIO_CONNECTED) {
// Serial.print(".");
Serial.println(io.statusText());
delay(500);
}

// we are connected
Serial.println();
Serial.println(io.statusText());

}
// ********************************
// ************ SETUP END *********
// ********************************



// **********************************
// ***** Main Loop Start ************
// **********************************
void loop() {
// io.run(); is required for all sketches.
// it should always be present at the top of your loop
// function. it keeps the client connected to
// io.adafruit.com, and processes any incoming data.
io.run();


// Read Soil Sensor
float tempC = ss.getTemp();
uint16_t capread = ss.touchRead(0);
delay(100);
moistureData = capread;
// Send moisture sensor data to adafruit io
Serial.print("-> Sending Moisture for Plant 1 to Adafruit IO: ");
Serial.print(moistureData); // Capacitive
plantmoisture1->save(moistureData);
Serial.println(" Sent!");


// Read Battery Voltage
vbatData = analogRead(VBATPIN);
vbatData *= 2; // we divided by 2, so multiply back
vbatData *= 3.3; // Multiply by 3.3V, our reference voltage
vbatData /= 1024; // convert to voltage
// Send battery voltage data to adafruit io
Serial.print("-> Sending battery voltage for Plant 1 to Adafruit IO: ");
Serial.print(vbatData);
plantvbat1 ->save(vbatData);
Serial.println(" Sent!");


delay(5000); // Five second delay before power off


// Shutdown the controller via the TPL5111 board
digitalWrite(donePin, HIGH);

delay(30000); // delay 30 seconds in case board does not sleep

}
// ******************************
// ******* End of Main Loop *****
// ******************************

mikef137
 
Posts: 1
Joined: Fri Jan 10, 2020 10:26 pm

Re: soil sensor feather io

by xraymike on Thu Apr 30, 2020 1:22 pm

Mike,
Thanks for posting that. I had some issues (maybe not updated libraries?, donno). with some of the extra sensor stuff in your code so here is what worked for me. Clearly without what you sent I would have been DOA, so thanks!

// config.h stolen from DHT sensor example...
#include "config.h"
#include "Adafruit_seesaw.h"

Adafruit_seesaw ss;
uint16_t moistureData;
float tempC;

AdafruitIO_Feed *plantmoisture1 = io.feed("plantmoisture1");

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);
}

// connect to io.adafruit.com
Serial.print("Connecting to Adafruit IO");
io.connect();

// wait for a connection
while (io.status() < AIO_CONNECTED) {
Serial.print(".");
delay(500);
}
// we are connected
Serial.println();
Serial.println(io.statusText());
}
void loop() {
io.run();

tempC = ss.getTemp();
moistureData = ss.touchRead(0);

Serial.print("Temperature: "); Serial.print(tempC); Serial.println("*C");
Serial.print("Capacitive: "); Serial.println(moistureData);
// save humidity to Adafruit IO
plantmoisture1->save(moistureData);
delay(5000);
}

xraymike
 
Posts: 8
Joined: Wed Oct 23, 2013 1:34 pm

Please be positive and constructive with your questions and comments.