The official pyboard running MicroPython.
This is the reference design and main target board for MicroPython.
You can buy one at the store.
Target audience: Users with a pyboard.
starter111
Posts: 40
Joined: Wed Mar 08, 2017 7:24 am

Hi, I'm trying to use pyboard measure negative voltage. Is it a way to do so? I can add circuit if needed it.

starter111
Posts: 40
Joined: Wed Mar 08, 2017 7:24 am

### Re: ADC measure negative voltage??

never mind, looks like just need add two resistors for voltage divider.

jimmo
Posts: 2072
Joined: Tue Aug 08, 2017 1:57 am
Location: Sydney, Australia
Contact:

### Re: ADC measure negative voltage??

A voltage divider can only be used to scale a voltage down. i.e. you cannot change its polarity.

Negative voltages (i.e. below your microcontroller's ground) could damage the microcontroller.

Can you describe what you're doing in more detail and we can give you some hints.

Roberthh
Posts: 2282
Joined: Sat May 09, 2015 4:13 pm
Location: Rhineland, Europe

### Re: ADC measure negative voltage??

Depending on the range of the negative voltage and it's impedance, a voltage divider may work, just between Vdd-ADC_Input-Sensing_Input instead of GND-ADC_Input-Sensing_Input. Don't forget to add a protective Diode to the input, so it cuts off negative voltages.

chrismas9
Posts: 149
Joined: Wed Jun 25, 2014 10:07 am

### Re: ADC measure negative voltage??

I have used the method suggested by @roberthh. Here's how it works. Say you want to measure down to -12V.

Make a 5:1 voltage divider, eg 10k and 40k. Connect 10k between Aref (3V3) and ADC input. Connect 40k from ADC input to negative voltage.

When Vin = 0V ADCin = 3.3 - (3.3 + 0)/5 = 2.44V.

When Vin = -12V ADCin = 3.3 - (3.3 + 12)/5 = 0.24V.

starter111
Posts: 40
Joined: Wed Mar 08, 2017 7:24 am

### Re: ADC measure negative voltage??

I have two 100k resistors.
r1.pin1 connect to 6v.
r2.pin2 connect to somewhere close to -3v(voltage going to measure).

so negative voltage = r1.pin2 v - (6v - r1.pin2 v)

jimmo
Posts: 2072
Joined: Tue Aug 08, 2017 1:57 am
Location: Sydney, Australia
Contact:

### Re: ADC measure negative voltage??

starter111 wrote:
Tue Jun 25, 2019 8:36 pm
so negative voltage = r1.pin2 v - (6v - r1.pin2 v)
Intuitively, with two 100k resistors, your ADC pin will be at the midpoint (i.e. the mean) between 6V and the voltage you're measuring.

So when the voltage is -3V, then you have 9V across the divider and so 4.5V across each resistor. So now your ADC is at 4.5V below 6V.

But yeah, don't forget the clamping diodes if you think that the input can go below -6V (or above 4V).

This is all assuming your negative voltage is referenced to the same ground etc.

chrismas9
Posts: 149
Joined: Wed Jun 25, 2014 10:07 am

### Re: ADC measure negative voltage??

I think there is a typo in your formula. With 100k resistors you will need a small cap on the ADC input as switched cap ADCs will draw transient current spikes from the inputs.

You don't say what MCU you are using but some STM32 ADC pins are completely intolerant of voltages outside supply and GND so use a Schottky diode pair like BAT54S to clamp to Vss and CDs.

starter111
Posts: 40
Joined: Wed Mar 08, 2017 7:24 am
{"ft_lang_label":"__label__en","ft_lang_prob":0.867031,"math_prob":0.6890882,"size":3888,"snap":"2021-04-2021-17","text_gpt3_token_len":1142,"char_repetition_ratio":0.17687951,"word_repetition_ratio":0.50499284,"special_character_ratio":0.2973251,"punctuation_ratio":0.17762399,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.9528527,"pos_list":[0],"im_url_duplicate_count":[null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2021-01-21T20:50:31Z\",\"WARC-Record-ID\":\"<urn:uuid:12933805-aa95-495d-be32-aebcc864d9d5>\",\"Content-Length\":\"49471\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:c5a4dec1-369f-49da-bb92-de73862bb279>\",\"WARC-Concurrent-To\":\"<urn:uuid:98cb3a60-149d-4d28-8801-a906de44ff14>\",\"WARC-IP-Address\":\"176.58.119.26\",\"WARC-Target-URI\":\"https://forum.micropython.org/viewtopic.php?f=6&t=6617\",\"WARC-Payload-Digest\":\"sha1:22HXTJ6SA5TILNNO4CC3QXD675ABLBFN\",\"WARC-Block-Digest\":\"sha1:3XQT3QLR7FIWJBR3NAMQIGMHVVC5H4LI\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2021/CC-MAIN-2021-04/CC-MAIN-2021-04_segments_1610703527850.55_warc_CC-MAIN-20210121194330-20210121224330-00087.warc.gz\"}"}