ESP201 dev board - One more finding #2.



Perfect ! The last piece of puzzle was found. How to control the relay on the ESP201 development board.

The on board relay is connected to DIP J, and to GPIO16. In order to trigger GPIO16 you need the function from gpio16.c from IoT Demo.


#include "ets_sys.h"#include "osapi.h"#include "driver/gpio16.h"
void ICACHE_FLASH_ATTRgpio16_output_conf(void){    WRITE_PERI_REG(PAD_XPD_DCDC_CONF,                   (READ_PERI_REG(PAD_XPD_DCDC_CONF) & 0xffffffbc) | (uint32)0x1); // mux configuration for XPD_DCDC to output rtc_gpio0
    WRITE_PERI_REG(RTC_GPIO_CONF,                   (READ_PERI_REG(RTC_GPIO_CONF) & (uint32)0xfffffffe) | (uint32)0x0); //mux configuration for out enable
    WRITE_PERI_REG(RTC_GPIO_ENABLE,                   (READ_PERI_REG(RTC_GPIO_ENABLE) & (uint32)0xfffffffe) | (uint32)0x1); //out enable}
void ICACHE_FLASH_ATTRgpio16_output_set(uint8 value){    WRITE_PERI_REG(RTC_GPIO_OUT,                   (READ_PERI_REG(RTC_GPIO_OUT) & (uint32)0xfffffffe) | (uint32)(value & 1));}
void ICACHE_FLASH_ATTRgpio16_input_conf(void){    WRITE_PERI_REG(PAD_XPD_DCDC_CONF,                   (READ_PERI_REG(PAD_XPD_DCDC_CONF) & 0xffffffbc) | (uint32)0x1); // mux configuration for XPD_DCDC and rtc_gpio0 connection
    WRITE_PERI_REG(RTC_GPIO_CONF,                   (READ_PERI_REG(RTC_GPIO_CONF) & (uint32)0xfffffffe) | (uint32)0x0); //mux configuration for out enable
    WRITE_PERI_REG(RTC_GPIO_ENABLE,                   READ_PERI_REG(RTC_GPIO_ENABLE) & (uint32)0xfffffffe); //out disable}
uint8 ICACHE_FLASH_ATTRgpio16_input_get(void){    return (uint8)(READ_PERI_REG(RTC_GPIO_IN_DATA) & 1);}

and the h file.

#ifndef __GPIO16_H__#define __GPIO16_H__
void gpio16_output_conf(void);void gpio16_output_set(uint8 value);void gpio16_input_conf(void);uint8 gpio16_input_get(void);
#endif


Now, during the init gpio part I can call the gpio16_output_conf to setup the GPIO16 as an output GPIO type.

Programmatic now I can call gpio16_output_set (0) or gpio16_output_set(1) to trigger the onboard realy OFF or ON. 

Again, this is the board I am using for testing and development.



0 Response to "ESP201 dev board - One more finding #2."

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel