Showing posts with label Development board.. Show all posts
Showing posts with label Development board.. Show all posts

Saturday, April 23, 2016

Witty ESP8266 module RGB LED removal

As you already know the Witty ESP8266 module has an SMD RGB LED on board. 

The LED colors are connected to some GPIO pins.

RED is connected to GPIO 15
GREEN is connected to GPIO 12 
BLUE is connected to GPIO 13

For a project I want to use the GPIOs 12,13,14,15 for a different functionality so I need to remove the LED from the board.


SMD LED for Witty ESP8266 board

In the above picture the pins 2,4,6 are connected together to the GND. 

Instead of removing the SMD LED I cut the common ground as you can see in the following picture.

Later if I need the LED functionality I can redo it very easy.





I've tested the board, and no sign of LED on board. Perfect.





Tuesday, June 2, 2015

Android application Homy

The new Android application that is connecting with my broker over web sockets is having now new features:

1. Auto-discovery. Each time the application is started, all devices are sending their status. Here there are 6 IoT devices discovered:

  • two plugs
  • two irritool ( one is in production for more then one month, and the other is for debugging and simulation ( NASA style :-)  )
  • two (dth - digital temperature and humidity sensors. They are mount on each irritool)


6 devices dicovered



2. Devices are presented on categories, based on the incoming  data from them. 
At  this stage the name is based on the unique device id and its type.

Plug devices discovered

3. Device detail. All the information about device is presented in here:
-device id
-ip address
-network type (B/G/N)
-up time ( if is configured to be transmitted)
and I am able to control the device ( like in plug/irritool case) or see the data for sensors.
Device detail - PLUG
Device detail - IRRITOOL 

Device detail - Sensor DTH


Looks ugly and hard to remember that the ESP_00A08478 is the name for irrigation controller so I've added the new option to rename the device name with whatever you want. This aliasing is persistent so every time I reopen the application, the mapping between device id and device alias is the same.


Here is a renamed plug:


Plug renamed 

Other feature is 7 day weather report for my location (need more work in presenting the data).

weather report next 7 days


I can declare now the application to be in alpha stage ....


4.Other option I have in the Menu:



Debug will be to see the messages received from broker.




There are a lot of picture in this post, but a picture is 1000 words.







Thursday, March 19, 2015

Example: Blink a LED

Like in the Arduino case one of the first thinks to try it is to blink an LED.

The following link contains the code for blink an LED.

Materials:

  • ESP-01 - or other version 
  • LED 
  • SERIAL to USB

If you have my setup described here 

1. put the the archive into this directory

/opt/Espressif/ESP8266_SDK   

2. untar the file

tar -xvf blinky.tar

3. enter in the app directory

cd blinky

4. compile the code

make clean ; make.

5. Upload the resulting files ( from the firmware directory) to your ESP after this steps

5.1 Unplug the VCC power pin
5.2 Connect the GPIO0 pin to ground
5.3.Use the command to write the firmware

./burnESP


Anatomy of the code

 The main application file is the user_main.c file located in 
/opt/Espressif/ESP8266_SDK/blinky/user

The file content is:


#include "ets_sys.h"
#include "osapi.h"
#include "gpio.h"
#include "os_type.h"
#include "user_config.h"

#define user_procTaskPrio        0
#define user_procTaskQueueLen    1
os_event_t    user_procTaskQueue[user_procTaskQueueLen];
static void user_procTask(os_event_t *events);

static volatile os_timer_t some_timer;


void some_timerfunc(void *arg)
{
    //Do blinky stuff
    if (GPIO_REG_READ(GPIO_OUT_ADDRESS) & BIT2)
    {
        //Set GPIO2 to LOW - TURN OFF the LED
        gpio_output_set(0, BIT2, BIT2, 0);
    }
    else
    {
        //Set GPIO2 to HIGH - TURN ON the LED
        gpio_output_set(BIT2, 0, BIT2, 0);
    }
}

//Do nothing function
static void ICACHE_FLASH_ATTR  user_procTask(os_event_t *events)
{
    os_delay_us(10);
}

//Init function 
void ICACHE_FLASH_ATTR user_init()
{
    // Initialize the GPIO subsystem.
    gpio_init();

    //Set GPIO2 to output mode
    PIN_FUNC_SELECT(PERIPHS_IO_MUX_GPIO2_U, FUNC_GPIO2);

    //Set GPIO2 low
    gpio_output_set(0, BIT2, BIT2, 0);

    //Disarm timer
    os_timer_disarm(&some_timer);

    //Setup timer
    os_timer_setfn(&some_timer, (os_timer_func_t *)some_timerfunc, NULL);

    //Arm the timer, &some_timer is the pointer 1000 is the fire time in ms
    //0 for once and 1 for repeating timer
    os_timer_arm(&some_timer, 1000, 1);
    
    //Start os task
    system_os_task(user_procTask, user_procTaskPrio,user_procTaskQueue, user_procTaskQueueLen);
}


and is pretty much self explanatory.

1. Include the necessary headers. See that user_config.h is empty so if you can use this app as a skeleton for your future applications. 

2. In user_init() function the GPIO is initialized, GPIO2 is set up as an output pin and is set
to 0 (LOW, GND).

3. A timer is defined (some_timer) and initialized and the  callback function is set to be called every 1000ms (1sec) interval. 

4. Callback function some_timerfunc is doing all the stuff, if the LED is ON turn it to OFF,
otherwise turn the LED ON.


If you want to add extra functionality check this post for how to have arduino like functions
to manipulate your GPIO. 

Happy codding !!! 

Tuesday, March 10, 2015

Post man #1 - 3V3 relays board

Today I've received a new order from aliexpress.com.

A board with four relays working on 3V3.




I will use the relays to control the irrigation system that is now driven by a Raspberry Pi.

So, the ESP201 will replace the Raspberry Pi that did a very good job in the last three years.

I am using the 3V3 relays just for fun, I've tested the ESP201 with 5V relays and are working normally from my point of view.  



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.



Sunday, March 8, 2015

ESP201 dev board - One more finding #1.


Good news today!

I have managed to find why the GPIO15 connected to the RED RGB LED was not working !

The answer was under my nose. DIP pin K1 (S2) must be on the OFF position. See the picture:



Cool !!!! Now I can fully test PWM on this board.





Remaining unknown items: RELAY (J) connected to GPIO16.  SOLVED !!! See link below.

UPDATE: triggering the relay is described here

Thursday, March 5, 2015

Use my ESP8266 environment !!!

User ESP8266
password espressif

Let's see how you can compile our first example of code.

To do this download the virtual box ova from my drive.

Apply this ova file to a Virtual Box.

Start the virtual machine

go to /opt/Espressif/ESP8266_SDK/ where there are two directories with examples:

IoTDemo - a web server controlling  some GPIO's
at - build a custom AT command along with all command that are supportded by the at library


go to /opt/Espressif/ESP8266_SDK/IoTDemo/
make clean
make

two files are generated into the /opt/Espressif/ESP8266_SDK/bin directory.
!!!
No boot needed.
Generate eagle.flash.bin and eagle.irom0text.bin successully in folder bin.
eagle.flash.bin-------->0x00000
eagle.irom0text.bin---->0x40000
!!!

 Use those files and the optional blank image blank.bin or you can use this command
to write the files.

sudo /opt/Espressif/esptool-py/esptool.py --port /dev/ttyUSB0 write_flash 0x3C000 /opt/Espressif/ESP8266_SDK/bin/blank.bin 0x00000 /opt/Espressif/ESP8266_SDK/bin/eagle.flash.bin 0x40000 /opt/Espressif/ESP8266_SDK/bin/
eagle.irom0text.bin

Write the files on ESP-01.
1. Power off the ESP-01
2. Connect GPIO0 to GND
3. Power on the ESP-01
4. Burn firmware

Write the files on ESP201 Dev Board.
1. Power off the ESP-201
2. Keep pressed S2 and power the board
3. Release the S2 switch
4. Burn firmware

Notes:


  1. In /opt/Espressif/ESP8266_SDK/document/ there are tow directories English an Chinese with document about the SDK fucntion, AT command. Spend some time looking into them.
  2. In the Virtual Box image I've added the moserial application that can be used to see the debug information from ESP.
  3. Launch moserial with: sudo moserial &
  4. If Software Updater is bugging you, do not update. You are just fine.





Wednesday, March 4, 2015

ESP8266 Wireless Wifi Module Develop Board 8266 SDK Development Chip

Other interesting board is this board from Electronic Gadget World, a shop on aliexpress.com.

If you can not find this board you can buy other good development boards like:

1. Development board with ESP8266 module and power supply.
2. Battery operated development board
3. Small form factor development board

The parcel contained one ESP201  an SDK Development board and a DHT11 sensor. No cables or power supply. I've ordered two extra ESP201 so I've replaced the faulty one with a good ESP201.

As you can see in the image there are two USBs. The microUSB located on the top right is just for powering the board. The other usb, a type B USB can be used to power the board, and to write firmware to ESP201 flash. The usb to serial on board is a CH340G chip. My win7 didn't complain about it, I was able to write the flash to ESP201.
The only problem is that the transfer was done at 9600 or less (like 5 minute for 200k), after I've modified in the DeviceManager the speed for the port, the transfer rate was increased. But this happened only once, so I gave up using the CH340G chip for now. I've removed the red jumpers and I used my old Prolific USB/serial.

I'll reinstall the drivers for CH340G chip with this one  later and I'll see if helps.


ESP201 SDK development board

Now let's talk about the connections. As you can see the dev board has:


  • a relay
  • a RGB led
  • a white led ( almost under the RGB led which is above the buzeer)
  • DHT11 
  • buzzer
  • two switched S2 and S3
  • a variable rezistor for ADC ( on the left of relay ) connected to ADC pin.
  • a 5v to 3v3 convertor 
  • a main switch in the right upper corner (this switch is just for ESP201 board I guess, I have the impression that the CH340G is still receiving power even the switch is off).


DIP functionality
On the PCB near the DIP switch there are the values :


  • R - should be the RED led from the RGB connected to the IO15 pin. Putting the R DIP to ON will light RED if the GPIO15 is HIGH.
  • G - GREEN led from RGB led is connected to IO13. Putting the G DIP to ON will light GREEN if the GPIO13 is HIGH.
  • B - BLUE led from RGB led is connected to IO12. Putting the B DIP to ON will light BLUE if the GPIO12 is HIGH
  • W - WHITE led located almost under RGB led is connected to the IO14 pin. Putting HIGH on GPIO14 and DIP switch on ON will light the WHITE led
  • J - relay pin connected to IO16 ( which is always HIGH - I have no idea why . This behavior and the RED led that is not working can be because I have a bad board or the design for all the boards is wrong. Connecting the IO16 to GND (not recommended) will stop the relay, otherwise it will be ON all the time the J DIP pin is ON.
  • B - BUZZER connected to IO5 pin throuch B DIP switch. Having GPIO5 HIGH and B on DIP switch ON will prove that the buzzer is working.
  • K1 - I assume is connected to S2
  • K2 - I assume is connected to S3.


A schematics on a napkin will look like this one:


Napkin schematics :-)

And thanks to Scott Snowden and jwbr from http://www.bpower.nl/ there is a complete schematics of the board.


Wifi Module Develop Board 8266 schematics




On IO4 is connected the DHT11 sensor. I didn't use it because I have a DHT22 which is more accurate.


How to write flash.

1.Power off the board.

2.Keep S2 pressed and power on the board using the switch located in the right top of the board.
3.Now you can write the flash from the ESP201 board.


Conclusions:

It is a very good board, no issues found. If you want a rapid development board you can buy this one.

And the final config will look like in this picture (2 external relays, 2 external LEDs DHT22). Pretty crowded. Breadboard is just for GND.




UPDATE1: See what to do to have access on the GPIO15 ( Red led from RGB) - HERE

UPDATE2: See what to do for controlling the relay connected on the XPD / GPIO16 - HERE

UPDATE3: A IoT plug based on ESP-01 - HERE.   A lawn irrigation IoT based on this board is coming soon.

UPDATE4: Now I have a unix cron functionality on my ESP8266 chips.

UPDATE5: MQTT broker running on ESP8266