View on GitHub

voffcon

System for controlling electronic appliances using esp8266 and/or esp32

VoffCon - How to setup the devices

Readme Device setup YouTube channel



NodeMcu Esp32
The esp8266 module The esp8266 module
NodeMCU 1.0 (ESP-12E Module) which has the Esp8266 wifi chip on board. ESP32 DEV Module which has the Esp32 Wifi and bluetooth chip on board

Why we need to setup a device

In order to be able to communicate with the device using VoffCon, you will need to setup your computer so you can use it to send a program to the device. This program is called the Device server. The device server will allow the Node server to view and change values on the device it self. To get the device server onto the device you will need to follow the instructions below.

Please see Video tutorial on how to setup VoffCon.

Provide Wifi informatin

These are the same values you need to connect your smart mobile phone to your wifi. The node server will create a program (the device server) and upload it to the device. These values will be injected into the program allowing the device to connect to your wifi network.

After running VoffCon, you will need to

Location

If you want to be able to automate commands (TriggerActions) based on when there is sunrise or sunset VoffCon will need to know your location, or a location near you. This location is used to calculate when sunrise, solar-noon and sunset. Hover the mouse over and click Settings-> Server location.

Install the Arduino IDE

You could also checkout these three video tutorials on how install the Arduino Ide and needed libraries for the two suppored devices.

ESP32 Arduino Core

If you will be using the ESP32 Development Module you will need the ESP32 Arduino Core.

Installing the esp32 core for Arduino

  1. Open the Arduino IDE
  2. Open the preferences window, go to File > Preferences
  3. Enter https://dl.espressif.com/dl/package_esp32_index.json into Additional Board Manager URLs field.
    • note, if you already have a path there, add a comma and a single space behind the last path and then add the path.
  4. Click “OK” button
  5. select from menu > Tools > Board: “Arduino/Genuino Uno” > Boards Manager…
  6. type esp32 into the text box to find the “esp8266 by ESP8266 Community” click it and press the “install” button.
  7. select from menu > Tools > Board: “Arduino/Genuino Uno” > NodeMCU 1.0 (ESP-12E Module).
  8. now you can have fun with a lot of examples for the ESP8266 in File > Examples > ESP8266*

    Tutorial

    Click click to view a good tutorial.

The old method

Click here to get information on how get the ESP32 Arduino Core.

ESP8266 core for Arduino

If you will be using the NodeMCU 1.0 (ESP-12E Module) you will need the ESP8266 Arduino Core.

“Esp8266 by ESP8266 community” is the library I used to write the Device server. You will need to install it. Easiest way to do that is to use the Arduino IDE Board manager.

Installing the ESP8266 core for Arduino

  1. Open the Arduino IDE
  2. Open the preferences window, go to File > Preferences
  3. Enter http://arduino.esp8266.com/stable/package_esp8266com_index.json into Additional Board Manager URLs field.
    • note, if you already have a path there, add a comma and a single behind the last path and then add the path.
  4. Click “OK” button
  5. select from menu > Tools > Board: “Arduino/Genuino Uno” > Boards Manager…
  6. type 82 into the text box to find the “esp8266 by ESP8266 Community” click it and press the “install” button.
  7. select from menu > Tools > Board: “Arduino/Genuino Uno” > NodeMCU 1.0 (ESP-12E Module).
  8. now you can have fun with a lot of examples for the ESP8266 in File > Examples > ESP8266*

Now we should be able to send our device server program to the device via a usb port.

Programming the device

We will need to send the Device server program to the device. We can do that by doing the following

  1. Browse to the the VoffCon system.
  2. Create a device, by going to menu -> Devices -> Register a new device.
  3. Save the device, to add it to the VoffCon database.
  4. Press the “> Run” button and click the “Get program” button.
  5. Save the program to you local hard disk.
  6. Open the Arduino IDE.
  7. Select the device you will be programming
    • for NodeMCU 1.0 select from menu > Tools > Board: “Arduino/Genuino Uno” > NodeMCU 1.0 (ESP-12E Module).
    • for ESP32 DEV Module select from menu > Tools > Board: “Arduino/Genuino Uno” > ESP32 DEV Module
  8. Connect the device to your computer using a USB cable.
  9. Select the COM port the device is connected to.
  10. Select from the menu File -> New to create a new sketch.
  11. Open the .ino program you downloaded.
  12. Copy all text in the downloaded file and paste it into the new sketch in the arduino IDE.
  13. Compile, build and send the Device Server program to the device.

Now the device has been setup and you should be able to connect to it.

Checkout these two tutorials on how to program the devices

The Device server

General information

As noted above this program needs to be uploaded on the device you want to control from the node server. This server will only allow request to it, if the request comes from a client which is on the same subnet. In fact the Device server will check for the first 3 numbers in the calling ip address and if all 3 match the device ip address numbers then the caller will be considered as save and his requests will be acted upon. Exeptions to this can be made by whitelisting specific ip addresses.

Device server commands

Some of the commands a client (the Node server) can send to the device.

Device server Documentation

NodeMcu

Here are all the classes you have access to from the NodeMcu VoffCon device server. In the device server code, there is a variable called server which is of the type ESP8266WebServer

See also:

Esp32

Here are all the classes you have access to from the Esp32 device server. The esp32 device server is built using Arduino-esp32 which is intended to provide an arduino compatible environment on the esp32 hardware. The basic arduino functional documentation can be found here.