SD card shield (from hobby components) not working when tying arduino ground

Hi everyone,

I am trying to write sensor readings (MQ-135 gas and SDS011 particle) on SD card. The attached code works when Arduino ground is not connected to the power supply ground, but as soon as I connect them, Arduino stops communicating with the Serial Monitor and displays nothing.

Is the SD shield faulty or there is something wrong with the code.

The assembly contains one MQ-135, SDS011, a touch button conditioning readings from SD011, a switch for MQ-135 power supply and a switch for the fan of SDS011.

I have attached the code.

Any advice on this is welcomed.

mq_135_and_sds011_with_data_schield.ino (2.4 KB)

Please post your schematic. A photo of a hand drawn circuit is adequate

Thanks for your reply. The problem has been sorted. The HRTC library was creating problems.