It is, I have SDA (from the ADS1115) connected to pin 21 of the Heltec LoRa32 (its SDA pin), and I have SCL (from the ADS1115) connected to pin 22 of the Heltec LoRa32 (its SCL pin). I have the ADDR connected to VDD, in which I ran a I2C bus scan to verify that the address is 0x49 (1001001). Do you know how to specify the address?
Heltec LoRa32 V2 pinout for reference
updated program, it's giving me an error when I try to add the address
#include <Wire.h>
#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 (0x49);
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)");
// 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.begin();
ads.setGain(GAIN_SIXTEEN); // 16x gain +/- 0.256V 1 bit = 0.125mV 0.0078125mV
amplify();
heltec_begin();
geoStartMillis = millis(); //start time of geophone
}
void loop()
{
currentMillis = millis(); //get the current time
geo();
if (sensorReading > 0 or sensorReading < -1){
heltec_send();
}
}
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()
{
int16_t adc0; // the ADS is connected to analog pin 36
// 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:
}
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++;
}
