After an introduction of cognitive radio (CR) technology in communication, the hot research topics are sensing, Primary User Interference (PUI), spectrum management, security, spectrum sharing, and environmental sensing. Among the listed, sensing and Primary User Interference are the bold ones. The base query for these two problems lays finding a means for which and what channel at a particular time is available and avoiding interference with Primary Users (PU). This article presents a novel cognitive radio algorithm called SenPUI for both mentioned main challenges, sensing and PUI. First, energy scan during the inactive portion of communication which is dynamic is done. Second, application packet based primary user identification for PUI avoidance is proposed as base solution. Both techniques described in this work are implemented and resulted in a significant reduction of the target problems estimated around 10-30% reduction in average. Main limitations of Wireless Sensor Network (WSN) such as memory, battery lifetime, and size are considered during the design and implementation of our solutions.