Skip to content

LMIC Tasmota Integration

Dave Williams | DitroniX | G8PUO edited this page Apr 8, 2023 · 23 revisions

Integrating LMIC into Tasmota, without any overally complicated setup, can be achieved with the below steps.

This is a basic working configuration. I have not fully integrated a Light Meter, User Button, or monitored the error flag (which is my next 5 minute task!)...

Note: You do NOT need to have any Home Automation or Cloud setup to use the below Tasmota example. It is completely standalone, although you can equally integrate into a Home Automation system, if you so wish,

Future: As I use two linear motors on some of my horizontal panels (one at each end), for safety, I also plan to include something like a MPU-6050 Gyroscope/Accelerometer, to give me a 'Digital Spirit Level' (via I2C). Then if a motor ceases/jams, for example, the panels will effectively start to tilt/twist slightly and the motors will immediately STOP! (saving my panels) - well that's the theory - just need to do the code and I only have 36 hour days..

If you are only using a single linear motor on each panel, then it is not a real problem anyway.

LMIC Dual Solar Panels Test Setup Example with Two Linear Motors

LMIC Dual Solar Panels Test Setup Example with Two Linear Motors

LMIC Solar Panel Tasmota Test - Box

LMIC Solar Panel Tasmota Test - Box

Introduction

Let's assume you are using LMIC to control your Solar Panels. The below configuration will automatically:

  • Configure the GPIOs
  • Configure the WebUI Switches for Up and Down. Controlling the Linear Motor Outputs.
  • Configure the Linear Motor Controller L6205 Enable Line, EN1.
  • Configure the WebUI Switches for a predetermined period (~60s).
  • Set Automatic Timers to turn ON the Linear Motor(s) at 1300 and OFF at 1800.
  • Allow LMIC board to be self contained and unconnected to a broker/server, if required.

Switches

  • Switch 1 = Down (Lower)
  • Switch 2 = Up (Raise)

Safety Enable

The Enable line, EN1 on the Linear Motor Controller (L6205), is connected to a virtual Button on GPIO15. This is used to enable the controller outputs. It is ACTIVE HIGH. This is also used for self protection and safety such as short circuit, over current, over temperature.

The SFLAG line on the Safety Flag logic is connected to GPIO14. This is connected to a virtual Inverted Button which is ACTIVE LOW. So if SFLAG goes HIGH then 'Houston, we have a problem!' This SFLAG is controlled via the on-board LMIC safety logic circuit.

Holding the Enable HIGH will enable the controller inputs to control the outputs to the linear motor(s)_. On an internal safety alert, the L6205 will pull EN1 LOW - but it does not latch!. This is where SFLAG steps in. In the setup, GPIO15 has now been forced HIGH using the LED Parameter (in place of the SWITCH), as this seems more reliable in pulling up - ensuring Enable is HIGH.

In the Tasmota configuration SFLAG is connected via GPIO14 to an inverted virtual Button, so it it held HIGH by default. Some Tasmota code logic could be added to detect if this is virtually pressed (taking GPIO14 HIGH), and then safely STOP further control of the LMIC board until the potential issue is investigated. In my example Arduino code, I simply latch this, disable motor control and display a fault, until investigated.

In round numbers, the SFLAG to GPIO15 should ideally be monitored and if it goes HIGH, then immediately latch in software and shut down the motor control (force Enable, OUT_1x and OUT_2x LOW.

Note: This Tasmota configuration example does NOT monitor the Safety flag.

Bench Test Setup

LMIC Bench Test Setup with Mini Linear Motor

LMIC Bench Test Setup with Mini Linear Motor

Getting Started

  • The first thing to do is Flash a standard Tasmota firmware to the LMIC ESP8266
    • A quick and reliable way to do this is using the Tasmota Web Installer which will connect to the LMIC board via USB
    • https://tasmota.github.io/install/
    • Ensure you 'tick' Erase Device
    • The install will take around a minute
    • Configure your Wi-Fi Si-Fi SSID and Password, which will connect to your network.
      • If you put in incorrect details, you ideally WILL need to re-flash.
    • Click Visit Device.

LMIC-Tasmota-Integration-Web-Install-Firmware

LMIC Tasmota Integration Web Install Firmware

LMIC Tasmota Integration WebUI Sonoff Basic

LMIC Tasmota Integration WebUI Sonoff Basic

  • You then have two options
    • A: Quick Setup. Restore Backup and Update Settings
      • Paste a single long script into the Console
    • B: Manual Setup
      • Paste separate commands into the console

LMIC Tasmota Integration WebUI Sonoff Basic - Console

LMIC Tasmota Integration WebUI Sonoff Basic - Console

LMIC Tasmota Integration WebUI Console - Basic

LMIC Tasmota Integration WebUI Console - Basic

Quick Setup

A Tasmota configuration has been created and saved as a complete example script.

Once Tasmota is flashed to the LMIC ESP8266 board, you should be presented with the Tasmota default WebUI.

Configuration information, and settings, are entered into the Tasmota WebUI Console. Copy and paste the below highlighted text, as separate individual entries, or as one configuration using the backlog option.

Simply:

  • Click Console

  • Copy and Paste the below into the command line

  • Press ENTER, once you have pasted

  • The board will then automatically restart.

  • Click Main Menu

      backlog SetOption0 0; SetOption36 1; template {"NAME":"Tasmota - LMIC","GPIO":[0,3200,7616,3232,640,608,1,1,224,225,96,288,33,4768],"FLAG":0,"BASE":18} ; PowerOnState1 0 ; PowerOnState2 0 ; webbutton1 Down ; webbutton2 Up ; pulsetime1 160 ; pulsetime2 160 ; Timer1 {"Enable":1,"Mode" :0,"Time":"13:00","Window":0,"Days":"SMTWTFS","Repeat":0,"Output":1,"Action":0} ; Timer2 {"Enable":1,"Mode" :0,"Time":"13:00","Window":0,"Days":"SMTWTFS","Repeat":0,"Output":2,"Action":1}; Timer3 {"Enable":1,"Mode" :0,"Time":"18:00","Window":0,"Days":"SMTWTFS","Repeat":0,"Output":1,"Action":1} ; Timer4 {"Enable":1,"Mode" :0,"Time":"18:00","Window":0,"Days":"SMTWTFS","Repeat":0,"Output":2,"Action":0} ; Timer15 {"Enable":1,"Mode":0,"Time":"19:00
      ","Window":0,"Days":"SMTWTFS","Repeat":0,"Output":1,"Action":0} ; Timer16 {"Enable":1,"Mode":0,"Time":"19:00","Window":0,"Days":"SMTWTFS","Repeat":0,"Output":2,"Action":0} ; DeviceName LMIC ; module 0
    

LMIC Tasmota Integration WebUI Console - Simple Setup

LMIC Tasmota Integration WebUI Console - Simple Setup

LMIC Tasmota Integration WebUI Main

LMIC Tasmota Integration WebUI Main

Manual Configuration Setup

Once Tasmota is flashed to the LMIC ESP8266 board, you should be presented with the Tasmota default WebUI.

Configuration information, and settings, are entered into the Tasmota WebUI Console. Copy and paste the below highlighted text, as separate individual entries, or as one configuration using the backlog option.

LMIC Tasmota Integration WebUI Console

LMIC Tasmota Integration WebUI Console

Note: The console commands below also show the 'backlog' option, which groups commands together, separated by a semicolon. Simply copy and paste a line at a time, whichever you feel comfortable using.

Disable power state saves

Backlog SetOption0 0; SetOption36 1

Configure LMIC GPIO Template and Reboot

This will setup the GPIO to match the LMIC basic configuration

backlog template {"NAME":"Tasmota - LMIC","GPIO":[0,3200,7616,3232,640,608,1,1,224,225,96,288,33,4768],"FLAG":0,"BASE":18} ; module 0

Configure Power On States

This ensures that both Linear Motor Control Inputs are LOW on power up.

PowerOnState1 0
PowerOnState2 0

or

backlog PowerOnState1 0 ; PowerOnState2 0

Rename Web Buttons

Simply renames the Web Buttons

webbutton1 Down
webbutton2 Up

or

backlog webbutton1 Down ; webbutton2 Up 

The above will setup the below GPIO Configuration

LMIC Tasmota Integration WebUI Template Parameters

LMIC Tasmota Integration WebUI Template Parameters

Set Web Button Countdown Timer. This will automatically turn off the motor after 0.x seconds.

Note: Adjust as needed, based on the time it takes to raise the Solar Panels (as this generally will be longer than lowering).

pulsetime1 160
pulsetime2 160

or

backlog pulsetime1 160 ; pulsetime2 160

The above will setup the below Buttons

LMIC Tasmota Integration WebUI Main

LMIC Tasmota Integration WebUI Main

Timers

Setup Timers. To control a device locally 16 timers are programmable. These timers can be fixed time or automatically controlled by local sunrise and sunset.

In this LMIC example, we are using this is to automatically raise and lower the panels are fixed certain times, days etc. If the light sensor is configured (not in this example), you could use this to automatically control the panels. Configure as required.

Further information, such as sunrise/sunset, can be found https://tasmota.github.io/docs/Timers/

Up, or Raise. This example will extend the linear motor(s), so raising the panels, daily at 1300

Timer1 {"Enable":1,"Mode" :0,"Time":"13:00","Window":0,"Days":"SMTWTFS","Repeat":0,"Output":1,"Action":0}
Timer2 {"Enable":1,"Mode" :0,"Time":"13:00","Window":0,"Days":"SMTWTFS","Repeat":0,"Output":2,"Action":1}

or

backlog Timer1 {"Enable":1,"Mode" :0,"Time":"13:00","Window":0,"Days":"SMTWTFS","Repeat":0,"Output":1,"Action":0} ; Timer2 {"Enable":1,"Mode" :0,"Time":"13:00","Window":0,"Days":"SMTWTFS","Repeat":0,"Output":2,"Action":1}

Down, or Lower. This example will retract the linear motor(s), so lowering the panels, daily at 1800

Timer3 {"Enable":1,"Mode" :0,"Time":"18:00","Window":0,"Days":"SMTWTFS","Repeat":0,"Output":1,"Action":1} 
Timer4 {"Enable":1,"Mode" :0,"Time":"18:00","Window":0,"Days":"SMTWTFS","Repeat":0,"Output":2,"Action":0} 

or

backlog Timer3 {"Enable":1,"Mode" :0,"Time":"18:00","Window":0,"Days":"SMTWTFS","Repeat":0,"Output":1,"Action":1} ; Timer4 {"Enable":1,"Mode" :0,"Time":"18:00","Window":0,"Days":"SMTWTFS","Repeat":0,"Output":2,"Action":0} 

Nightly Reset. This example will ensure Motor Outputs are Low, daily at 1900

Timer15 {"Enable":1,"Mode":0,"Time":"19:00","Window":0,"Days":"SMTWTFS","Repeat":1,"Output":2,"Action":0}
Timer16 {"Enable":1,"Mode":0,"Time":"19:00","Window":0,"Days":"SMTWTFS","Repeat":2,"Output":3,"Action":0}

or

backlog Timer15 {"Enable":1,"Mode":0,"Time":"19:00","Window":0,"Days":"SMTWTFS","Repeat":0,"Output":1,"Action":0} ; Timer16 {"Enable":1,"Mode":0,"Time":"19:00","Window":0,"Days":"SMTWTFS","Repeat":0,"Output":2,"Action":0}

Note: The days shown above 'SMTWTFS' could equally be a 1, such as '1111111'. Any day with a 0 or -, will be ignored.

The above will setup the below Timers

LMIC Tasmota Integration WebUI Timer Parameters

LMIC Tasmota Integration WebUI Timer Parameters

Static IP Address

Set Static IP, rather than DHCP. This example will set static IP of 192.168.1.60, Gateway 192.168.1.1, DNS 192.168.1.1

Should you wish to fix the IP address, rather than use DHCP, you can do this using the below example. Change the addresses as needed to suit your network.

backlog IPAddress1 192.168.1.60 ; IPAddress2 192.168.1.1  ; IPAddress3 255.255.255.0  ; IPAddress4 192.168.1.1  ; restart 1

Note: All these configurations could be added in one go! However, the backlog command has a maximum 500 character limit.

Backup

Most important is to BACKUP your configuration. This can be achieved via the Configuration menu Backup.

LMIC Tasmota Integration WebUI Configuration Menu - Backup

LMIC Tasmota Integration WebUI Configuration Menu - Backup

Testing the Board

Once you have completed the above quick, or manual, configuration, you should see the below WebUI.

Simply click the Up or Down buttons and if you have a linear motor connected to the LMIC (remember to power the board!), the motor should actuate.

Note: Nothing will happen if you have both buttons turned on!

Remember also, the configuration examples will make the button automatically turn OFF in around 60 seconds.

enter image description here

You can now adjust configuration as needed, integrate with your Home Automation, if you have one, or experiment further.