Heltec Lora32 (V2) crashing when i attempt to pair it with a geophone sensor

I am new to programming and I am trying to combine two sets of code (heltec LoRa esp32 OLED sender example, and an Adafruit ADS1115 amplifier comparator example. I have a geo-phone connected to a Gikfun 20A Range Current Sensor, which is connected to the ADS115, and that finally connects to the Heltec ESP32 LoRa OLED (I know its alot). Separately these codes work just fine. If I only upload the comparator project, the serial monitor reads the stimuli correctly. When I only upload the sender example the LoRa board properly communicates with my other heltec LoRa esp32 OLED receiver setup. But when I try to combine the two the program crashes. I am trying to have the LoRa module send a packet only if the geo-phone detects vibration. Here are is the code below. I'm thinking that when It does get a reading to trigger the if statement it trips ups the program and causing it to crash. I'm looking for any tips in case this is the actual issue or if any of you guys can help me identify the real problem, I'm still very new to programming. Any suggestions? code below,

#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
int threshold = constrain(threshold, 0, -1);  // threshold value to decide when the detected noise triggers the LoRa to send a message
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(9600);       // 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 = !threshold) {
    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++;


}

Please do not cross post. Forum moderator alerted.

Other post/duplicate DELETED
Please do NOT cross post / duplicate as it wastes peoples time and efforts to have more than one post for a single topic.

Continued cross posting could result in a time out from the forum.

Could you also take a few moments to Learn How To Use The Forum.

Other general help and troubleshooting advice can be found here.
It will help you get the best out of the forum in the future.

sorry about that, How do I delete this post?

I deleted your other one so this can stay if you wish.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.