Hiiii
I have 4 analog sensors. I have read the analog output of all sensors using Arduino Uno. now I want to write all sensor data using I2C protocol into another microcontroller that also has I2C.
This means I read analog sensor output and write this data into Pixhawk I2C port.
Can anyone guide me on how can I write sensor data into the Pixhawk I2C port and view this data in mission planner?
Thank You…
Can you explain how this code work. ?
i have read analog sensor data on Pin A0, A1,A2, A3
iampete
(Peter Hall)
April 14, 2021, 10:33am
4
If its analog in, you can also read that directly with scripting,
-- there are a few combinations of PWM in that will not work
-- this is due to the way interrupts are handled, AUX 1 and 6 cannot both
-- be PWM at once because they use the same interrupt (on Cubes), this should fail
if not pwm_in_fail:set_pin(55) then -- AUX 6
gcs:send_text(0, "Failed to setup PWM in on pin 55")
end
gpio:pinMode(51,1) -- set AUX 2 to output, gpio:pinMode(51,0) would be input
function update()
gcs:send_text(0, string.format("voltage: %0.2f, PWM: %i, input: ", analog_in:voltage_average(), pwm_in:get_pwm_us()) .. tostring(gpio:read(51)))
-- analog_in:voltage_average() the average voltage since the last call
-- analog_in:voltage_latest() the latest voltage reading
-- analog_in:voltage_average_ratiometric() the average ratiometric voltage (relative to the board 5v)
-- pwm_in:get_pwm_us() the latest pwm value in us
-- pwm_in:get_pwm_avg_us() the average pwm value in us since the last call
-- gpio:read(pin)
-- gpio:write(pin, state)
Sir, Pixhawk AUX4, AUX5, AUX6 i already used for relay ON/OFF