Skip to content

Releases: Resinchem/TM1638-MQTT

Version 0.52

15 Oct 22:42
Compare
Choose a tag to compare

New Feature!

Blink LEDs

Adds a new /blinkleds MQTT topic. Issue the MQTT command with a payload of eight zeros or ones, where each position corresponds to the LED(s) to turn on and blink.

Examples:

  • payload: "01001010" - turns on and blinks LEDs 2, 5 and 7 (all other LEDs off).
  • payload: "00000000" - turns off all LEDs and stops blinking

Button 3 on the TM1638 has also be defined to stop the blinking and/or dismiss any lit LEDs when pressed. If you don't want to use button 3 for this (or wish to use a different button), see additional notes below.

The blink speed is set by a new Settings.h option, blinkInteval (see breaking changes below).

Breaking Changes

The update does require a change to the Settings.h file. There are two options for upgrading if you have installed a previous version:

  1. Download the new Settings.h file, open and re-apply your particular settings and options, such as pin assignments and any other things you changed from the prior versions like you did for the initial isntallation.

  2. Keep your existing Settings.h file and just add the following line to the end of the file:

    uint16_t blinkInterval = 1000;

Set the value of blinkInterval, in milliseconds, to control how fast the lights blink. The value is a 'half cycle'. In other words, if you set a blinkInteval of 1000 ms, the lights will be on for one second and then off for one second (techincally 2 seconds to complete the cycle). It is recommended that you don't set this value any lower than around 500 ms.

If you opt to use the second option and modify your existing Settings.h file (recommended), then you only need to download the new tm1638_mqtt.ino file below. Just replace your existing .ino file with the new one, recompile and upload to your controller via USB or OTA.

If you clone or download the .zip asset and have an existing installation, take care not to overwrite your existing Credentials.h file or you will need to re-enter all of your WiFi and MQTT information again. You can continue to use your pre-existing Credentials.h file with this new release.

Additional notes

If do not wish to use a button on the TM1638 to stop the blinking lights (e.g. dismiss an alert), just locate and comment out or remove the following two lines in the main loop:

   } else if (buttons == 4) {
      stopBlinking();

If you wish to use a different button, just change the number, but note that a button 3 press returns a value of 4... a button 4 press returns 8, etc. See the MQTT and Home Assistant section of the wiki for the values returned by the eight buttons. This step is completely optional.

Note that when the LEDs are blinking, setting of any individual LEDs (via /setled or /setleds) will be overwritten by the blinking LED routine. It is not currently possible to have some LEDs solid and other LEDs blinking. This might be possible in a later version.

All changes

Settings.h

  • Added new uint16_t blinkInterval setting (set with default value of 1000)

tm1638_mqtt.ino

  • Changed type of prevLEDs from byte to uint16_t
  • Added MQTT callback for new topic MQTT_TOPIC_SUB"/blinkleds"
  • Added new function, setPrevLightsHex(), to convert payload string to hex for blinking
  • Modified existing blinkLights() proc - prevously unused
  • Added new function, stopBlinking(), to stop blinking lights
  • Added code to main loop to use TM1638 button 3 to stop blinking lights (commented out)
  • Added code to main loop to call blinkLEDs if blinking turned on
  • Added section to button press logic in main loop to use button 3 to dismiss LEDs (and stop blinking)

Version 0.51

14 Oct 20:29
Compare
Choose a tag to compare

New MQTT Command: /setleds

This is still very much a work in progress!

It is also a bit of a manual setup and install process to get it on your ESP board. Please read the wiki for details and to assure a successful installation. Applying updates after the initial install are easier with the OTA functionality.

Added in this release:

New MQTT Topic: /setleds
Publish a payload of eight zeros or ones to turn the corresponding LED off or on. Note this is different than the current /setled (no 's' at the end) which is used to set a single LED to off or on.

Example:
Topic: cmnd/tm1638/setleds
Payload: "01001100"
(This would turn on LEDs 2, 5 and 6. All other LEDs would be set to off.)

Breaking Changes

None Just update your existing .ino file with the one in this release and load to your controller.

Version 0.50

14 Oct 15:55
Compare
Choose a tag to compare

Initial Release

This is still very much a work in progress!

It is also a bit of a manual setup and install process to get it on your ESP board. Please read the wiki for details and to assure a successful installation. Applying updates after the initial install are easier with the OTA functionality

The available MQTT topic set is also a bit limited in this initial release. I hope to continue to expand on this, so check back often for new releases and features.