Build a 2log Switch

Learn how to build a 2log Switch

The 2log Switch is a smart wireless socket that can switch power and measure energy consumption. It communicates via WiFi with the 2log server and ensures that only authorized users can use the machines. By measuring the power consumption, the system knows exactly how long the machine has been in use.

Supported smart sockets

Theoretically, any tasmota compatible, ESP8266 based WiFi socket is suitable. Depending on the type, the software from our repository has to be adapted a bit.

To turn a smart socket into a 2log Switch, the 2log Switch firmware must be flashed to the device. For this purpose a USB Serial Adapter (FTDI) is required.

Shelly Plug S

Officially supported is currently the model “Shelly Plug S”. By the way, this is also one of the few models for which correct CE certificates could be provided.

To flash a Shelly Plug S socket you have to do the following steps:

  1. Download the firmware binaries from our CI Pipeline
  2. Open the housing of the socket by loosening the screw on the back.
  3. Connect the serial programmer (This blogpost shows how to connect the pins)
  4. Flash the firmware with esptool \
        --chip esp8266 \
        --port /dev/tty.usbserial-UUT1 \
        --baud 230400 \
        --before default_reset \
        --after hard_reset write_flash \
        -z \
        --flash_mode dio \
        --flash_freq 40m \
        --flash_size 4MB \
        0x0 /build/bootloader/bootloader.bin \
        0x10000 /build/2log-switch.bin \
        0x8000 /build/partitions-single-1MB.bin

Connect the Switch with your 2log instance

You can set up the devices either with the 2log app or manually with a Linux Shell. Using the app is straight forward and will be explained in the corresponding chapters.

Provisioning without mobile app

Here we explain how to provision a Switch via a direct SSH connection. You only need a command line for the manual setup.

You can also use this protocol to create your own program code for provisioning.

  1. Press the button of the Switch for several seconds. Once the Dot is in pairing mode, it will start blinking slowly and open a WiFi hotspot.

  2. Connect your laptop to the WiFi with the SSID I'm a Switch.

  3. Enter the following command into your linux console:

openssl s_client -connect

After a few console outputs, a connection to the Switch should be established.

  1. Send the following JSON command to the device by typing it into the console and confirming with return:
 {"cmd": "hi"}

The device will respond with something similar to

	"cmd":	"welcome",
	"device":	{
		"sid":	"I5O2",
		"uuid":	"3C:61:05:DE:8A:A4"

Write down the short id (sid) somewhere. You will need it later to assign the device. In the example here the device has the sid I502

  1. Now we can send the configuration to the device with the following JSON command
  1. The device will respond with
{ "cmd":"setconfig","status":1}

Which means that the device has received the data.

  1. The device will now reboot and try to connect to the server. The Switch will stop blinking and glow continuously once it is successfully connected to the 2log instance. Now you can assign a function to the Dot using the four-digit short ID.