in my project we need to send two kind of sensor data via arduino to PX2 and forward to PC, which is connected with another arduino. And currenctly I have a lot of things that I need to ask about.
One of the sensor’s output will only be 0 or 1, will there be a simplier way to send it than to build a driver for this sensor.
The second one is smoke sensor, I wonder if there will be some kind of faster solutions too for that too?
And what do you think about the current method that need two arduinos?
Thank you for this! Sorry for my poor skill and knowledge in pixhawk and mavlink, I need to confirm with few things:
So this AP_button code can be used to build message via Pixhawk’s serial port connection? I mean by requesting data from sensor <-> arduino <-> PX connection to the arduino connected to ground control?
If it is possible, I assume the Telem1/Telem2 can be set as pins?
no worries. The button library just sends a mavlink message when the pin it is connected to changes state (toggles from high to low or low to high) - for that sensor, you don’t need the arduino, just connect it to an Aux pin on the Pixhawk, and set the button parameters for that pin (https://ardupilot.org/copter/docs/parameters.html#btn-enable-enable-button-reporting). That will get the data to the groundstation, where you can do whatever you need to with it.
The gas sensor you linked has two options: either an analog voltage (link says 0-5V), or a digital pin - which is binary on/off, based on a manually set threshold (trimpot). If you just need a binary result, you could set it up as a button, same as above. If you need to read the analog value, the easiest thing to do is pretend it is RSSI, and follow the guide for analog RSSI (https://ardupilot.org/copter/docs/common-rssi-received-signal-strength-indication.html?highlight=rssi#analog-voltage-type-rssi-fed-to-a-dedicated-pin). This will again get your data logged and sent down over mavlink, for you to handle how you need to.
Good to know, thank you for telling me this. When I tried to include the AP_Button, there have shown different warnings related to other h. and cpp. files that the AP_button included, I assume some of them are because I am using Arduino.
Do you know if there is a safe way to “cut” some of the other files?
Oh I see. So this ap_button data can be viewed in ground station (for example mission planner)? But shouldn’t I use the codes from the first link to set the output.
and if I want to send the out put digital data forward, I just need to follow the driver codes that are already in Mission planner?