Combining the Internet of Things (IoT) and federated learning (FL) is a trend. In addition to privacy risks, a long-term operating IoT always faces a hierarchical environment, heterogeneous nodes, and occasional communication and node failures. Blockchain-based FL can improve security, reliability, and tractability compared to conventional FL but faces inference, wire-tapping, and Byzantine attacks, besides consensus-based aggregation problems. These security and privacy protection requirements are particularly prominent in some IoT systems, such as IoMT. This study proposes a secure and efficient blockchain-based hierarchical asynchronous FL (S-BHAFL) for IoT. S-BHAFL treats the smart devices under a gateway as a group and weights them on dataset size. In each group, the gateways use mask differential privacy (DP) to prevent wire-tapping and inference attacks while ensuring zero noise to the global model compared to conventional DP-based schemes. Less noise means more accurate models, fewer iterations, and lower energy consumption. Among the groups, S-BHAFL proposed a novel consensus-based aggregation mechanism with a global testing dataset to resist Byzantine attacks. The normalized dynamic factors reduce the impact of simple weighting on model accuracy. Furthermore, theoretical analysis and experimental results on the S-BHAFL compared with state-of-the-art schemes demonstrate convergence, security, effectiveness, and robustness of SBHAFL. The experiment on datasets MNIST, Fashion-MNIST, CIFAR10, and a real-world Heart Disease dataset shows improvements in accuracy by 0.70%-2.71%, in convergence speed by 8.69%-61.29%. S-BHAFL significantly improved the training efficiency and accuracy and maintained the security. © 2013 IEEE.