Microgrids in smart grid development create a new era towards resilient energy supply. In turn, They also render complicated cyber-physical system development towards high scalability and comprehensiveness. Heterogeneous Small Cell based Networks (HSCNs) endow a suitable cyber infrastructure for microgrid based cyber-physical systems. To tackle this emerging research area, this paper proposes a Spatiotemporal Device-to-device communication based HSCN Deployment scheme for Microgrid based Smart grid Development (3xSD), to achieve high energy efficiency with high qualityof-service, chronically and dynamically. Concretely, a joint optimization for long-term energy efficiency and achievable data rate maximization with interference mitigation is formulated for spatial small cell positioning, which models both cyber and physical characteristics of Smart Grid User Equipment (SGUE). A Temporal On-demand Small cell Powering and work-Offloading scheme (TOSPO) is proposed on top of the determined small cell positioning. TOSPO considers the real-time heterogeneous features and demands of SGUEs to maximize energy and cost efficiency, for both communication and computation perspectives. To evaluate the performance of 3xSD, spatial analysis, temporal analysis, and selected case study are simulated. Numerical results showcase that 3xSD is capable of providing both long-term and on-demand optimal energy efficiency and quality-of-service solution for microgrids, outperforming existing benchmarks in the literature.INDEX TERMS Small cells, smart grid, on-demand, energy efficiency, cyber-physical systems.