Welcome to EnviroDIY, a community for do-it-yourself environmental science and monitoring. EnviroDIY is part of WikiWatershed, a web toolkit designed to help citizens, conservation practitioners, municipal decision-makers, researchers, educators, and students advance knowledge and stewardship of fresh water. New to EnviroDIY? Start here

Reply To: LSM303 Accelerometer + Compass library integration into ModularSensors

Home Forums Mayfly Data Logger LSM303 Accelerometer + Compass library integration into ModularSensors Reply To: LSM303 Accelerometer + Compass library integration into ModularSensors

#12851
Greg Cutrell
Participant

Thanks Sara! My I2C port is not switched and confirmed that it had 3.3V. I didn’t think about looking into what the begin() function is actually doing. It turns out applying the begin() before every compass object creating did the trick!

As for actually saving the compass data could I create a constructor for a calculated variable where the value for the ‘float (*calcFxn)()’ calls a function that then gets data from the compass? I’m guessing the downside would be I could not do averages and I would just receive one reading per logging interval?

I have not gotten calculated variable method to work for my compass but I think it is because of an error in my code or maybe a bug in ModularLibrary 19.6 I’m working on. Anytime I add the variable pointer to the variable array (like in https://github.com/EnviroDIY/ModularSensors/blob/master/examples/baro_rho_correction/baro_rho_correction.ino) it makes the MayFly reset going through all the initial checks again and setting up sensors ever sampling interval. I might just need to update to the most recent master version 21.1.