damiaa 发表于 2021-2-10 11:32

【测评SGP40】+UART通信测试传感器

本帖最后由 damiaa 于 2021-2-10 12:07 编辑

<p>【测评SGP40】+UART通信测试传感器</p>

<p>1), SEK-SVM40支持I2C和UART通信。Sensirion_Gas_Sensors_SEK-SVM40_Technical_Description_D1手册里有详细的介绍。</p>

<p></p>

<p>硬件接口连线如下:</p>

<p>1,2电源电压,3,4,I2C和uart共享,5选择I2C 还是uart&nbsp; 接GND为i2C,悬空或者接VCC为uart。</p>

<p>&nbsp;</p>

<p>2),有一些代码,有支持arduino的,有嵌入式的。但arduino的好像用到了serial1,因为stm32的板子跑arduino 不知道怎么整除serial1。因此作罢。</p>

<p>就用at32F407的uart口吧。也很好的。下篇里面仔细介绍。现在先把uart的通信搞明白。</p>

<p>Sensirion_Gas_Sensors_SEK-SVM40_UART_Interface_Description_D1手册对串口通信说得很明白。</p>

<p></p>

<p>3),根据Sensirion_Gas_Sensors_SEK-SVM40_UART_Interface_Description_D1介绍,物理层通信串口通信参数uart 115200 n,8,1。&nbsp;</p>

<p>&nbsp;SHDLC Frame Layer层采用一套简易的SHDLC包裹I2C的MISO MOSI。</p>

<p>4),具体实现看UART Commands</p>

<p>有13个命令。 按资料介绍。只要把串口接好。发送命令就会有回传结果。</p>

<p></p>

<p></p>

<p>5),下面准备一个uart-ttl的工具,这里采用ch340.&nbsp; &nbsp;</p>

<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 准备串口通信助手&nbsp; &nbsp;&nbsp; <span style="color:#009900;"><strong>也可以直接用官方的哪个uart-ttl +串口通信助手</strong></span></p>

<p>&nbsp; &nbsp; &nbsp; 连接svm40到uart-ttl 注意 VCC GDD TX&nbsp;RX 四根,svm40的TX接uart-ttl RX&nbsp; svm40的RX接uart-ttl TX !</p>

<p>&nbsp;&nbsp;</p>

<p></p>

<p>接好后插到电脑</p>

<p>查看一下串口</p>

<p>打开串口调试助手 设置串口通信参数&nbsp;115200 n,8,1</p>

<p>把命令都加进去。打开串口,就可以实验了。</p>

<p>6,通信时发现有些命令是关联的,比如,如果模块处于复位状态。或者按svm40_device_reset后</p>

<p>&nbsp; &nbsp; &nbsp; svm40_get_signals读命令就不能正确执行。要先发送启动测量命令svm40_start_measurement</p>

<p></p>

<p>7,具体数据分析。</p>

<p>1,svm40_start_measurement 开启测量</p>

<p>2,svm40_get_signals&nbsp;</p>

<p>3,svm40_get_raw_signals</p>

<p>4,svm40_stop_measurement&nbsp; 关闭测量</p>

<p>5,svm40_get_temperature_offset</p>

<p>6,svm40_set_temperature_offset</p>

<p>7,svm40_get_voc_parameters</p>

<p>8,svm40_set_voc_parameters</p>

<p>9,svm40_store_input_parameters</p>

<p>10,svm40_get_voc_states</p>

<p>11,svm40_set_voc_states</p>

<p>12,svm40_get_version&nbsp;&nbsp;版本号获取</p>

<p>13,svm40_device_reset&nbsp;模块复位</p>

<p>13个命令里面除了6,8,11命令带参数外,其他都是固定一个命令,资料里有说,看MOSI Data &nbsp;Byte number &nbsp;Description<br />
因此实验是很方便的,直接送手册里面数据就OK,6,8,11倒是要计算一下。</p>

<p>1,4,是开启关闭测量,12,版本号获取,13,模块复位。</p>

<p>2,获得测量值。</p>

<p>3,svm40_get_raw_signals</p>

<p>0, 1 &nbsp;int16 provides the VOC Index (no unit) with a scaling factor of 10, e.g., an output of +250<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;corresponds to a VOC Index of +25.0.<br />
&nbsp;2, 3 &nbsp;int16 provides the relative humidity (in % RH) compensated for the temperature offset with a<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;scaling factor of 100, e.g., an output of +2&rsquo;500 corresponds to +25.00 % RH.<br />
&nbsp;4, 5 &nbsp;int16 provides the temperature (in &deg;C) with a scaling factor of 200, e.g., an output of +5&rsquo;000<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;corresponds to +25.00 &deg;C.</p>

<p>命令&nbsp; 7E 00 03 01 0A F1 7E</p>

<p>应答&nbsp;&nbsp;7E 00 03 00 06 <span style="color:#009933;"><strong>00 00 20 1C 09 81</strong></span> 30 7E&nbsp;</p>

<p>VOC&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;0000&nbsp; &nbsp; &nbsp; &nbsp; ==&gt;&nbsp; &nbsp; &nbsp;0</p>

<p>RH&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 201C&nbsp; &nbsp; &nbsp; &nbsp;==&gt;&nbsp; &nbsp; &nbsp;8220&nbsp; &nbsp;82.20%</p>

<p>TEMPERATURE&nbsp; 0981&nbsp; &nbsp; &nbsp; &nbsp; ==&gt;&nbsp; &nbsp; &nbsp;2433&nbsp; &nbsp;12.165&deg;C</p>

<p>再用官方的串口工具和官方uart-ttl读一下比较</p>

<p></p>

<p>数值是81.09%&nbsp; &nbsp;12.275&deg;C&nbsp; &nbsp;因为温湿度是动态变化的,所以值是对得上的。数值是0</p>

<p>5,svm40_get_temperature_offset</p>

<p>6,svm40_set_temperature_offset</p>

<p>7,svm40_get_voc_parameters</p>

<p>8,svm40_set_voc_parameters</p>

<p>9,svm40_store_input_parameters</p>

<p>10,svm40_get_voc_states</p>

<p>11,svm40_set_voc_states</p>

<p>准备了一块板子,串口调试好了,下一步准备把模块加上试试。</p>

<p></p>

qwqwqw2088 发表于 2021-2-28 11:47

<p>测试描述的很清楚</p>

<p>顶起</p>
页: [1]
查看完整版本: 【测评SGP40】+UART通信测试传感器