Write BME280 Sensor data into sdcard and send to the another Adafruit

Hi,

I am using Adafruit Feather 32u4 Lora for getting BME280 sensor data and write the data into a sd card using MicroSd card adaptor and then send the data to another Adafruit client.Here I am using serial pin for connection with Sdcard Adaptor.

But with the serial connection with SdCard Adaptor, rf95.init() is failed every time. But when i remove the connection with the sdcard adaptor, rf95.init() works fine.Can anyone help me to solve this issue?

Here is the code i am using .....

#include <avr/sleep.h>
#include <avr/wdt.h>
#include <Wire.h>
#include <RH_RF95.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_BME280.h>
#include <SD.h>

Adafruit_BME280 bme;
#define RF95_FREQ 868.0
#define RFM95_CS 8
#define RFM95_RST 4
#define RFM95_INT 7

File myFile;
// Singleton instance of the radio driver
RH_RF95 rf95(RFM95_CS, RFM95_INT);

float t=0,h=0;

void setup()
{
Serial.begin(9600);
while(!Serial){}
Serial.println("After While");
pinMode(RFM95_RST, OUTPUT);
digitalWrite(RFM95_RST, HIGH);
digitalWrite(RFM95_RST, LOW);
delay(10);
digitalWrite(RFM95_RST, HIGH);
delay(10);

while (!rf95.init()) {
Serial.println("In init");
while (1);
}
Serial.println("rf95 init is done");

// Defaults after init are 434.0MHz, modulation GFSK_Rb250Fd250, +13dbM
if (!rf95.setFrequency(RF95_FREQ)) {
Serial.println("In rf95");
while (1);
}
Serial.println("setFrequency is done");
rf95.setTxPower(23, false);
rf95.setPromiscuous(true);
Serial.print("Initializing SD card...");

if (!SD.begin(6)) {
Serial.println("initialization failed!");
while (1);
}
Serial.println("initialization done.");

bool status;

// default settings
// (you can also pass in a Wire library object like &Wire2)
status = bme.begin();
if (!status) {
Serial.println("Could not find a valid BME280 sensor, check wiring!");
while (1);
}

}

void loop(){
t=bme.readTemperature(); //read temperature bme280
delay(50);
Serial.print("temperature is :");
Serial.println(t);
h=bme.readHumidity(); //read humidity bme280
delay(50);
Serial.print("Humidity is :");
Serial.println(h);
myFile = SD.open("test.txt", FILE_WRITE);
if(myFile){

myFile.print("Temperature is :");
myFile.print(t);
myFile.print(" and humidity : ");
myFile.println(t);
myFile.println("\n");
myFile.close();
}
else{
Serial.println("error opening document");
}

delay(2000);
}

Hi,
Welcome to the forum.

Please read the first post in any forum entitled how to use this forum.
http://forum.arduino.cc/index.php/topic,148850.0.html then look down to item #7 about how to post your code.
It will be formatted in a scrolling window that makes it easier to read.

Can you please post a copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg, png?

Thanks.. Tom... :slight_smile:

Hi Tom,

I have attached the hand drawn circuits .Here i am using the arduino uno board to give 5 V power to the microsd card adaptor and I have connected GY BME NE/P 280 sensor to the Adafruit 32u4 LORA Sensor using I2C connection and all the ground's are sorted.