# Voxl2 analog sensor interface

Source: https://forum.modalai.com/topic/2756/voxl2-analog-sensor-interface
Category: General Questions (https://forum.modalai.com/category/2/general-questions)
Posted: 2023-10-19 09:22:15 UTC by tiralonghipol
Replies: 7 · Views: 1308

## tiralonghipol · 2023-10-19 09:22:15 UTC

Hi,
I do not see an ADC or similar pin on the Voxl2 to read an analog signal coming from a [flex sensor](https://www.digikey.no/no/products/detail/spectra-symbol/FS-L-055-253-ST/17050937?utm_adgroup=&utm_source=google&utm_medium=cpc&utm_campaign=PMAX%20Shopping_Product_Low%20Performers&utm_term=&productid=17050937&utm_content=&utm_id=go_cmp-19562419088_adg-_ad-__dev-c_ext-_prd-17050937_sig-CjwKCAjwp8OpBhAFEiwAG7NaEgPpjKXZv0Exk6_kLsPPYELA9LDD6CpciMHxLWrO5a3IXZB3M8YxJxoCyGsQAvD_BwE&gad=1&gclid=CjwKCAjwp8OpBhAFEiwAG7NaEgPpjKXZv0Exk6_kLsPPYELA9LDD6CpciMHxLWrO5a3IXZB3M8YxJxoCyGsQAvD_BwE)
is there any other way to achieve this? maybe the gpio pins on J19 ?

thank you!

## Reply by Moderator (ModalAI staff) · 2023-10-19 14:20:33 UTC

@tiralonghipol Correct, there is not an ADC input on VOXL 2

## Reply by tiralonghipol · 2023-10-23 10:19:15 UTC (in reply to Moderator)

@Moderator awesome!
I saw in the px4 drivers that the module i'm trying to read (ADS1115) is [already supported](https://github.com/PX4/PX4-Autopilot/tree/main/src/drivers/adc/ads1115)
what I plan to do, since I am not using pin 4 and 5 on J19 (sda,scl) is to read the adc instead of the gps.

now the problem is that when I plug the [ADC breakout board](https://www.elfadistrelec.no/en/ads1115-16-bit-adc-board-adafruit-1085/p/30091131?ext_cid=shgooaqnono-Shopping-PerformanceMax-CSS&cq_src=google_ads&cq_cmp=20351270785&cq_con=&cq_term=&cq_med=pla&cq_plac=&cq_net=x&cq_pos=&cq_plt=gp&gclid=CjwKCAjws9ipBhB1EiwAccEi1ObAGQ_IAEyCsimB4DLOnzMnHZ6eHYMiqk21XvcVrDHC0U82HezmHRoCHlUQAvD_BwE&gclsrc=aw.ds)

and i 
```
voxl2:/$ i2cdetect -r -y 0
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- -- -- -- -- -- -- -- -- 
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
70: -- -- -- -- -- -- -- --  
```
there is nothing on i2c-0.
actually there is no register detected on 0,1,2 (3 should not be used)

what am I doing wrong?

the physical connection is [J19 <-> adc board]:
pin 1 (5V) <->  Vin
pin 4 (SCL) <->  scl
pin 5 (SDA) <->  sda
pin 12 (GND) <->  gnd

## Reply by tiralonghipol · 2023-10-24 07:01:35 UTC (in reply to tiralonghipol)

@Moderator 
Solved using the J5 connector instead!

## Reply by tiralonghipol · 2023-10-24 09:01:44 UTC (in reply to Moderator)

@Moderator 
so I am able to correctly read 2 flex sensors using a python library.

But is it possible to achieve the same via the px4 driver itself? if yes, where should I look into?
should I rebuild the voxl-px4 image enabling the ads1115 driver?
I believe it is disabled by default, if I understood correctly

just to give some context:
let's say the arms of my quad are able to passively flex and I read the 4 deflection angles via this ADC.
the ultimate goal I am trying to achieve is to send this analog information to the control actuator matrix and adapt it real time, taking into account the deflection

Any help is highly appreciated thanks

## Reply by Eric Katzfey (ModalAI staff) · 2023-10-24 15:54:48 UTC (in reply to tiralonghipol)

@tiralonghipol That driver is not built or included in the px4 dsp build. So you would need to add that and then add it's start command to the /usr/bin/voxl-px4-start script file. You would need to specify `-b 4` as an option to that start command to choose the proper bus.

## Reply by tiralonghipol · 2023-10-24 19:55:52 UTC (in reply to Eric Katzfey)

@Eric-Katzfey thank you Eric!
I figured out during our time-zone difference!
I was actually able to use the pins reserved for the mag
so I built the docker, added the driver, modified the start on the correct bus but now I am unsure: where are these values published? lol

```
========== Starting ads1115 ADC ===========
INFO  [qshell] Send cmd: 'ads1115 start -X -b 1'
INFO  [muorb] SLPI: Marking DeviceNode(qshell_req) as advertised in process_remote_topic
INFO  [muorb] SLPI: qshell gotten: ads1115 start -X -b 1
INFO  [muorb] SLPI:   arg0 = 'ads1115'

INFO  [muorb] SLPI:   arg1 = 'start'

INFO  [muorb] SLPI:   arg2 = '-X'

INFO  [muorb] SLPI:   arg3 = '-b'

INFO  [muorb] SLPI:   arg4 = '1'

INFO  [muorb] SLPI: *** I2C Device ID 0x904809 9455625
INFO  [muorb] SLPI: ads1115 #0 on I2C bus 1
INFO  [muorb] SLPI:  (external)
INFO  [muorb] SLPI:  address 0x48
INFO  [muorb] SLPI: 

INFO  [muorb] SLPI: Ok executing command: ads1115 start -X -b 1
INFO  [qshell] qshell return value timestamp: 791748467, local time: 791750038
INFO  [uORB] Advertising remote topic sensor_baro
INFO  [qshell] Send cmd: 'sensors start'
INFO  [muorb] SLPI: Marking DeviceNode(qshell_req) as advertised in process_remote_topic
INFO  [muorb] SLPI: qshell gotten: sensors start
INFO  [muorb] SLPI:   arg0 = 'sensors'

INFO  [muorb] SLPI:   arg1 = 'start'

```

could be this one?
```
INFO  [uORB] Advertising remote topic adc_report
```

## Reply by Eric Katzfey (ModalAI staff) · 2023-10-25 15:55:42 UTC (in reply to tiralonghipol)

@tiralonghipol I have never used that sensor but from the code it looks like adc_report is indeed the data it is publishing.
