New sensor adding code

I want to add my own sensor code to the PX4 firmware for sending the data Qgroundcontrol(QGC), can I get some directions or resources for implementing this?

The easiest and crudest method is to use your own sensor data to replace some messages that have been displayed in QGC (for example: accelerometer data). A reasonable method is to create a new mavlink message and use this message to pass sensor data to qgc

Can you please suggest me some references to look at for creating a new mavlink message and the other dependencies to handle to collect sensor data in PX4 and pass data to qgc? Really appreciate your help

What sort of sensor is it? Maybe we can find an existing message that can be used for your case.

Is there a way to know what data is being recorded on the Pixhawk (or really just within the PX4 stack when running on any hardware) - I want to know if information related to power use is 1) saved, 2) sent back to the ground and/or 3) measured, in that maybe the system has access to this power use data, but doesn’t send it back to the ground?