ESP8266 ADC

来自Jack's Lab
(版本间的差异)
跳转到: 导航, 搜索
(以“== Overview == * 10 bit sigmal delta ADC * Internal reference voltage is 1.0 V <br><br> == Example == <source lang=cpp> </source> Output: <source lang=bash> ...”为内容创建页面)
 
(Example)
第9行: 第9行:
  
 
<source lang=cpp>
 
<source lang=cpp>
 +
#include "noduino.h"
  
 +
/*
 +
* A0 --> 220K ---> 100K --> GND
 +
*              |
 +
*              |
 +
*          esp_adc
 +
*/
 +
void setup()
 +
{
 +
        serial_begin(115200);
 +
        wifi_set_opmode(NULL_MODE);
 +
}
 +
 +
void loop() {
 +
 +
  int ad = analogRead(A0);
 +
 +
  serial_printf("ad = %d\r\n", ad);
 +
 +
  float V = (ad / 1024.0) * (220 + 100)/100;
 +
  serial_printf("V*1000 = %d\r\n", (int)(V*1000));
 +
 +
  delay(5000);
 +
}
 
</source>
 
</source>
  

2018年10月28日 (日) 17:01的版本

1 Overview

  • 10 bit sigmal delta ADC
  • Internal reference voltage is 1.0 V



2 Example

#include "noduino.h"

/*
 * A0 --> 220K ---> 100K --> GND
 *              |
 *              |
 *           esp_adc
 */
void setup()
{
        serial_begin(115200);
        wifi_set_opmode(NULL_MODE);
}

void loop() {

  int ad = analogRead(A0);

  serial_printf("ad = %d\r\n", ad);

  float V = (ad / 1024.0) * (220 + 100)/100;
  serial_printf("V*1000 = %d\r\n", (int)(V*1000));

  delay(5000);
}


Output:

ad = 0
V*1000 = 0
ad = 0
V*1000 = 0
ad = 1024
V*1000 = 3200
ad = 1024















个人工具
名字空间

变换
操作
导航
工具箱