bonjour,
je viens vers vous car j’ai un petit souci, je n’arrive pas a avoir une lecture de tension sur la sortie de l’ads1115
le projet est un analyseur O2, pour controler le % d’oxygene en sortie de bouteille
j’ai trouvé le code sur un site :
http://www.e-ocean.fr/index.php?option=com_content&task=view&id=127&Itemid=1
le materiel que j’ai :
Arduino Uno
Ecran 2004 i2c
ads1115
cellule O2
Par rapport au code initial, j’ai compris que je devais modifier code par rapport a la génération d’écran
avec un peu de bidouille j’ai ca :
//////////////////////////////////////////////////////////////////////////////
// Arduitrox version 1.0
// Main code by Lionel Pawlowski - Copyright (c) 2014
// ADS library by Adafruit
// Running average library by Rob Tillaart
// Commercial use and/or distribution of this code and relevant
// hardware forbidden without prior agreement.
// Provided "as is". Use at your own risk
//////////////////////////////////////////////////////////////////////////////
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include <RunningAverage.h>
#include <Adafruit_ADS1015.h>
Adafruit_ADS1115 ads;
LiquidCrystal_I2C lcd(0x27, 20, 4);;
int opmode=0;
int cnt;
float oldRA;
float sig1,sig,sig2;
float relpourc;
float gain = 0.0078125;
float pour;
RunningAverage RA(10);
int samples=0;
// Définition du gaz de référence
float calibgas=20.95;
void setup(void)
{
// Message d'accueil si besoin (nom, etc)
lcd.init(); // initialize the lcd
lcd.init();
// Print a message to the LCD.
lcd.backlight();
lcd.setCursor(0,0);
lcd.print("Arduitrox v1.0");
lcd.setCursor(0,1);
lcd.print("");
delay(3000);
Serial.begin(9600);
ads.setGain(GAIN_SIXTEEN); // 16x gain 1 bit = 0.0078125mV
ads.begin();
oldRA=0;
cnt=0;
lcd.setCursor(0,0);
lcd.print("Cal. auto");
lcd.setCursor(0,1);
lcd.print(" ");
}
void loop(void)
{
int16_t adc0;
oldRA=RA.getAverage();
adc0 = ads.readADC_Differential_0_1();
RA.addValue(adc0);
cnt=cnt+1;
sig=(RA.getAverage()-oldRA)/oldRA;
sig1=abs(sig);
// Calibration Auto
if (opmode==0) {
if (sig1<0.0002) { // 0.0002
samples=samples+1;
} else {
// samples = 0;
}
lcd.setCursor(0,1);
lcd.print(RA.getAverage()*gain,2);
lcd.print("mV ");
lcd.print(calibgas,2);
lcd.print("% ");
lcd.setCursor(10,0);
pour=samples/5;
lcd.print(pour,0);
lcd.print("% ");
if ((RA.getAverage()*gain)<0.02) {
lcd.setCursor(0,0);
lcd.print("PANNE CELLULE O2");
opmode=10;
}
Serial.print("CAL,");
Serial.print(cnt);
Serial.print(",");
Serial.print(RA.getAverage()*gain,4);
Serial.print(",");
Serial.println(calibgas);
if (samples==500) {
samples=0;
opmode=2;
lcd.setCursor(0,0);
lcd.print("CALIBR TERMINEE");
lcd.setCursor(0,0);
delay(3000);
relpourc=100*calibgas/RA.getAverage();
lcd.setCursor(0,0);
lcd.print(" ");
lcd.print(" ");
lcd.begin(16, 2);
delay(500);
}
}
// Lecture des échantillons
if (opmode==2) {
lcd.setCursor(0,0);
lcd.print("%O2: ");
pour = RA.getAverage()*relpourc/100;
lcd.print(pour,1);
lcd.print(" ");
lcd.setCursor(0,1);
lcd.print("mV : ");
lcd.print(RA.getAverage()*gain,2);
lcd.print(" ");
lcd.setCursor(10,0);
if (sig1<0.0002) {
lcd.print("====");
} else {
lcd.print(" ");
}
Serial.print("MES,");
Serial.print(cnt);
Serial.print(",");
Serial.print(RA.getAverage()*gain,4);
Serial.print(",");
Serial.println(pour,2);
delay(200);
}
// Calibration manuelle
if ((analogRead(0)>600)&&(analogRead(0)<700)) {
if (opmode<3) {
opmode=3;
samples=0;
lcd.setCursor(0,0);
lcd.print("Calibr. manuelle");
lcd.setCursor(0,1);
lcd.print(" ");
delay(500);
} else {
lcd.setCursor(0,0);
lcd.print(" ");
lcd.setCursor(0,1);
lcd.print(" ");
delay(2000);
lcd.setCursor(0,0);
lcd.print("Cal. auto");
lcd.setCursor(0,1);
lcd.print(" ");
opmode=0;
}
}
if (opmode==3) {
lcd.setCursor(0,1);
lcd.print("%O2 REF: ");
lcd.setCursor(9,1);
lcd.print(calibgas,2);
lcd.print(" ");
if ((analogRead(0)==100)&&(calibgas<99)) {
calibgas=calibgas+1;
delay(100);
}
if ((analogRead(0)==0)&&(calibgas<100)) {
calibgas=calibgas+0.05;
delay(200);
}
if ((analogRead(0)==257)&&(calibgas>1)) {
calibgas=calibgas-1;
delay(100);
}
if ((analogRead(0)==411)&&(calibgas>0.05)) {
calibgas=calibgas-0.05;
delay(200);
}
}
}
mon problème est qu’il me marque toujours panne Cellule avec un tension -0.01mv
Si je modifie la ligne
“float gain = 0.0078125;”
j’arrive a passer le cap de la panne cellule mais derrière j’ai rien donc je me demande si j’ai pas flinguer la carte ads1115 en soudant les broche dessus et de ce fait l’arduino n’aurais pas la valeur de la cellule O2
j’ai aussi tente de changer le branchement de la cellule sur la carte en partant sur A3et A4 en modifiant “adc0 = ads.readADC_Differential_0_1();”
mais rien non plus
comment je peux savoir si la carte est bonne?
si quelqu’un a une idée
merci d’avance
Piccolo