-->
Page 1 of 1

SD module and I2C sensor not working at the same time

PostPosted: Fri Feb 17, 2017 6:28 am
by Fasol0
Hello everybody, here is my problem:

I'm using a wemos D1 board and I can't get my IMU sensor (LSM9DS0) connected in I2C (SDA:GPIO4 & SCL:GPIO5) and datalogger shield working at the same time.. both are working fine separately.

Here is the code:
Code: Select all#include <Wire.h>
#include <Adafruit_LSM9DS0.h>
#include <Adafruit_Sensor.h>
#include <SD.h>

Adafruit_LSM9DS0 lsm = Adafruit_LSM9DS0();
const int chipSelect = 4;

void setup()
{
Serial.begin(115200);
 if (!lsm.begin())
  {
    Serial.println("Oops ... unable to initialize the LSM9DS0. Check your wiring!");
    while (1);
  }
  if (!SD.begin(chipSelect)) {
    Serial.println("Card failed, or not present");
    return;
  }

void loop()
{
   lsm.read();
  Serial.println(lsm.magData.z); //doesnt work if SD.begin()
}


I'm using Arduino IDE 1.6.13 and ESP8266 2.3.1

Any help would be appreciated :)

Re: SD module and I2C sensor not working at the same time

PostPosted: Sat Feb 18, 2017 12:13 am
by gdsports
Use a different pin for chip select. Your sketch uses pin 4 for chip select and i2c.

Re: SD module and I2C sensor not working at the same time

PostPosted: Mon Feb 20, 2017 4:06 am
by Fasol0
It works as expected.. didn't noticed SCL/SDA were in D3/D4 aswell :roll:
Thanks :D