When I take a write a sketch with a loop reading software serial AND i2c ads1115, the ads1115 reads sucessfully UNTIL the code to read the serial port runs (softwareserial) and then the ADS1115 returns nothing.
Kind thanks in advance
When I take a write a sketch with a loop reading software serial AND i2c ads1115, the ads1115 reads sucessfully UNTIL the code to read the serial port runs (softwareserial) and then the ADS1115 returns nothing.
Kind thanks in advance
Your explanation also "returns nothing".It's impossible to someone help you with just this info.At least post the code ...
#include <Wire.h>
#include <Adafruit_ADS1015.h>
#include <SoftwareSerial.h>
#include "cozir.h"
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE); // Set the LCD I2C address
SoftwareSerial nss(3,2);
COZIR czr(nss);
Adafruit_ADS1115 ads; /* Use this for the 16-bit version */
double xfactor;
int outPin = 13;
void setup(void)
{
lcd.begin(20,4); // initialize the lcd for 20 chars 4 lines and turn on backlight
delay(5000);
// czr.CalibrateFreshAir();
pinMode(outPin, OUTPUT);
Serial.begin(9600);
Serial.println("Hello!");
Serial.println("Getting single-ended readings from AIN0..3");
Serial.println("ADC Range: +/- 6.144V (1 bit = 3mV/ADS1015, 0.1875mV/ADS1115)");
lcd.setCursor(0,1);
lcd.print("Air calibration!");
ads.setGain(GAIN_SIXTEEN);
ads.begin();
xfactor = ads.readADC_SingleEnded(0);
xfactor = 20.94 / xfactor;
}
void loop(void)
{
digitalWrite(outPin, HIGH);
delay(1000);
digitalWrite(outPin, LOW);
delay(1000);
int16_t adc0, adc1, adc2, adc3;
adc0 = ads.readADC_SingleEnded(0);
Serial.print("AIN0: "); Serial.println(adc0);
Serial.print(adc0*xfactor);
Serial.println(" ");
delay(1000);
float f = czr.Fahrenheit();
int c = czr.CO2();
//int digi = czr.GetDigiFilter();
lcd.setCursor(0,0);
lcd.print("CO2 : "); lcd.print(c);
lcd.setCursor(0,1);
lcd.print("Fahrenheit : "); lcd.print(f);
lcd.setCursor(0,2);
lcd.print("O2 : "); lcd.print(adc0);
Serial.println("");
}
As soon as I remark the line
int c = czr.CO2();
my ads1115 reads no problem, as soon as I unremark it, the ADS1115 stops returning a reading.
Sorry about the messy code!
Sorry about the messy code!
It is not that bad ... but CTRL-T does an autoformat, so a cleanup is faster than the apology ![]()
As soon as I remark the line
int c = czr.CO2();
my ads1115 reads no problem
does the ADC block?
or does the LCD block?
Sorry, when the program gets to the line
int c = czr.CO2();
the ADC (ADS1115) stops responding and returns nothing.
The LCD continues to work no problem as it keeps a log of the CO2 level.