I2c - wire.h compatability?

When I include this library I can’t connect. I just get this over and over… Anyone else have issues with this specific library?

[16152] Cmd error
[[530] Connecting to devices
[5778] IP: +CIFSR:STAIP,"10.0.2.106"
+CIFSR:STAMAC,"5c:cf:7f:8f:1f:7c"

OK
[5892] Connected to WiFi
[5923] state 0, tconn 0
[11295] Connect success
[11322] <msg 2,1,10
<u95XXXXXXX
[16369] Cmd error
[[529] Connecting to devices
[5947] IP: +CIFSR:STAIP,"10.0.2.106"
+CIFSR:STAMAC,"5c:cf:7f:8f:1f:7c"

OK
[6060] Connected to WiFi
[6091] state 0, tconn 0
[11252] Connect success
[11279] <msg 2,1,10
<u95oXXXXXXX
[16327] Cmd error
[[530] Connecting to devices

Arduino ?

yes, sorry i forget about the Rpi

I have run this sensor with raspberry and I am very happy with measurements that I can gain. I can help for raspberry :frowning: Sorry :frowning:

i appreciate it. ya I saw your sketches on here with it.

Pretty sure its actually the wire.h library… when I call to begin() it haults the arduino…

Hard to troubleshoot without a sketch. Can you share?

Cheers,

Craig

It a revised version of my sensor hub but I keep getting intermittent disconnects. The whole purpose was to move the BMP280 to the main unit rather than the battery powered remote. I’m still trying to trace down what is making it freeze when the wire.h library is called to begin in setup. I’ve tested it on a 32bit sparkfun board, a nano, and a uno…different libraries… all freeze at the same time. very strange. This code below is without the BMP280. The remote code is down below too.

// #include <SoftwareSerial.h>
//
// SoftwareSerial softSerial(2, 3);
// #define CAYENNE_DEBUG SerialUSB
// #define CAYENNE_PRINT SerialUSB

#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
#include <CayenneESP8266Shield.h>
#include <DHT.h>
#include <SimpleTimer.h>


#define DHTPIN 7
#define DHTTYPE DHT22
#define ledBluePin 5
#define ledYellowPin 6

DHT dht(DHTPIN, DHTTYPE);

SimpleTimer timer;

float dataInfo[6];
float far = 0.0;

RF24 radio(9, 10);
const uint64_t pipe = {0xE8E8F0F0E1LL};


char token[] = "";
char ssid[] = "";
char password[] = "";

#define EspSerial Serial
ESP8266 wifi(EspSerial);

float hum1;
float temp1;

float pressurePa;
float pressureIn;
float temperature;
int altimeter;

int m;
int i;
// int timer1;

unsigned long time;
unsigned long time2;
unsigned long onlineTime;
unsigned long prevTime;
byte disco = 0;

void setup()
{
	EspSerial.begin(9600);
	delay(10);

	// SerialUSB.begin(9600);
	pinMode(ledYellowPin, OUTPUT);
	pinMode(ledBluePin, OUTPUT);


	radio.begin();
	radio.setDataRate(RF24_250KBPS);
	radio.openReadingPipe(1, pipe);
	radio.startListening();

	dht.begin();

	Cayenne.begin(token, wifi, ssid, password);

	timer.setInterval(30000, getTemp);
	// timer1 = timer.setInterval(10000, onlineLED);
	// timer.disable(timer1);

}




void loop()
{
	//softSerial.print("loop");
	Cayenne.run();
	// softSerial.println("cayenne - DONE");
	timer.run();
	// softSerial.println("timer - DONE");
	time = millis();

	if ( radio.available() )
		{
			Cayenne.virtualWrite(V0, 1);

			for (i = 0; i < 255; i++)
				{
					analogWrite(ledYellowPin, i);
					delay(2);
				}
			for (i = 255; i > 0; i--)
				{
					analogWrite(ledYellowPin, i);
					delay(2);
				}

			getData();
		}
}


// void onlineLED()
// {
//      for (i = 120; i > 30; i--)
//              {
//                      analogWrite(ledBluePin, i);
//                      delay(3);
//              }
//
//      Cayenne.run();
//      for (i = 30; i < 120; i++)
//              {
//                      analogWrite(ledBluePin, i);
//                      delay(3);
//              }
// }


void getData()
{
	// softSerial.println("getData");
	radio.read(&dataInfo, sizeof(dataInfo));
	time2 = millis();


	digitalWrite(ledYellowPin, 0);

	far = ((dataInfo[0] * 1.8) + 32);

	temperature = dataInfo[4];
	pressureIn = dataInfo[5];

	Cayenne.virtualWrite(V4, dataInfo[3]);
	Cayenne.virtualWrite(V5, dataInfo[2]);
	Cayenne.virtualWrite(V11, dataInfo[2]);
	Cayenne.virtualWrite(V2, dataInfo[1]);
	Cayenne.virtualWrite(V6, far);
	Cayenne.virtualWrite(V12, far);
	Cayenne.virtualWrite(V3, pressureIn);
	Cayenne.virtualWrite(V10, pressureIn);

	Cayenne.virtualWrite(V0, 0);
	// softSerial.println("getData - DONE");
}


void getTemp()
{
	// softSerial.println("getTemp");
	temp1 = dht.readTemperature(true);
	hum1 = dht.readHumidity();


	Cayenne.virtualWrite(V13, temp1);
	Cayenne.virtualWrite(V15, temp1);
	Cayenne.virtualWrite(V14, hum1);
	Cayenne.virtualWrite(V16, hum1);



	// softSerial.println("getTemp - DONE");

}




CAYENNE_CONNECTED()
{
	// softSerial.println("connected");
	prevTime = millis();
	//
	// for (m = 0; m < 120; m++)
	//      {
	//              analogWrite(ledBluePin, m);
	//      }
	// timer.enable(timer1);
	// softSerial.println("connected - DONE");
}

CAYENNE_DISCONNECTED()
{
	// softSerial.println("disconnected");
	prevTime = millis();
	disco++;
	//
	// for (m = 120; m > 0 - 1; m--)
	//      {
	//              analogWrite(ledBluePin, m);
	//      }
	// timer.disable(timer1);
	// softSerial.println("disconnected - DONE");
}

CAYENNE_OUT(V1)
{
	byte transmitTime = ((time - time2) / 1000) / 60;
	Cayenne.virtualWrite(V1, transmitTime);
}

CAYENNE_OUT(V23)
{
	Cayenne.virtualWrite(V23, disco);
}

CAYENNE_OUT(V24)
{
	float time1 = (time / 1000) / 60;
	Cayenne.virtualWrite(V24, time1);
}

CAYENNE_OUT(V25)
{
	onlineTime = ((time - prevTime) / 1000) / 60;
	Cayenne.virtualWrite(V25, onlineTime);
}

And the remote:

#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
#include <SimpleTimer.h>
#include <DHT.h>
#include "Seeed_BMP280.h"
#include <Wire.h>

#define DHTPIN 2
#define DHTTYPE DHT22

BMP280 bmp280;

SimpleTimer timer;

DHT dht(DHTPIN, DHTTYPE);


RF24 radio(9, 10);
const uint64_t pipe = 0xE8E8F0F0E1LL;


float temperatureDHT;
float temperature;

float volts;
float dataInfo[6];
byte motion;
byte hum;
float pressurePa;
float pressureIn;






void setup()
{
	dht.begin();

	radio.begin();
	radio.setDataRate(RF24_250KBPS);
	radio.openWritingPipe(pipe);

	timer.setInterval(300000, getReadings);

	bmp280.init();

	getReadings();
}



void loop()
{
	timer.run();
}




void getReadings()
{
//   radio.powerUp();

	hum = dht.readHumidity();
	delay(50);
	temperatureDHT = dht.readTemperature(true);
	volts = ((analogRead(A2) * (5.0 / 1023.0)) / 0.08933);

	pressurePa = bmp280.getPressure();
	temperature = bmp280.getTemperature();
	pressureIn = pressurePa * 0.000295;

	dataInfo[0] = temperatureDHT;
	dataInfo[1] = hum;
	dataInfo[2] = volts;
	dataInfo[3] = motion;
	dataInfo[4] = temperature;
	dataInfo[5] = pressureIn;


	radio.write(dataInfo, sizeof(dataInfo));
//  Serial.println(temperature);
//  Serial.println(hum);
//  radio.powerDown();
}

as far as my random disconnects, I think it is a issue of speed on the nano. The 32bit runs it pretty smoothly.

Code looks fine to me.

If you are having issues, I’d try and find another BMP driver first.

Cheers,

Craig

Ya tried that. I also discovered it does lock up, after like 20 min it will run. Very strange

Ok, I’m thinking power now. Tell us about how you are powering the remote?

Batteries. I’m beginning to think it’s something wrong with something on my comp… I’ve tried replacing the libraries, I’m on the verge of reinstalling PlatformIO and Arduino IDE.

Did you ever get this working? I’m going through some old tabs and realized I never responded.

not yet. I’m going to try and tackle it later this week. I’ll update what I find… when I find it hopefully lol