4845 views|7 replies

1131

Posts

17

Resources
The OP
 

[Raspberry Pi Pico Review] - AD acquisition example and serial communication [Copy link]

 
This post was last edited by fxyc87 on 2021-2-4 13:37

There are already very detailed examples in the official documentation about AD collection.

Moderator dcexpert also posted this thread [RPi PICO] Reading the internal temperature sensor

I'm playing here too.

First of all, according to the official manual, AD has 5 channels, of which 4 channels 0-3 are external, and channel 4 is the internal chip temperature.

See the code for the conversion method and the figure for details:

Figure 1, AD parameters:

Figure 2, official example

Figure 3, Figure 4, Pin Links

Figure 5 shows the internal temperature of the chip. It is actually almost the same as the ambient temperature, about 10 degrees Celsius. When I press my hand on it, it rises to over 12 degrees in 5 seconds.

You can also use Thonny software to display curves. Just tick the curve in the view, see the picture

Thonny curves can also display multiple lines, separated by spaces when printing, as shown below

The above curves seem too simple. Let's use a professional curve tool called Serial Studio.

GIT and download address can be found here:

https://github.com/Serial-Studio/Serial-Studio/blob/master/README_ZH.md

https://github.com/Serial-Studio/Serial-Studio/releases/download/v1.0.13/SerialStudio-1.0.13-Windows.exe

If you want to use external curve display, you need to use the Uart module.

The print statement used in the above figure cannot output data through an external PIN, it can only be displayed in the Thonny environment

import machine
import utime

from machine import UART
from machine import Pin
#分配串口编号及波特率和引脚

uart = UART(0,baudrate=9600,bits=8,parity=None,stop=1,tx=Pin(0),rx=Pin(1))


sensor_temp = machine.ADC(4)
ad0=machine.ADC(0)
ad1=machine.ADC(1)
ad2=machine.ADC(2)

conversion_factor = 3.3 / (65535)
while True:
    reading = sensor_temp.read_u16() * conversion_factor
    temperature = 27 - (reading - 0.706)/0.001721
    print(temperature,ad0.read_u16(),ad1.read_u16(),ad2.read_u16())

    uart.write("/*temp,%3.2f,%4d*/"%(temperature,ad0.read_u16()))
    utime.sleep(1)

You can use uart.write to output serial port data to the outside

Post a curve chart

The Serial Studio software needs to be configured using JSON. It can be configured as a curve graph, a meter graph, etc. I'm not very good at using it yet.

{
   "t":"RT2040",
   "g":[
      {
         "t":"AD曲线测试",
		 "w":"map",
         "d":[
            {
               "t":"%1",
               "v":"%2",
               "u":"℃",
			   "g":true
            }
         ]
      },
      {
         "t":"通道1-测试空",
         "d":[
            {
               "t":"曲线",
               "v":"%3",
			   "g":true,
			   "u":"*"
            }
         ]
      }
   ]
}

Here is another hardware link diagram:

Latest reply

Very good, it is quite detailed, I like it.   Details Published on 2021-2-5 11:51

赞赏

1

查看全部赞赏

 
 

1942

Posts

2

Resources
2
 

Great, everyone has a board to play with! I have to apply for one.

 
 
 

5791

Posts

44

Resources
3
 

Not bad, not bad, very fun, take some time to play with it

Personal signature

射频【放大器】

 
 
 

1w

Posts

25

Resources
4
 

Thonny is getting more and more powerful.

 
 
 

1412

Posts

3

Resources
5
 

Awesome!

Personal signature

没有什么不可以,我就是我,不一样的烟火! 

 
 
 

1237

Posts

66

Resources
6
 

This data display software is good, where can I download it?

Comments

There are links in the article. The software name is Serial Studio GIT and the download address can be found here: https://github.com/Serial-Studio/Serial-Studio/blob/master/README_ZH.md https://github.com/Serial-Studio/Serial-Studio/re  Details Published on 2021-2-5 12:09
 
 
 

2948

Posts

0

Resources
7
 

Very good, it is quite detailed, I like it.

 
 
 

1131

Posts

17

Resources
8
 
dql2016 posted on 2021-2-5 09:34 This data display software is good, where can I download it?

There are links in the article.

The software is called Serial Studio

GIT and download address can be found here:

https://github.com/Serial-Studio/Serial-Studio/blob/master/README_ZH.md

https://github.com/Serial-Studio/Serial-Studio/releases/download/v1.0.13/SerialStudio-1.0.13-Windows.exe

 
 
 

Guess Your Favourite
Just looking around
Find a datasheet?

EEWorld Datasheet Technical Support

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号
快速回复 返回顶部 Return list