So i ran the program with the proper formula for my threshold. I kept getting weird symbols even though the baud rate was the same in my serial begin line as well as in the serial monitor. I wasn't able to get actual readings until I increased the baud rate in both as well as increase the upload speed to match with both baud rates (in the serial monitor and my serial begin line). Now its giving me a reading that I wasn't expecting. I'm very intrigued and happy as at least I'm getting feed back now. It is giving me the same number of "64" for my reading in my combined program. below I will post the new program and its screen shot of the serial monitor, the same code with the LoRa code removed (when i tried to trouble shoot what was causing the odd readings), and what I should be getting with a normal comparator program.
this is the updated program-
#include <Adafruit_ADS1X15.h>
#include <heltec.h>
#include "images.h"
#define BAND 915E6 //you can set band here directly,e.g. 868E6,915E6
// Adafruit_ADS1115 ads; /* Use this for the 16-bit version */
Adafruit_ADS1115 ads;
int16_t GPI36; // the ADS is connected to analog pin 36
unsigned int sensorReading = 0; // variable to store the value read from the sensor pin
unsigned int counter = 0;
String rssi = "RSSI --";
String packSize = "--";
String packet ;
unsigned long geoStartMillis;
unsigned long currentMillis;
const unsigned long geoPeriod = 100; //sensor read period
void setup()
{
Serial.begin(115200); // use the serial port
Serial.println("Hello!");
Serial.println("Single-ended readings from AIN0 with >3.0V comparator");
Serial.println("ADC Range: +/- 6.144V (1 bit = 3mV/ADS1015, 0.1875mV/ADS1115)");
Serial.println("Comparator Threshold: 1000 (3.000V)");
amplify();
heltec_begin();
geoStartMillis = millis(); //start time of geophone
}
void loop()
{
currentMillis = millis(); //get the current time
geo();
}
void geo() //function to get updated geophone reading
{
if (currentMillis - geoStartMillis >= geoPeriod) //test whether the period has elapsed
{
getReading();
geoStartMillis = currentMillis;
}
}
void amplify()
{
if (!ads.begin()) {
Serial.println("Failed to initialize ADS.");
while (1);
}
// Setup 3V comparator on channel 0
ads.startComparator_SingleEnded(0, 1000);
}
int getReading()
{
// read the sensor and store it in the variable sensorReading:
sensorReading = ads.getLastConversionResults();
Serial.print("GEOPHONE: "); Serial.println(sensorReading);
// if the sensor reading is greater than the threshold:
if (sensorReading > 0 or sensorReading < -1) {
heltec_send();
}
}
void logo() //logo display
{
Heltec.display->clear();
Heltec.display->drawXbm(0, 5, logo_width, logo_height, logo_bits);
Heltec.display->display();
}
void heltec_begin() //setup for heltec LoRa 32
{
//WIFI Kit series V1 not support Vext control
Heltec.begin(true /*DisplayEnable Enable*/, true /*Heltec.Heltec.Heltec.LoRa Disable*/, true /*Serial Enable*/, true /*PABOOST Enable*/, BAND /*long BAND*/);
Heltec.display->init();
Heltec.display->flipScreenVertically();
Heltec.display->setFont(ArialMT_Plain_10);
logo();
Heltec.display->clear();
Heltec.display->drawString(0, 0, "Heltec.LoRa Initial success!");
Heltec.display->display();
}
void heltec_send() //send LoRa message
{
Heltec.display->clear();
Heltec.display->setTextAlignment(TEXT_ALIGN_LEFT);
Heltec.display->setFont(ArialMT_Plain_10);
Heltec.display->drawString(0, 0, "Sending packet: ");
Heltec.display->drawString(90, 0, String(counter));
Heltec.display->display();
LoRa.beginPacket();
/*
LoRa.setTxPower(txPower,RFOUT_pin);
txPower -- 0 ~ 20
RFOUT_pin could be RF_PACONFIG_PASELECT_PABOOST or RF_PACONFIG_PASELECT_RFO
- RF_PACONFIG_PASELECT_PABOOST -- LoRa single output via PABOOST, maximum output 20dBm
- RF_PACONFIG_PASELECT_RFO -- LoRa single output via RFO_HF / RFO_LF, maximum output 14dBm
*/
LoRa.setTxPower(14, RF_PACONFIG_PASELECT_PABOOST);
LoRa.print("Stimulant ");
LoRa.print(counter);
LoRa.endPacket();
Serial.print("--Alert!"); Serial.println(sensorReading);
counter++;
}
this is what the updated program gives me for a reading regardless of vibration.
this is the updated program where I removed the LoRa code to trouble shoot-
#include <Adafruit_ADS1X15.h>
#define BAND 915E6 //you can set band here directly,e.g. 868E6,915E6
// Adafruit_ADS1115 ads; /* Use this for the 16-bit version */
Adafruit_ADS1115 ads;
int16_t GPI36; // the ADS is connected to analog pin 36
unsigned int sensorReading = 0; // variable to store the value read from the sensor pin
unsigned long geoStartMillis;
unsigned long currentMillis;
const unsigned long geoPeriod = 100; //sensor read period
void setup()
{
Serial.begin(115200); // use the serial port
Serial.println("Hello!");
Serial.println("Single-ended readings from AIN0 with >3.0V comparator");
Serial.println("ADC Range: +/- 6.144V (1 bit = 3mV/ADS1015, 0.1875mV/ADS1115)");
Serial.println("Comparator Threshold: 1000 (3.000V)");
amplify();
geoStartMillis = millis(); //start time of geophone
}
void loop()
{
currentMillis = millis(); //get the current time
geo();
}
void geo() //function to get updated geophone reading
{
if (currentMillis - geoStartMillis >= geoPeriod) //test whether the period has elapsed
{
getReading();
geoStartMillis = currentMillis;
}
}
void amplify()
{
if (!ads.begin()) {
Serial.println("Failed to initialize ADS.");
while (1);
}
// Setup 3V comparator on channel 0
ads.startComparator_SingleEnded(0, 1000);
}
int getReading()
{
// read the sensor and store it in the variable sensorReading:
sensorReading = ads.getLastConversionResults();
Serial.print("GEOPHONE: "); Serial.println(sensorReading);
// if the sensor reading is greater than the threshold:
if (sensorReading > 0 or sensorReading < -1) {
Serial.print("ALERT: "); Serial.println(sensorReading); //serial print where heltec_send() used to be
}
}
this is what the serial monitor displays with the LoRa code removed and some vibrations (The large numbers aren't from the vibrations, it seems to be very random)-
and here is finally the original Comparator program that the sensor is based off of-
#include <Adafruit_ADS1X15.h>
// Adafruit_ADS1115 ads; /* Use this for the 16-bit version */
Adafruit_ADS1015 ads; /* Use this for the 12-bit version */
void setup(void)
{
Serial.begin(115200);
Serial.println("Hello!");
Serial.println("Single-ended readings from AIN0 with >3.0V comparator");
Serial.println("ADC Range: +/- 6.144V (1 bit = 3mV/ADS1015, 0.1875mV/ADS1115)");
Serial.println("Comparator Threshold: 1000 (3.000V)");
// The ADC input range (or gain) can be changed via the following
// functions, but be careful never to exceed VDD +0.3V max, or to
// exceed the upper and lower limits if you adjust the input range!
// Setting these values incorrectly may destroy your ADC!
// ADS1015 ADS1115
// ------- -------
// ads.setGain(GAIN_TWOTHIRDS); // 2/3x gain +/- 6.144V 1 bit = 3mV 0.1875mV (default)
// ads.setGain(GAIN_ONE); // 1x gain +/- 4.096V 1 bit = 2mV 0.125mV
// ads.setGain(GAIN_TWO); // 2x gain +/- 2.048V 1 bit = 1mV 0.0625mV
// ads.setGain(GAIN_FOUR); // 4x gain +/- 1.024V 1 bit = 0.5mV 0.03125mV
// ads.setGain(GAIN_EIGHT); // 8x gain +/- 0.512V 1 bit = 0.25mV 0.015625mV
// ads.setGain(GAIN_SIXTEEN); // 16x gain +/- 0.256V 1 bit = 0.125mV 0.0078125mV
if (!ads.begin()) {
Serial.println("Failed to initialize ADS.");
while (1);
}
// Setup 3V comparator on channel 0
ads.startComparator_SingleEnded(0, 1000);
}
void loop(void)
{
int16_t GPI36;
// Comparator will only de-assert after a read
adc0 = ads.getLastConversionResults();
Serial.print("AIN0: "); Serial.println(adc0);
delay(100);
}
and this is what it should be giving me (it fluctuates from -1 to 0, but any number outside of that is me tapping around the geophone sensor)-


