nikouz
Junior Member level 2
Hi all
I have create an air monitoring project. I use a PIC16F18346, BMP280, SCD40 and BH1750. The project is working ok no issues there. I decide to use 2n3904 to switch off the BMP280 and the SCD40 to save energy. I create a circuit for that which is attached in pdf. Now the problem explanation. When i use these circuits separate with the PIC working fine, means that the bjt turns on the measurement is taken and then is turning off. But when i compine these 2 together (BMP280 and SDC40) with the PIC, the program runs normally at the beginning initializing and recognizing both of the sensors but then is getting inside the function to read the BMP280 and never gets a reading and not going further. If in that point i connect the earth straight to the sensor(permanent ON) and restart the PIC, then reading BMP280 normaly and after proceeding to the SCD40 and also reading it successfully.
Because as i said in the beginning the code runs ok i enclose only the functions that been called to make a measurement and the drawing with the 2N3904. Is there any idea about that?
I have create an air monitoring project. I use a PIC16F18346, BMP280, SCD40 and BH1750. The project is working ok no issues there. I decide to use 2n3904 to switch off the BMP280 and the SCD40 to save energy. I create a circuit for that which is attached in pdf. Now the problem explanation. When i use these circuits separate with the PIC working fine, means that the bjt turns on the measurement is taken and then is turning off. But when i compine these 2 together (BMP280 and SDC40) with the PIC, the program runs normally at the beginning initializing and recognizing both of the sensors but then is getting inside the function to read the BMP280 and never gets a reading and not going further. If in that point i connect the earth straight to the sensor(permanent ON) and restart the PIC, then reading BMP280 normaly and after proceeding to the SCD40 and also reading it successfully.
Because as i said in the beginning the code runs ok i enclose only the functions that been called to make a measurement and the drawing with the 2N3904. Is there any idea about that?
Code:
void display_BMP280()
{
BMP_PWR_RC6_SetHigh();
__delay_ms(2000);
if(BMP280_begin(MODE_FORCED, SAMPLING_X1, SAMPLING_X1, FILTER_OFF, STANDBY_0_5) == 0)
{
// connection error or device address wrong!
UART_new_line();
UART_send_string((char*)" BMP280 connection error or device address wrong!");
UART_new_line();
UART_send_string((char*)" Restart device");
}
else {
UART_new_line();
UART_send_string((char*)" BMP280 connected");
}
UART_new_line();
// Read temperature (in hundreds C) and pressure (in Pa)
if(BMP280_ForcedMeasurement())
{
// values from the BMP280 sensor
BMP280_readTemperature(&temperature); // read temperature
BMP280_readPressure(&pressure); // read pressure
// print data on the screen
// 1: print temperature
if(temperature < 0){
memset(BMP_buf, '\0', sizeof(BMP_buf));
Float2Ascii ((float)temperature / 100.0, BMP_buf, 2);
UART_send_string((char*)" Temperature is:");
EUSART_Write('-');
UART_send_string(BMP_buf);
EUSART_Write('C');
UART_new_line();
}
else{
memset(BMP_buf, '\0', sizeof(BMP_buf));
Float2Ascii ((float)temperature / 100.0, BMP_buf, 2);
UART_send_string((char*)" Temperature is:");
UART_send_string(BMP_buf);
EUSART_Write('C');
UART_new_line();
}
// 2: print pressure
memset(BMP_buf, '\0', sizeof(BMP_buf));
Float2Ascii ((float)pressure / 100.0, BMP_buf, 2);
UART_send_string((char*)" Pressure is:");
UART_send_string(BMP_buf);
UART_send_string((char*)" hPa");
UART_new_line();
}
else
{
UART_send_string((char*)" Forced measurement failed!");
UART_new_line();
}
BMP_PWR_RC6_SetLow();
}
Code:
void display_sd4x()
{
SCD4X_PWR_RC5_SetHigh();
__delay_ms(1500);
SCD4x_start_periodic_measurement();
SCD4x_read_measurement();
SCD4x_stop_periodic_measurement();
__delay_ms(100);
SCD4X_PWR_RC5_SetLow();
}