In machine-to-machine (M2M) communication, smart spectrum management is vital for the system performance since there are a large number of wireless devices sharing the same limited spectrum and the spectrum resource is scarce. For the spectrum sharing, it's not only encountered in ISM band, but also in the networks with dedicated spectrums when the network is under evolution or upgrading, such as the system updating from narrow-band to broadband in SmartGrid communications. In this paper, we summarize the typical methods in wireless cellular network to improve the spectrum utilization and compare their advantages and limitations as applied to M2M communications. Based on the analysis, we propose a novel mechanism for dynamic spectrum allocation in a cognitive radio environment for SmartGrid applications using OFDMA technology and give some evaluations based on field test data. The spectrum allocation we proposed can be divided into two stages: network entry stage based on initial sensing and dynamic interference avoidance stage based on periodical sensing. At the network entry stage, we focus the discussion on the design of optimal spectrum auto planning algorithm and provide a new scheme based on backup list generation and internal/external interference differentiation. After the OFDMA based system enters into normal communication stage, interference avoidance within the allocated spectrum band is the main task of the M2M system. The in-band spectrum will be segmented into several sub-bands and be scheduled by the system based on periodical spectrum sensing results to avoid interferences coming from external devices(SCADA or unknown system) which share the same spectrum with the current system. The spectrum allocation mechanism we proposed has been used in IBM Wireless Internet-of-Thing (IoT) platform and achieved good performance during the field test. © 2012 IEEE.