ESP8266 ADC电压采集

本例程基于ESP8266 NONOS 2.0 开发

ADC电压采集



os_timer_t LED_timer;				// 软件定时器

void system_done()
{
       os_timer_disarm(&LED_timer);
       os_timer_setfn(&LED_timer, (os_timer_func_t *)ADC_OUTPUT, NULL);
       os_timer_arm(&LED_timer, 1000, 1);
}


void ADC_OUTPUT()
{
       static adc_value = 0;   //ADC值
       adc_value = system_adc_read();  //读取ADC值
       os_printf("adc_value is %d\n", adc_value);  //读取原始ADC
       adc_value = ((adc_value/1024)*3)*300; 
       os_printf("adc_value time is %d\n", adc_value); //修改参数后的ADC
}


main()
{
    //ADC采集电压值
    uint16 vdd33 = 33;
    uint32 flash_r_w[1024];

    spi_flash_read(0x1fc*4096, flash_r_w, 4096);
    flash_r_w[107/4] = flash_r_w[107/4] & !(0xff<<((107%4)*8));
    flash_r_w[107/4] = flash_r_w[107/4] | 33;
    spi_flash_erase_sector(0x1fc);
    spi_flash_write(0x1fc*4096,flash_r_w,4096);

    system_init_done_cb(system_done);
}

 

你可能感兴趣的:(esp8266,nonos,sdk开发)