hi all. im new here. also comparatively i am a newbie. recently i have tried to add thermocouples to an existing project using an mcp3424. i have bashed and smashed my way through several libraries on git hub and finally got one to work (the one form u chip ) measuring all four channels and printing temperatures correctly. when using the other libraries weird stuff would happen eg. commenting out a serial print line returned crazy results.
another library designed to read all four channels of the mcp3424 was just a fantastic random number generator no matter the configuration.
i figure there must be some low level timing issue that i don't currently have the brain resources to understand or fix.
now though, as i have some code that delivers, when i try to add the bmp180 air pressure module(adafruit libraries)i again get crazy results. for the air pressures i get sub sea pressures and for the temps i get hot coffee temps. neither of which are correct. if i take either sensor away i get coerrect results. the address for the mcp3424 is set to 0x6E and the bmp 180 is 0x77
i tried running the i2c speed test and it found both addresses plus the one for the crypto locker and another mcp3424 that is not being read yet.
by themselves i can get both modules to work perfectly but together, not so.
if i try to run the bmp test code with everytihng connected the output say it cant find a valid sensor however when i disconnect the mcp3424 it springs to life. as i reconnect either the clock or data line the results go mental.
. i am still thinking it is a timing, speed or bit alignment issue- not reading the bit or byte i think i am etc.
hope someone out there with a touch of the clevers can maybe point me in a direction of where to start looking.
cheers
p.s sorry but i cant seem to find the code blocks button mentioned on other posts. to post my code and i tried to cut and paste code but an error came up saying that i couldnt post more than two links (??)
[code]
#include <SoftwareSerial.h>
#include <Picaso_Const4D.h>
#include <Picaso_Serial_4DLib.h>
#include <genieArduino.h>
#include <Arduino_LSM6DS3.h>
#include <Wire.h>
#include <MCP342X.h>
#include <Adafruit_BMP085.h>
#include <idDHTLib.h>
#define rightport 0
#define leftport 1
#define fuelsender 2
int idDHTLibPin = 3; //Digital pin for comunications
unsigned long runtime;
unsigned long deehttimer;
const int smoothsize = 150;
int rightmanraw;
int leftmanraw;
int avmanraw;
int airpressure;
int airtemp;//for pressure
int wetness;
int dewpoint;
int eyretemp;//for cloud stuff
int qnh;
int qfe;
int mslp;
int altitude;
int cloudbase;
int sensedat[400][4];
int twun, ttwo, tthree, tfour;
int i = 0;
int a = 0;
int RC;
int rv[smoothsize];
int lv[smoothsize];
int readindex = 0;
int ltotal = 0;
int rtotal = 0;
int lav;
int rav;
int address=0;
long junkint = 0;
long Voltage[4];//for egt
long timestart;
int form;
bool acknowledge = 0;
bool deebug=0;
//map(Voltage,
idDHTLib DHTLib(idDHTLibPin, idDHTLib::DHT22);
Adafruit_BMP085 bmp;
// Instantiate objects used in this project
MCP342X myADC;
Genie genie;
SoftwareSerial mySerial(8, 9);
void setup() {
Serial.begin(9600);
mySerial.begin(9600);
Wire.begin();
while (!Serial) {
delay(300); //needs notification for no serial
}
Serial.println(myADC.testConnection() ? "MCP342X connection successful" : "MCP342X connection failed");
if (!bmp.begin());
{
Serial.println("Could not find a valid air pressure sensor, check wiring!");//change to genie output
}
myADC.configure( MCP342X_MODE_ONESHOT |
MCP342X_CHANNEL_1 |
MCP342X_SIZE_14BIT |
MCP342X_GAIN_8X);
junkint = (myADC.getConfigRegShdw(), HEX);
runtime = millis();
deehttimer = millis();
}
void loop()
{
Serial.print("in the loop");
{ a++;
MET();
/
TEMPS();
/* genie.WriteObject(GENIE_OBJ_GAUGE,9,rightmanraw);
//leftvalue = analogRead(leftmanraw);
genie.WriteObject(GENIE_OBJ_GAUGE,10,leftmanraw);
genie.WriteObject(GENIE_OBJ_LED_DIGITS,12,airtemp);
genie.WriteStr(0,leftmanraw);
genie.WriteStr(5,rightmanraw);
genie.WriteObject(GENIE_OBJ_LED_DIGITS,11,airpressure);
genie.WriteObject(GENIE_OBJ_LED_DIGITS,13,wetness);
genie.WriteObject(GENIE_OBJ_LED_DIGITS,14,dewpoint);
genie.WriteObject(GENIE_OBJ_LED_DIGITS,15,cloudbase);
genie.WriteObject(GENIE_OBJ_THERMOMETER,0,(eyretemp+5));//+5 is to allow for -5 on thermmeter scale
genie.WriteObject(GENIE_OBJ_LED_DIGITS,16,eyretemp);
genie.WriteObject(GENIE_OBJ_COOL_GAUGE,1,avmanraw);*/
if (a = 473) {
checkstuff();
}
}
}
void MET()
{
if (a = 473) {
checkstuff();
}
airtemp = (bmp.readTemperature());
airpressure = ((bmp.readPressure())/10);
altitude = ((bmp.readAltitude(1013)*3.28084));
mslp = (bmp.readSealevelPressure());
dewpoint = (DHTLib.getDewPoint());
eyretemp = (DHTLib.getCelsius());
wetness = (DHTLib.getHumidity());
a++;
if (deebug=true)
{
Serial.println("in MET now");
Serial.println(airtemp);
Serial.println(airpressure);
Serial.println(altitude);
Serial.println(mslp);
Serial.println(dewpoint);
Serial.println(eyretemp);
Serial.println(wetness);
}
}
void TEMPS()
{
Serial.print("in temps");
{//channel1
myADC.configure( MCP342X_MODE_ONESHOT |
MCP342X_CHANNEL_1 |
MCP342X_SIZE_14BIT |
MCP342X_GAIN_8X);
//Serial.println(myADC.getConfigRegShdw(), HEX);
static int16_t result;
myADC.startConversion();
delay(1);
myADC.getResult(&result);
Serial.print("cahnnel1 :");
Serial.println(((result * 31.25) / 40) + airtemp);
}
{
//channel2
myADC.configure( MCP342X_MODE_ONESHOT |
MCP342X_CHANNEL_2 |
MCP342X_SIZE_14BIT |
MCP342X_GAIN_8X);
//Serial.println(myADC.getConfigRegShdw(), HEX);
static int16_t result;
myADC.startConversion();
delay(1);
myADC.getResult(&result);
Serial.print("cahnnel2 :");
Serial.println(((result * 31.25) / 40) + airtemp);
}
{
//channel3
myADC.configure( MCP342X_MODE_ONESHOT |
MCP342X_CHANNEL_3 |
MCP342X_SIZE_14BIT |
MCP342X_GAIN_8X);
//Serial.println(myADC.getConfigRegShdw(), HEX);
static int16_t result;
myADC.startConversion();
delay(1);
myADC.getResult(&result);
Serial.print("cahnnel3 :");
Serial.println(((result * 31.25) / 40) + airtemp);
}
{
//channel4
myADC.configure( MCP342X_MODE_ONESHOT |
MCP342X_CHANNEL_4 |
MCP342X_SIZE_14BIT |
MCP342X_GAIN_8X);
// Serial.println(myADC.getConfigRegShdw(), HEX);
static int16_t result;
myADC.startConversion();
delay(1);
myADC.getResult(&result);
Serial.print("cahnnel4 :");
Serial.println(((result * 31.25) / 40) + airtemp);
Serial.println();
}
a++;
}
void vibelog ()
{
if (a = 473)
{
checkstuff();
}
//read cycle
for ( RC = 0; RC < 401; RC++)
{
leftmanraw = analogRead(leftport);
{
float X, Y, Z;
if (IMU.accelerationAvailable()) {
IMU.readAcceleration(X, Y, Z);
sensedat[RC][0] = {X};
sensedat[RC][1] = {Y};
sensedat[RC][2] = {leftmanraw};
sensedat[RC][3] = {millis()};
Serial.println(sensedat[RC][0]);
Serial.println(sensedat[RC][1]);
//Serial.println();
//Serial.println(i);
// reset timestart
timestart = millis();
//delay(250);
if (RC >= 400)
writestuff();
}
}
}
a++;
}
void writestuff()
{
if (a = 473)
{
checkstuff;
}
RC = 0;
mySerial.begin(9600);
for (int i = 0; i < 400; i++)
{
Serial.print("writing stuff from inside loop");
//Write to array including micros(optionally manifold vacuum)
//array stuff
Serial1.println();
for (int b = 0; b < 4; b++) {
mySerial.write(sensedat [i] [b]);
mySerial.write(' ');
}
}
}
void checkstuff()
{
//if
}
[/code]