ESP8266 – easy interrupts

While working on a current project i’ve faced an issue with code reuse. Espressif sdk allows only one interrupt handler for all GPIOs. That’s fine for monolithic code but since we like modular code a dispatcher comes handy.

The little inconvenience i’ve had was like this. I wanted to use the drivers/key.c code but it does use the data argument , so i’ve had to modify it to use a global variable. So i can call it from my own interrupt handler. And that is ugly.

So the lab have a brand new GitHub Account – where i’ll share code.

And the remedy for the issue –  new project: esp8266_easyintr .

May need a tweek or two.  I’ve  extracted it from a wip project.

Usage:

ei_init(); // init easy interrupts
ei_attach(GPIO_NUM, GPIO_MUX, GPIO_FUNC, module_isr, module_data); // setup  handler

You can attach only one per GPIO . You will get your data at the isr and you can have a proper code separation.

 

ESP8266 – The Little Beast!

esp8266ex

The esp8266 chip is made by Espressif Systems.

ESP8266 is a highly integrated chip designed for the needs of a new connected world. It offers a complete and self-contained Wi-Fi networking solution, allowing it to either host the application or to offload all Wi-Fi networking functions from another application processor.

The chip have both certifications FCC and CE. You can sell your products to the mass market.

  • The FCC identifier : 2AC7Z-ESP8266EX
  • The CE opinion number : TCF-1933CC14

Internet of things survey from an year ago at Wi-Fi.org shows very big numbers for smart enabled devices.

Why WiFi for the Internet of Things A.K.A Smart Devices?

Two words – security and availability.

While WiFi is know to be at the edge of the secure protocols it offers much more protection than regular 315/433Mhz devices. 2.4GHz keyboards were hacked recently too.

There are two main types of data that the IoT  devices process:

  1. Sensor Data – It may be sensitive or not but can only be used for analysis. Can cause trouble but only indirectly.
  2. Actuators Control –  If hijacked can make a real mess – what if you use a wireless door lock?

WiFi and the esp8266 chip provide enough security with the TKIP and AES engines built in /is there ever completely secure system? / to control your appliances.

So let’s get started and build some devices:

Appliance Control Goals

  1. Control devices – turn on/off your oven/dishwasher/washing machine/coffee maker/whatever at predefined schedule or at your will.
  2. Collect usage data from your  appliances
  3. … ?

Environment Control Goals

  1. Monitor environment parameters
  2. Monitor presence
  3. Control environmental devices – lights,  blinds
  4. …. ?

It’s an open ended post which will get updated for sure.

But let’s put that little beast to work!