enocean

This is an old revision of the document!


enOcean

enOcean is a pretty cool energy harvesting technology focused on smart home applications. enOcean is best known for the wireless light switches that don't require a battery to operate. additionally, they come in looks compatible to Feller edizio due and hager callysto, which are used in almost every building in switzerland.

the light switch has a piezo module built in which uses the energy of the button-push to create enough electricity to send a datagram to the enOcean receiver to tell it that the switch has been pushed.

another nice thing about enOcean is the fact, that they sell a pretty affordable (15$ range) module called TCM310 which can be used to both send or receive enOcean data packages over the air. The protocol is also openly documented.

my goal is to use a TCM310 in the form of an enOcean Pi module together with ideally a sonoff or some other ESP8266 based board to receive push button presses and send them to an MQTT broaker. As the “enOcean PI” product name says, the module is acutally made for a raspberry pi and I am sure, that my goal could be achieved simpler by using a raspberry Pi. But i want this to be a set-and-forget system, and a full blown linux server to me is just not such a thing. however, we will see how it works out.. maybe i'll revert to the easy path in case it gets too complicated to do it all on an ESP8266 :)

there are only four pins which are used on the enOcean PI module:

thanks to Kerry D. Wong who published this Information

I plan on using a Wemos D1 mini module (or a clone of it i guess) which can be purchased on aliexpress for a few $. i will then use the arduino core on it to program it via the arduino IDE.

arduino-esp8266 documentation

based on this documentation, the serial port will be available on GPIO1 and GPIO3.

here are a few libraries i have found beforehand and intend on trying out:

  • Async MQTT client for mqtt obviously
  • ESPAsyncTCP to plot debug messages to a netcat server while working with the enOcean module on the serial port.. this is to avoid using SoftSerial.
  • WiFiManager seems to do all we need to make the final device easy to get configured without a serial connection (has automatic fall back to AP mode with captive portal config page).

first setup_arduino_ide_for_esp8266 and install the WiFiManager via the Tools→Include Library→Manage Libraries. Search for and install WiFiManager. This also installs all the dependencies which is nice. However i had to manually download and install the latest development release from the git, in order to have the configuration page available even when the device was connected to the wifi.. this should become part of the stable release any time soon, so this step might not be necessary anymore when you read this:

  1. navigate to <arduino directory>/portable/sketchbook/libraries/
  2. rm -rf WiFiManager
    git clone https://github.com/tzapu/WiFiManager.git
    cd WiFiManager/
    git branch -a
    git checkout remotes/origin/development

that's actually fairly simple.. just include it and put autoConnect() in your startup. the tricky part was to get the config webpage to run using startWebPortal(). the trick i've missed was, that the process() method needs to be called in the loop() or else it won't display any webpages. so here is the working sketch:

#include <ESP8266WiFi.h>          //ESP8266 Core WiFi Library (you most likely already have this in your sketch)
#include <DNSServer.h>            //Local DNS Server used for redirecting all requests to the configuration portal
#include <ESP8266WebServer.h>     //Local WebServer used to serve the configuration portal
#include <WiFiManager.h>          //https://github.com/tzapu/WiFiManager WiFi Configuration Magic
 
WiFiManager wifiManager;
 
void setup() {
  // put your setup code here, to run once:
  Serial.begin(115200);
  wifiManager.autoConnect();
  wifiManager.startWebPortal();
}
 
void loop() {
  // put your main code here, to run repeatedly:
  wifiManager.process();
}

we use ESPAsyncTCP's AsyncPrinter to print debug messages to a tcp socket at our development machine as we will use the serial port to connect to our enOcean board.

first we need to install the library:

cd <arduino directory>/portable/sketchbook/libraries/
git clone https://github.com/me-no-dev/ESPAsyncTCP.git

for my development machine to receive those messages i need to open a socket with netcat in listening mode. this is for linux but i am sure there are tools like that in windows too, i just don't know them. so on your develpment machine run:

nc -l 3333

and leave the terminal open.

let's add AsyncPrinter to our sketch:

#include <ESP8266WiFi.h>          //ESP8266 Core WiFi Library (you most likely already have this in your sketch)
#include <DNSServer.h>            //Local DNS Server used for redirecting all requests to the configuration portal
#include <ESP8266WebServer.h>     //Local WebServer used to serve the configuration portal
#include <WiFiManager.h>          //https://github.com/tzapu/WiFiManager WiFi Configuration Magic
#include <AsyncPrinter.h>

AsyncPrinter ap;
WiFiManager wifiManager;
 
void setup() {
  // put your setup code here, to run once:
  Serial.begin(115200);
  wifiManager.autoConnect();
  wifiManager.startWebPortal();
  ap.connect("192.168.168.48",3333);
  ap.println("hello world");
}
 
void loop() {
  // put your main code here, to run repeatedly:
  wifiManager.process();
}

you should now see “hello world” on your terminal with nc running.

  • enocean.1520655916.txt.gz
  • Last modified: 10.03.2018 05:25
  • by Pascal Suter