Tasmota MQTT Mosquito Telegraf Influxdb Grafana


Just a few notes at the moment – a work in progress.  This is just what I’m doing – your mileage may vary.

ESP8266

The WIFI chip behind the modules.  By most accounts it is not 5V tolerant.  I’m using 2 modules, the D1 Mini Pro and the smaller ESP-01S.

The D1 has a USB interface on-board and programs reliably when plugged directly into the PC.  The ESP-01S needs a 3.3V USB adapter so I got a couple of those small USB adapters the ESP-01S plugs directly into – orient to point the antenna at the USB connector.  This was not reliable until I installed a 1K resistor in series with the TX line to the module.  The USB chip is applying 5V to the RX pin of the 8266, which it doesn’t seem to like.  The USB adapter also needs a switch to Gnd on the GPIO0 line to enable programming.

Note: GPIO0 and GPIO2 must be low and GPIO15 high at boot for the 8266 to run normally.  The D1-Mini-Pro board has 10K resistors on-board to set these levels for normal program boot.  GPIO0 = D3, GPIO2 = D4. GPIO15 = D8.  If these I/O line levels are wrong at reset you program won’t run – be careful.

Tasmotizer can install the network configuration to the D1 so it connects directly to your wifi network after programming.  Otherwise after reboot Tasmota provides a access point (AP) at 192.168.4.1 which you have to use a cellphone to connect to via wifi to configure the SSID and password.  Tasmota then reboots and connects to your wifi, DHPC.

I had some problems getting Tasmotizer to install the configuration but think I have it working now.  Install Tasmota first and reboot normally (Tasmota provides the AP but ignore this.  Use Tasmotizer to save the configuration to Tasmota and reboot it again.  It should now connect to your network without having to use the AP.

Tasmota

Command reference: here

I’m using the D1-Mini-Pro because it has the external antenna option and the ESP-01S (S means 1MB flash) because it’s small and cheap.

Install Tasmota using Tasmotizer – I’m using Kubuntu, running Tasmotizer from the command line by simply entering “tasmotizer.py”.

Tasmotizer will erase then install Tasmota.  If using a cellphone to configure – once Tasmota is installed and restarted, use a smart phone to connect to the AP it provides – a message appears, select “connect to” and it takes you to a page that allows your network SSID and PW to be entered.  It then resets and connects to your network.

Check you wifi router to find out what IP address it’s on then visit that address using a web browser – I had to allow java script on that address for it to be functional.  Now complete the configuration of Tasmota.

When I added the 4th Tasmota device DHCP to the router there was a problem – all 4 devices would appear and disappear, no data getting through and no access using a web browser.  The IP addresses would keep changing making connection attempts impossible.  The solution was to log into the router and manually assign IP addresses to the MAC addresses of the Tasmota devices.

Be sure you have a reasonably good wifi signal between Tasmota and the router or it may be a bit slow and unreliable.  looking at the “Information” page will let you know the signal level and a lot more.  I have noticed that if the signal level is below about 30%, the pages can take a long time to load and often don’t completely load.

To get correctly dated messages you set timezone at the web interface console by entering the command “timezone 12” – for New Zealand.  Timezone without the 12, will display the current setting.  The number “12” is an offset in hours from UTC.

To set a static IP address:  use the web console and enter “IPAddress1 192.168.1.75”, changing the actual address to what you want it to be.

ESP-8266 D1-mini Pro – ACW-1A*

esp8266 1 Mini Pro acw_1a1A carrier board for the D1-Mini-Pro, providing power supply and input/output connections.  The design purpose was to provide a outdoor unit for control/monitoring.  The narrow module can be housed inside a 32mm diameter conduit making it waterproof and suitable for outdoor elevated mounting for best wifi range.

  • mounts a standard ESP-8266 D1-Mini-Pro module (not supplied)
  • power supply nominal 12V DC
  • dc-dc 5V regulator module
  • relay output – 2A, 35V ad/dc, C-NC-NO
  • mosfet output – 5A, 12V – switches -ve
  • 1 each, optically isolated input and output
  • ten general purpose i/o connections
  • narrow to fit inside 32mm electrical conduit
  • mounts various 2.4Ghz wifi antennas
  • corner mounting holes

esp8266 1 Mini Pro acw_1a1For outdoor mounting, possibly raised, up a pole or on a roof the ACW_1A module can be mounted inside a standard 32mm electrical conduit.  The antenna can be sealed into the conduit or protruding through a hole in the end cap – sealed with silicon RTV.  The antenna can be a simple 1/4 wave as shown or for longer ranges a higher gain or directional antenna.

For shorter ranges, the on-board antenna can be used.

Note :  Unless specified, you will need to supply the ESP-8266 D1-Mini-Pro and wifi antenna if required.

For specific application the unit can be supplied complete and ready to install with a suitable wire tail for connection to power and input/output.

Header Pin and I/O functions

  • TX and RX = TX and RX on the D1-Mini-Pro : 3.3V I/O
  • I2C – clk and dat to D1 and D2 on the D1-Mini-Pro : 3.3V I/O
  • Analog Ana = A0 on the D1-Mini-Pro (see comment below)
  • DS 1-wire = D5 : note : the 4K7 pull-up is enabled via a small solder jumper on board
  • isolated opto-input = D3 : apply a voltage to trigger the input – Note: must be off at boot/reset
  • isolated opto-output = D4 : output closes when activated
  • relay = D0 : note : the relay must be enabled via a small solder jumper on board
  • mosfet-output = D8 : affects boot mode (GPIO15).

Analog Input

The input is only rated to a maximum of 3.3V.  As there is a 10K pull-up on the analog input it will read full scale (1024).  The 470R series resistor and the 10K act as a voltage divider but only increase the input voltage slightly.  An additional external series resistor is all that’s needed to read higher voltages.  Example: 33K allows reading approximately 0-14V over the 0-1024 count range – suitable for monitoring a 12V SLA battery.  Note: each instance will require calibrating.

Example I/O

Anemometer and direction : wind sensors.  Fine-Offset.  Yellow/Red the two center wires are the wind speed providing 2 pulses per revolution.  Black/Green the two outer wires are wind direction providing a resistance over 8 steps for 360-deg.  The resistance varies between 1K and 120K but is not in regular increments around 360-deg.

Rain gauge (Fine Offset) produces a pulse with every 0.3mm of rain.

DHT-22 humidity/temperature and DS18B20 temperature sensors each use a different 1-wire data interface.

Example – Greenhouse 2

Module Type: Sonoff Basic, Generic (0).  Operating from a 12V 7Ah SLA battery and 10W solar panel.  The battery is enough for a week or so but the 10W solar panel is not big enough during winter.  If the battery runs flat the Tasmota configuration can be lost and must be reloaded from backup.

IO setup: D2: I2C SDA, D1 I2C SCL, D5: AM2301, D8: Relay1, D0: Relay2, A0: Analog

Analog is used with a voltage divider to monitor the 12V battery voltage.  The voltage divider reduces the battery voltage to less than 3.3V for the 8266.  14V to 3.3V.  The battery voltage tops out at 13.8V which is quickly achieved during summer but often not during winter.  This requires improvement.

The I2C connects a ?? sensor.  These have not been very reliable in the greenhouse and need a much more protective housing that still allows air-flow.

The AM2301 is a basic temperature and humidity sensor.  These have been quite reliable.

Relay1 is the on-board relay, not currently used.  Relay2 is the power mosfet output and switched a 10W LED light strip. 

Sensor Board – CJMCU-8118

This board contains a CCS811 gas sensor and a HDC1080 ?? sensor.

Configure 2 I/O pins, D1 as “I2C SCL” and D2 as “I2C SDA”.  The sensor runs on 3.3V.

PIC – ESP-01 board

wlc_1a controller esp-01This is an update of a previous control board that I have used for several applications.  The on-board PIC controller performs the particular function required.  The expansion/improvements include on-board mains power supply and ESP-01 which with suitable support in PIC code can provide remote monitoring and/or control.

wlc_1a controller esp-01Previous applications of the original board include refrigeration controller, power safety cutoff controller for laser cutters, computer cabinets, etc. and water level controller.

ESP-01 Relay Board

Note:  This board as assembled operates from a 12V DC mains power supply module, due to the use of 12V relays.

Initially tested with Tasmota (sensors version) installed to the ESP-01 – was just convenient.  “D3 GPIO0” is the relay output – use “Relay1i(29)” for normal relay operation.  RX, TX D0 and D2 can be connected to the PIC micro.

Application Example – July 2022

PZEM-004T electricity monitoring moduleAdding a PZEM-004T 100A electricity monitoring module to our Power-Safety-Cutoff unit creates a portable power meter that reports data  via MQTT to a database to be displayed on a web page.  This was done using on-hand parts to graph power use by a refrigerator to get an idea of how it was holding up after 18+ years.

PZEM-004T resistor update for 3.3VTo connect directly with the eps-01s a resistor on the PZEM-004T is changed from 1K to 470R to support the 3.3V interface rather than 5V.  R8 in this image.  Connecting just one PZEM-004T module to Tasmota is easy enough as it just works it out and connects.  In other situations it is possible to connect three modules to the one serial port of the esp-01s by setting the address of each module.  At the command line in the Tasmota Console enter “ModuleAddress 2” and Tasmota will set this address.  Have one module connected at a time while setting addresses and set addresses, 1,2 or 3.

Power Safety Cutoff with PZEM-004T electricity monitoringAdding the PZEM-004T module to the Power-Safety-Cutoff required a bit of fiddling.  The 4-pin interface connector onthe board was swapped from a right-angle to a straight type.  A short lead added to connect the PZEM board to the PSC board, soldered to the back of the esp-01 socket and glued to the back of the PSC board for strain relief.  The esp-01 is disconnected from the PSC micro-controller so that it doesn’t upset the esp-01 boot – as there is no esp-01 support code in the PSC function at the moment.  The CT for the PZEM just fits in the slot at the end.

Power Safety Cutoff with PZEM-004T electricity monitoringThe esp-01 is loaded with Tasmota, sensors version then plugged into the PSC.  it can then be configured via wifi.

I have the MQTT data going into InfluxDB and displayed using Grafana.  Nothing fancy.  These are still running on a Orange Pi board with a SSD.