The MemAnalyzer tool was not able to perform a proper analysis of the current builds, since we introduced the `USES_P001` syntax of defines to determine what should be included and what not.
Trying to reduce size of the compiled binaries by excluding certain parts of the code if not needed.
See definitions at the end of 'define_plugin_sets.h'
Currently done:
- Casting all controllers that are not included
- Casting all MQTT related code
- Casting all Domoticz related code
The last page of the wizard now shows the network info, just like in the sysinfo page and has a button at the bottom which links to the IP address of the node on the normal network
This last page of the setup also has the menu bar at the top and also the default template now shows a warning when you're connected via AP mode.
This allows for easier setup, since you don't have to switch networks anymore
Move WiFi/Network related functions into separate files to keep them organized and easier to locate.
Also added lots of comments and some documentation on the state machine handling WiFi connect and reconnects.
Simplified the WiFi connect state machine.
Fixed setup of initial WiFi configuration.
AP mode is now kept as long as client is connected.
AP mode will be started immediately if there are no valid WiFi credentials, or after 20 seconds of no wifi connection.
AP mode will be disabled 60 seconds after starting it, or after the last client disconnected from the AP.
This makes it easier to adapt settings, since platform and build_flags both depend on the same variable section.
Thus it makes sense to have them on consecutive lines.
Makes the rest of the decoder.js a lot simpler.
Also changed the GPS lat/long into 3 bytes again, saving 2 bytes in the packet length.
GPS outputs now 7 values using 18 bytes (incl. header)
This does allow uploading even more parameters than the 4 supported by ESPeasy, since encoder and decoder can be tailored to the specific plugin.
For example the GPS plugin can now upload 7 parameters in only 20 bytes.
Still to do: Why can the decoder not handle encoding per 24 bit? (lat/lon do fit perfectly fine in 24 bit).
For LoRa, it may take a while to send out samples of different plugins.
This makes it hard to match samples belonging to the same set after receiving them.
The Sample Set Initiator is a task index which should always be considered as the first of a set samples sent to the controller.
For example when triggering to send a set of samples from rules, its order can be always the same.
Setting the initiator to the first one of the sequence, the same sample set counter will be sent along with the samples.
Normally a controller uses a hostname or IP to connect to.
But a LoRa node does not connect to any specific host, but does broadcast messages using its own unique dev addr.
This will be shown as host description in the Controller overview page.
Move loading and saving of controller settings to separate functions per item.
Also string generation is now done in a function to keep internal strings in sync.
The flag to signal a successful boot was only set when there was a successful WiFi connection.
But this can lead to step by step disabling of plugins when the accesspoint is unreachable for a long time.
Some plugins and controllers were writing to TXBuffer.buf directly.
This should not happen, since then the memory usage of that buffer will increase and never decrease again.
Also C011 Generic HTTP advanced was not using existing functions for displaying config page.
The node delivering the data for a plugin is now shown on the device page in the "Port" column.
Also added a fix to only allow updates from 1 node to a remote node.
Previously it was possible to have several nodes writing to the same remote p2p shared plugin.
This could lead to very strange results.
This also means that a remote installed plugin must now be deleted and re-installed to allow receiving data from a remote host if the remote host unit id has changed.
For example a stream at 38400 bps can fill up the serial buffer over 27x a second.
This means that receiving data strings over 128 bytes (buffer size) may already be corrupted when reading at 10x a sec.
Just an initial skeleton to build the new Serial Proxy plugin.
It will fetch data and move it to a controller.
This will be the first plugin to handle something other than float values.
As described by @davidgraeff openHAB is supporting Home Assistant MQTT convention, so C005 should have Home Assistant in name.
Arguments:
openHAB is following HA convention
this will help new users (like me) to setup ESPEasy with Home Assisnant
Since there are not that much PRs open and in progress, this is maybe the least intrusive moment to cleanup some code using the given uncrustify.cfg
If there is a PR merge issue, checkout the PR and perform an uncrustify first before trying to merge.
The Dallas 1wire sensor can get into some error state.
To signal an error state, a NaN was ouput, but that may be hard to use in rules.
This selector allows to set a fixed value to signal an error state.
Also removed a lot of redundant code and make sure no data is shared among other active instances of the same plugin.
Auto gain will switch on/off the gain to extend the range of the sensor.
The 16x gain will be turned on below 10 Lux.
It will be off at 1/16th of the full range of the ADC.
On top of that there is also an option to extend the range of the sensor to about 130'000 lux.
The ratio ch1/ch0 will be stored as long as no ADC is clipping. This ratio will be applied to the measured ch1 (IR part) of the measured data when the ch0 value is clipping.
For example meauring direct sunlight may give upto 130'000 Lux of light intensity, but the sensor itself can only handle upto about 30'000 Lux without clipping.
Saturation level of the CH0 and CH1 ADCs is not at 65535 for all integration time settings.
For an integration time less than 178 msec, the max ADC value is less. This fix does detect those saturation levels.
The Uncrustify package in VS code does look in the project dir for a config file.
When it is present, there is hardly any configuration needed. Therefore I moved it and updated it a bit to behave more uniform than the cfg file we already had.
Just for testing/debugging purposes, the last executed task from the scheduled is logged into RTC memory.
This decoded string is also logged at boot and shown in the system info page.
It still demands quite some expertise to interpret but maybe we can find some pattern to where the crashes occur most often.
-Extended command example:
IRSENDAC,"protocol":"GREE","power":"off","mode":"heat","temp":21,"fanspeed":"max","swingv":"middle","swingh":"off"}
-Refactored and simplified code based on new libary updates
-1M IR build does not support Extended AC commands
-Usage instructions added
-Also added back the ability to have arbitrary bits to the IR send command. Reflected that also in the received signal decoding. Using 0 bits as an argument the ir send command will still use the default protocol bits
ref: https://www.letscontrolit.com/forum/viewtopic.php?f=4&t=6452&p=37373#p37373
Core 2.5.2 does contain a lot of fixes.
If this core version does seem to appear stable in the next few weeks, we will use it as the standard core for nightly builds.
Since Release mega-20190215, the plugin “ P065_DRF0299_MP3.ino “ wasn’t functioning on GPIO16.
With this small change, it’s operational once again and also available to connect other serial (non-critical) devices on GPIO16.
It is now possible to select different values for output.
A new output will be given when either the Interval time has passed, or a set minimal traveled distance is exceeded.
This can then be used in rules to trigger other samples.
There was still a hard-coded delay left in the process modbus command function.
Now it returns as soon as a valid reply is received.
This will make the PLUGIN_READ call of SenseAir S8 take 45.1 msec instead of 59.1 msec on average.
The calibration is now presented more clear.
Added an option to clear the logged data in the AccuEnergy sensor
Fixed an inconsistency in reported Watt and Wh.
Added display of imported/exported/net/total energy.
For example the SysInfo plugin should be made more flexible in the number of outputs.
Also the SenseAir plugin now supports multiple outputs to be able to get CO2 and sensor temperature for example. (temp reading is not yet correct)
Debouncing was no real debouncer before, this is fixed now.
Instead of setting a delay after a change occured during this the counter is "blind" the counter now waits for the next edge in the pulse signal and calculates then the time that the last state was active.
Only if the debounce threshold is exceeded the counter will be increased.
The SPIFFS may become fragmented, so it is possible a file cannot be appended to even though there is room on the file system.
So there has to be a proper check to see if writing fails and also delete oldest file(s) when needed + call to the garbage collector.
See also https://github.com/esp8266/Arduino/issues/5987
- hook for CPLUGIN_GOT_CONNECTED placed correctly
- hook for CPLUGIN_GOT_INVALID placed + added log
- fixed return values
- some log fixes
- cleaned up code
issues
I Think MQTTclient_should_reconnect=true does not reconnect if there is a working connection. In case of CPLUGIN_GOT_INVALID success a MQTTDisconnect(); function added.
The last read values were only saved when the device enters sleep mode, not when new values are read.
So after a reboot (as a result of a crash) the values were at their initial values.
P016_TIMEOUT is set now to 50 instead of 90 as a compromise between stability of decoding and accomodating large IR signals.
Also added breaks to mitigate unstability with long operations that might starve the ESP from backround tasks
Reverted and made compatible and optional the old style of the irsend command that supported also repeats
Both commands
IRSEND,NEC,ASDF123
and
IRSEND,NEC,ASDF123,0,0
will produce the same result.
to repeat the signal 1 time the command is
IRSEND,NEC,ASDF123,0,1
Create a much bigger CSV using 12*4 value columns with all labels on top.
6000 samples takes about 35 - 80 seconds depending on the number of 0.0 values (more zeroes, less time, smaller size)
The size of the CSV ranges between 900 and 2600 kByte for 6000 samples.
Export speed is 70 - 160 samples per second.
Calling `/dumpcache' will generate a CSV file of all logged data.
This may block the ESP for a while, since it outputs about 250 samples per second.
So 480'000 bytes of flash storage takes roughly 70 seconds to dump to a 1.6 MByte CSV. (20'000 samples)
Some settings have char arrays. Make sure these are 0-terminated when stored or loaded.
For example the ExtraTaskSettings were used without these checks
Use a state to process reading temp and hum or keep error.
The state is handled in the 10/sec call and when a new measurement is ready it will schedule itself to read the new values.
See #2407
There may be some unexpected responses after the reset.
So do not reset the sensor unless > 10 unknown responses were seen and also do not reset within 3 minutes after sensor reset.
Apparently the last update broke handling of unexpected response to commands.
According to the datasheet, the sensor should not give a response to some commands, but it does.
These responses should not lead to a reset of the sensor.
This will allow to reduce code duplication, reduce strings used in binary and makes code better readable.
This is a project which may take some time to cover all code.
Saves 20K of flash memmory. They provide no functionality other than giving log stirngs of that short:
"Mesg Desc.: Power: On, Fan: 5 (AUTO), Mode: 3 (HEAT), Temp: 22C, Zone Follow: Off, Sensor Temp: Ignored"
When using 'Oversampling' the Analog input plugin is simply summing all samples and upon calling the read function it will divide this sum by the number of samples.
This added filtering is keeping track of the lowest and highest value measured in this loop and excludes these extremes.
This makes the reading a lot more stable, since it is often only a single extreme value which causes noise in the reported values.
Also added a note to the setup page near the calibration points to make it easier to add calibration values. It shows the current raw value + its calibrated equivalent (if enabled).
Saves 20K of flash memmory. They provide no functionality other than giving log stirngs of that short:
"Mesg Desc.: Power: On, Fan: 5 (AUTO), Mode: 3 (HEAT), Temp: 22C, Zone Follow: Off, Sensor Temp: Ignored"
Eco mode will call delay() from scheduler during idle loops. (significant energy reduction of up-to 0.25 Watt)
WiFi_NONE_SLEEP will keep wifi on continously (max energy consumption)
Gratuitous ARP will be sent to keep the MAC tables in switches know about the MAC of the ESP node.
The interval for sending ARP messages is dynamic. The interval between these ARP's is increasing up-to 60 seconds interval, so we're not flooding the network.
But on some occasions this interval time is reset to 100 msec (and doubled each next interval step), so we're announcing ourselves a bit more often.
Known issue:
- WiFi always on does seem to miss some packets (unstable RF due to heat?)
- UDP packets sent for ESPeasy p2p do seem to be missed more often as soon as the power consumption of the node is actually reducing.
- Eco mode may take some time to actually reduce power consumption of the node. It is like the underlying core library is dynamically increasing/decreasing the power consumption of the node. (core 2.6.0, SDK2.2.1)
This will reduce the loop counter and even cause some inverse effect. Higher loop count means the node has more work to do (less scheduled tasks which are not yet due for work)
Initial tests show a significant lower power consumption and thus hopefully a more stable wifi connection.
The average used delay during idle calls can be seen in the timing stats (likely around 2.5 msec per idle loop)
The CPU load (in %) is still the same as before this patch, but the node feels a bit more 'snappy' and the extremes in the timing stats are lower.
In the backgroundtasks and also for a number of other network related operations there was no check for connectivity.
This could lead to various timeouts and maybe hanging processes. (Hardware watchdog resets)
Also:
- included core 2.6.0 alpha build with SDK2.2.1
- included core 2.6.0 alpha build with SDK3.0.0-dev
- Made memory size in bin filenames consistent (_4M instead of _4096)
- There were some unicode characters
- JPG file had wrong image type
- Documented the needed packages to build LaTeX documentation in Linux (still fails to build PDF dus to chapter count overflow)
load index.htm if it exists
If for some reason this is not working well (error in the index.htm) you can go to /filesystem
or /devices
or any other page, and it will load the old ui
Then go to /filesystem and delete index.htm
Core 2.5.0 is out, but this gives instability issues serving web pages.
For now the builds of core 2.5.0 are not included in the nightly builds until this is fixed.
The RX/TX pins are defined in the init. So no need to hand them to the begin function call again and set some default when not used.
This will lead to issues where the TX pin is not working when using HW serial.
Reading the sensor data will now only accept data starting with 0xFF.
This should improve reading stability.
Also added indicator showing checksum pass/fail and the model detected (MH-Z19 A or B)
Fixed several compile errors which occurs in case of active FEATURE_SD.
errors:
(1) #if with no expression
(2) converting to 'const String' from initializer list would use explicit constructor 'String::String(char)'
(3) no matching function for call to 'serialPrintln(uint32_t, int)'
The internal buffer was a char* array, but all it needed was just the same as being already available in the `String` class.
So it has been changed to be a String.
Not using the Plugin_task_data, since it is using interrupts and callback functions.
Not sure what will happen if we store these volatile variables in the same global array.
Exclude debug logs from C001, C002, C005, C008, C009, C013 and P001, P026, P033 which are compiled in by default in the PLUGIN_BUILD_MINIMAL_OTA set.
Reduces sketch about 1k.
Add BUILD_NO_DEBUG in define_plugin_sets.h to PLUGIN_BUILD_MINIMAL_OTA.
This makes commit #316691ad07731798687ada096907c5ccb61fb1b6 included and active in 1M minimal OTA build.
Decouple PLUGN_BUILD_MINIMAL_OTA in define_plugin_sets.h from other #defines in source code, otherwise either plugin set from Custom.h gets overriden by PLUGN_BUILD_MINIMAL_OTA from define_plugin_sets.h or #define's in code (eg. WebServer.ino) are not included.
Also name is misleading, as eg. WebServer is not a plugin..
- Call delay(0) unconditionally after plugin calls as they can take quie some time, even if they fail
- add some more log output in various places for WiFi info
- add some ()/{} to make groupings clear
- add all possible statuses in case statement after WiFi.begin() call
- test for layer 2 availability independent of valid IP (can happen that IP is still valid, but layer 2 is lost)
See:
- https://github.com/esp8266/Arduino/issues/2111
- https://github.com/esp8266/Arduino/pull/5395/files
Hopefully it will help for modules which have a hard time to connect to WiFi, which may be caused by weak power supply.
It will also not start unintended DHCP-client services which lead to strange issues when using static IP configuration.
Tests should reveal if it will also help to lessen the chaos which may happen now the 'May deal' is off, so please perform some tests and we'll see the coming days.
At least it will save some peak power at startup.
The internal buffer was a char* array, but all it needed was just the same as being already available in the `String` class.
So it has been changed to be a String.
Not using the Plugin_task_data, since it is using interrupts and callback functions.
Not sure what will happen if we store these volatile variables in the same global array.
See the defines in `_Plugin_Helper.h`
They were already used in some plugins, but now made globally available since they make the source much more readable.
You can now name the physical USB port names (ini file in settings folder).
You can now download (and unzip) directly from GitHub (small "update" button in top right)
You will now receive announcements about ESP Easy (opt out) if we push a message.
The 'old' limit of 4294 seconds was 2^32 usec.
By casting it to an uint32, you may get unexpected results when multiplying it by 10^6 again.
So better to use uint64 as variable and work on that one, now the deepsleep functions support uint64.
Make deepSleep work again with Core 2.5.0. Changed ESP.deepSleep() to ESP.deepSleepInstant().
Refactor delay variable to dsdelay to avoid conflicts with the delay() function.
Added a delay(100) before going to sleep to give the node time to send the last log messages.
Since these calls can be performed in sequences, the time of these calls can become rather large.
Every call returning success did something, so add a delay(0) after such a plugin function call to make sure background tasks are performed.
Add support for BL0937 to plugin _076_HLW8012
-Add possibility to set interrupt tigger for cf and cf1
Add possibility to set current reading state (low/high)
In order to get the build size down, a number of things had to be done:
- Removed notifications
- Reduce favicon.ico size
- Reduce flash string usage
- No SVG images on buttons.
Also made the OTA load button visible but disabled when OTA not possible.
See #2162
Also added a WROOM02 core 2.5.0 beta test build using the new 2M128k flash layout. (allowing OTA)
Using the new layout will remove any existing 2M1M layout.
This commit is to cherry-pick all fixes in the reverted commits to make future GPIO related fixes be as easy as possible.
These also contain small fixes which were in the reverted commits, but not really related to the issues for which this revert is meant.
This commit is to cherry-pick all fixes in the reverted commits to make future GPIO related fixes be as easy as possible.
These also contain small fixes which were in the reverted commits, but not really related to the issues for which this revert is meant.
Disabling dev/test builds for 1 MB chips, since the bin files will be too big to fit on 1 MB modules.
We have to decide later how to make the plugins in dev/test state available for 1 MB modules.
Implemented a GPIO timer for the scheduler to schedule a GPIO state change.
These will be stopped async:
- Tone > 50 msec duration
- Longpulse and longpulse_ms
Also implemented a frequency parameter for the `pwm` command.
See #2097
Timings are now less than a msec per iteration and interrupt driven.
Also settings are no longer saved every time the plugin gets initialized. (flash wear out)
A number of functions was given a String parameter as a deepcopy instead of a (const) reference.
This will use a lot more memory and time, where it isn't needed.
Also those deepcopy actions may fail silently and thus lead to crashes.
Since the `ESPEasyRules.ino` file is newly introduced in this branch, now is the best moment to tidy up the source code.
Also included the used Uncrustify.cfg file.
- Parsed commands or IR codes now only use amount of memory needed, no fixed allocation on the stack.
- Strings passed to functions via const reference instead of deepcopy
- Massive checks for brand name is now done on lower case, to improve speed.
See #2057
Currently this version works with P001 and P019.
Main changes:
Added a new command to SWITCH 001: unmonitor,pcf,port#
Added two new commands to PCF 019: monitor,pcf,port# and unmonitor,pcf,port#
Added two new http commands: monitor and unmonitor
Added a new rules command: logPortStatus that will print the port status
Added the "SafeButton" functionality to 001 and 019 that will avoid false positives
Added more checks to all commands in WRITE function to avoid possible overflows
Added two more PIN STATUS: OFFLINE and INPUT_PULLUP
Modified SendStatus function so that it will be called only when needed (#1593)
Redesign of the pinstate page
Optimized the WRITE function, changing the serie of 'if' with 'else if'
Split the plugin related substitutions into separate files (per 10) to speed-up building docs.
Please note the use of indirect paths used in includes, needed to link those replacements from other directories.
Sonoff POW build now is usable for both POW and POW r2.
Use the Reset Factory default to select proper pre-defined setup for keys and relay.
Both power sensors are included as plugin.
Problem appeared to be a stack overflow.
There were a lot of large arrays allocated on the stack to parse commands or their arguments.
These are now only temporary allocated and de-allocated as soon as possible.
Writing data to the serial port while it is not being read may cause all kinds of issues and maybe even Watchdog Resets.
All `Serial.print` and `Serial.println` calls in our own code is now sent to a dynamic buffer.
This buffer will try to only send data to the serial port when its buffer permits it.
After a while, unread data will be dropped.
- Replaced all <TH> with functions
- Optimized CSS (removed some errors too)
- Uniform rendering of pages (TH, width first column)
- Added some metadata to timing stats page
- Reduction in used flash strings.
Saving the settings file may sometimes take a few 100 msec.
Added a `delay(0)` per page written to make sure background tasks are dealt with.
These system background tasks should not perform writes to SPIFFS, so this delay should be fine.
For all other plugins not setting the GPIO labels, all are now added.
Also reverted the decision about RX/TX, since these are the only ones to be crossed, the rest is always describing the data on the sensor side.
"GPIO <-- TX" is rather descriptive. The GPIO is on the ESP side, TX is on the sensor side.
So the function to format the label is called `formatGpioName_RX` and it will write "GPIO <- TX"
At least it is clear where it is going to be used, it is the RX channel on the ESP side. (for example SoftwareSerial describes the pins with function on ESP side)
All custom GPIO labels (set using `PLUGIN_GET_DEVICEGPIONAMES` ) now use the same format.
It is now uniform to describe GPIO functions on ESP side.
It was quite a mixup of sensor pin descriptions and ESP side descriptions (e.g. mixup of RX and TX)
Now all descriptions show the ESP side description.
Make sure disconnects will not be missed.
Give background tasks more time when not connected to WiFi.
This may help lowering power consumption and improve chance of getting connected.
Add a System#NoSleep event which returns the amount of seconds fow which the unit will be awake (at least). However this time can change within the delay or even disabled (by rules, commands, etc.)
Amend system command "nosleep" to accept a parameter that sets the awake time (eg. nosleep for <time>).
like this it's possible to send a "nosleep" command to the unit immediately after it awakes, do whatever needed and then reset the awake time with "nosleep,<time>" instead of having to go via web-page.
- Fix for bug #1977 for serial and web sources
- Fix for Publish command not evaluating Formulas
- Fixed addlog commands only when needed
- Fixed logEntry command not showing command line
Fixed nit value of pinstate in P001, P009 and P019
Got rid of a few kB in the binary image by removing F-macro from numerous 1 or 2 character flash strings.
These very short strings take more space in flash and memory when using the F-macro.
Also appending to a string using a `'a'` character definition takes less resources compared to a one-character string `"a"`.
The (large) template string was reduced over and over again while parsing for strings to replace.
Now it is using one big string in memory which is not reduced. (and thus taking twice the amount of memory)
- ESP32 could not select GPIO-0 in plugins.
- Only usable pins will be selectable
- Arrow icon will show if GPIO is input or output only
- Added warning sign for pins affecting boot.
- Added RX0/TX0 indicator for GPIO-1 and -3 when serial is enabled.
- Added GPIO-1 and -3 to boot pin state setup, but only selectable when Serial disabled.
- Reduce number of flash strings.
Using 128k SPIFFS and 2-step OTA image, it is possible to perform an OTA update on 1 MB nodes.
This 2-step image does not have the ArduinoOTA service running, but does allow for manual upload using web interface.
ArduinoOTA needs 8 kB more, which will not work at the moment.
Define `GPIO_KEY1` containing GPIO number to get a pre-configured button input on factory reset.
Define `GPIO_REL1` containing GPIO number to get a pre-configured relay on factory reset.
When couple of `GPIO_KEY1` and `GPIO_REL1` is defined, a rule matching both will be added.
This is defined for 1...4
`delay(0)` is a special case of delay, which also calls the system scheduler, `yield()` does not call.
It may interrupt a bit more than `yield()`
See #1950
See #1910
Added a lot more of these changes and changed the input fields of the Notification Settings to be the same as all input fields in other places.
These char arrays were rather large, so allocate on heap instead of char[240] on the stack.
Also re-order elements in not stored structs to reduce memory usage
4 new system variables:
%iswifi% (=1 if wifi is connected)
%isntp% (=1 if NTP has been initialized)
%ismqtt% (=1 if mqtt is connected)
%ismqttimp% (=1 if mqtt import is connected)
Example:
if %isntp%=1 and %systime%>%sunset% do
....
endif
Lately a lot of new issues were non-descriptive and the same basic questions were to be asked over and over again.
These are now included in this template.
Started with this issue:
"Framed Oled Display mixing up multiple values in different lines" #1904
Now almost all calls to `strncpy` are replaced with this safe variant which does some checking and zero-ing the buffer.
Removed some unneeded stack allocations of 240 bytes in the rules processing.
Also gave the `process_system_event_queue()` a bit more priority to make sure it will be looked at at least once every 500 msec.
Add escaping of wifi network names that can be discovered using the search
functionality of for instantce the /setup page. As these names are also used
inside an html tag, a stronger html encoding variant has been added.
PlatformIO `espressif8266@1.7.3` instead of `espressif8266@1.8.0`
2.4.2 has a lot of improvements like 4k of extra free memory.
But also the number of hardware watchdog reboots has increased a lot and the PWM related code no longer seems to work on 2.4.2
So for now, back to 2.4.1 library.
Added DEBUG_LOG define to reduce info log messages and prevent serial log flooding.
Added SendStatus() to post log message on browser to acknowledge HTTP write.
Added reserve() to minimize string memory allocations.
Measuring unit can be changed bewtween metric/imperial
Filtertype can none or median. If median a filtersize can be set.
Meauring value time to distance conversion now as float division, resulting in a higher resolution output.
Apparently the settings are allocated on the system stack and not on the Arduino stack.
This means it takes a lot of ram when allocated on the heap. So move it back to the system stack.
Originally the Arduino stack was placed on top of the system stack.
But since the system stack is mostly empty, it was decided to shift the Arduino stack to overlap the system stack to save an extra 4k of memory.
However, since a lot of Watchdog timer reboots are reported lately, this optimisation will now be reverted to see if it will improve stability.
This will use about 4k more RAM.
there were several errors that all resulted in a distance value reading of 0. Added an errorState that is printed to the log and helps troubleshooting.
Max. Distance checking can be turned off by setting max distance to 0 cm. If max. distance is used, exceeding the range will return a distance of 0 cm and print this to the log.
the P_013_sensordef object was created on the stack and the destructor was called after leaving the PLUGIN_INIT. That deleted the included NewPingESP8266 object and using this object failed.
Enable RTOS flag in advanced settings (and reboot) to create separate threads on the 2nd ESP32 core, which will handle the scheduler.
This lowers stack usage and CPU load.
Also the ESP will no longer crash when saving large settings like for the Framed OLED plugin.
The last update to > 0.12 increased the binary size a lot. This is mainly due to the added BLE support.
This makes it almost impossible to use the default partition table layout.
This changes the app partitions to 1.8 MB and reduces the SPIFFS to 320 k.
Changing the partition table will clear all settings, so make a backup of the settings.
Also added all plugins that would compile (not tested) for ESP32.
Known issue:
ESP32 might crash due to stack overflow when saving settings of plugins. (e.g. OLED framed plugin)
Maybe a fix for #1525
Meant to be a fix for #1530
It looks like the MQTT broker is refusing to accept a new connection from a specific client ID, as long as the broker thinks a client with that ID is still connected.
This work around adds the number of wifi reconnects to the clientID, to make the ID unique when a reconnect has to be made.
MCP and PCF devices should be of type SWNSOR_TYPE_SWITCH instead of SENSOR_TYPE_SINGLE so that the controllers can identify them correctly as switches (for GPIO related functions)
The plugin still had some delay and an active polling to see if the reading was ready.
This took more than 1.5 sec per reading, which could trigger a Watchdog reset.
In addFormPinSelect move local variables from the stack to the heap
because when it is called from the P1WifiGateway there is not enough
stack space resulting in a stack overflow.
hi,
added 2 new operators for calculations:
!: Logical NOT:
returns 1 if operand is = 0
returns 0 if operand is != 0
%: MOD:
converts operands in integers and calculates the remainder of the division
When the node gets locked in a boot loop, the only recovery is to erase it and start all over.
This fix will count the number of failed boots and above a certain threshold it will start disabling plugin, then controller and then notification.
Only one will be disabled at once, so the user can see which one is giving issues.
The disabled state will not be saved, so make sure to save the failing part when it is accessible again.
Hi,
adding the possibility to have 3 parameters when calling an event:
event,eventname=p1,p2,p3
The variable name are:
param 1: %eventvalue% or %eventvalue1%
param 2: %eventvalue2%
param 3: %eventvalue3%
Added three new commands to toggle the pins from 0 to 1 or viceversa and to toggle the task value:
Command: taskvaluetoggle
P001: gpiotoggle
P019:pcfgpiotoggle
Hi,
here is a PR for using parameters when calling commands from inside the rules.
The scope is to be able to use formulas instead of an integer when calling a command inside the rules.
Example:
taskvalueset,1,%eventvalue%+65,[Relay1#r1]+1
Usage could be:
Assuming you have a PCF8574 with ports from 65 to 72.
You can write a rule:
on turnOnRelay do
pcfgpio,%eventvalue%+64,0
endon
And to turn on port65, the rule can be called like this:
event,turnOn=1
Write the log lines to a std::deque and write that buffer to the serial port without overflow of the Serial buffer.
This flushing is done during background task.
Depending on the type of controller, the queued messages can be quite big.
This means the queue limit set can cause the memory to fill up.
This commit adds another check. If the free memory is less than 5000 bytes, it will consider the queue being full.
It will then also log the actual memory usage of the queue.
`bla@bla.com` will be set as `nodename <bla@bla.com>` in the mail header as from part.
`John Doe <bla@bla.com>` will now be used like that in the mail header.
N.B. `<` is actually the separator, so as long as that character is being used to separate the name and mail address, it will work. (see #1714 )
Make sure only enabled devices are used for checking. (see #1702)
Do a full erase of the task settings when deleting a plugin. Just to make sure no obsolete settings may corrupt behaviour of new settings.
It looks like the check for `client->connected()` may return false positives.
This means the MQTT client may assume the connection is still active, while it isn't.
These structs to keep track of available plugins and controllers were fixed in size and also the member variables were not ordered in the most optimum way.
Also the name of the nodes always used 26 Bytes and would impose a memory leak when deleted.
As suggested here: https://github.com/letscontrolit/ESPEasy/pull/1669#issuecomment-414434578
This plugin is not using the Queue yet, but only had some duplicate code moved to a helper class.
I now removed the port number from the HTTP header, since I am not really sure if the standard demands it or only for the connect part.
Also changed the HTTP command to use the code that has the port in the header, just to check if that will break now compared to older builds.
Added some simplifications to the code by creating one big macro in `_CPlugin_Helper.h` that does all the work and defines.
This will reduce the chance of typo errors a lot.
MQTT messages are queued and processed at set pace to not overload the broker.
N.B. other controllers still need a similar queue to process. Current interval for those is now probably too low.
Also initial queue parameters must still be corrected when set to 0.
For example `%syshour%` to `%syshour_0%`
Both variables are now supported.
The ones without leading zero can be used in rules.
The ones with leading zero will probably be used on displays.
At this moment it is just using the same static configuration as P150 from the playground.
It is not yet using the settings. This will have to be changed later on.
As a NTP client, you don't need to send requests from port 123. Some internet providers even block ports below 1024. So try to use a random port for outgoing requests.
Also added some checks and increased buffer on the receiving end of UDP packets.
When using C013, the size of infoStruct is copied from that buffer and the size is about 137 bytes, which may lead to Exception crashes.
Add a duplicate call for changing the address. This is required by the new sensor firmware version 2.6. This is to avoid a stry address change command that happens during hotplugging of the sensor
also see here: https://github.com/Apollon77/I2CSoilMoistureSensor/pull/17
Scheduled commands are blocking when run all after another at highest priority.
This removes the scheduled commands from the scheduler and the scheduler will now process the next queued command when no other scheduled task has to run.
Also made some optimizations to reduce memory usage.
Controller C011 (Advanced HTTP) uses all of the available `ExtraControllerSettings`.
Now the last byte of those arrays is set to 0, just to make sure they will not read beyond the range of those arrays when using as a string.
The controller still causes crashes, bit it is a start.
New timing was only allowed after MessageDelay seconds. (default was 1000, which is about 20 minutes)
It should use `TaskDeviceTimer`.
BME280 can now schedule itself to perform a read-update as soon as a measurement has completed.
Then it schedules itself to perform a new measurement at set interval time.
When sending command request from the Tools tab in the web interface, the command will be executed immediately.
In other situations it will use the scheduler to run commands async.
Commands will now be buffered and processed in order.
This will also speed-up rules which do a publish.
- Save RAM, move constants to flash (CharTableTM1637, CharTableMAX7219)
- Remove unnecessary parameter passing (the interface pins do not change during operation for one instance)
The existing implementation was a bit sparse in returned info.
Now each command can return a useful string to display in the command output window in the webinterface. (or whatever the source of the command is)
Servo Motors by default forcefully hold the desired position. This consumes power. In some cases for example to turn a value or open a latch once the position is set there may be no need to hold the new position. With this update users can pass a special case value above >9000 which is out of normal range 0-180 or 365. when this value is passed the servo is detached and is free to move.
We need to find the xth command, so we need to find the position of the (X-1)th separator.
Too bad the rest of the world (other than programmers) do not start counting at 0 :(
Apparently it is called 1.4 million times in 30 seconds and takes 8.5 CPU cycles on average (about 50'000 calls per second)
So maybe this function can benefit from some optimisation?
All enabled plugins have their own timer added to the scheduler.
The `PLUGIN_INIT` function call is used to reschedule when it was added, or enabled.
The set interval for the plugin will be used to set the new entry in the scheduler.
And fix longpulse command
With other plugins active, like the OLED Framed, the set period of `longpulse_ms` may fluctuate and durations below 100 msec are quite useless.
However, when running just a few sensors, the set pulse width is quite accurate.
Must still check a few other plugins.
`%sunrise%` and `%sunset%` were already available.
Now it is also possible to get some time before or after those times.
For example `%sunrise+10m%` or `%sunset-1h%`
The offset must be an integer (including + or -) and can have a postfix of "m" or "h".
Default is "s", for seconds.
some code rearrangements and improvements:
- fix a rare buffer overflow
- only update variables when new (correct) values are received
- little speed-up
- correct code indentations...
`ParseString` and `getParamStartPos` made (lots of) copies of the strings.
Also the result of `getParamStartPos` was not checked, which can result in crashes.
As being described a few times and a screenshot shown here: https://github.com/letscontrolit/ESPEasy/issues/1302#issuecomment-393631572
It looks like a DHCP request may fail resulting in a cleared IP setup. The web server then still replies to requests, but no new connections can be made then.
This patch should detect such a situation and then reset the wifi and make a new connection.
The lookup of a function call based on a command string is known at compile time, so no need to keep track of this in memory.
This saves about 2200 bytes of RAM.
The strings alone account for close to 800 bytes (not using F() macro) and they are also being stored in the map.
So that's about 1600 bytes.
The extra 400 bytes are probably the pointers being stored in the map.
For .h files, it is common practice to add #ifndef #def statements around the implementation to prevent compiler issues when a file might be included twice.
VScode + PlatformIO needs the monitor_speed setting to be able to monitor the connected node. (default 9600 baud)
Also set the ESP8266 code base to 1.7.2
This plugin works on my test setup for more than 6 months and is by far the most stable node. (system uptimes of > 110 days)
So this may be considered stable.
The Json data has more items at the level of `data.Sensors[c]` thus must check if it is a TaskValues item.
Otherwise the values shown on Device page will not be updated.
With the newer Platform IO versions, builds failed because of wrong size set in board definition of ESP8285 board.
The PlatformIO settings labels have changed.
A failing ping may also halt the ESP node and some services may not return a ping, or ICMP packets may be filtered out on some connections.
See issue #1494.
Ammended central I2C functions with 16bit write and 32 bit read.
also added "false" parameter to wire.endTransmission before wire.request form
all as discussed in #1417
The plugin BMx280 can handle BMP280 and BME280.
The BMP version has no humidity sensor.
For Domoticz you have to send the data formatted differently.
Now the same plugin can be used for both BME280 and BMP280 and the settings in Domoticz can be set accordingly.
Previously the I2C registers containing measurement data was read per address at once.
Now all are read in one I2C command and then processed.
Also changed the source to be able to support multiple instances of the same task.
This should also fix #1381.
There is something strange about the handling of micros() timers in `NewPingESP8266`.
For this reason I added also a timeout based on `millis()`.
Adding an existing and proven I2C library.
Will need to test if this is working fine on ESP32 too and try to move I2C functionality to use these functions.
In order to semplify the setup of new units, I have added the following commands for modifying settings though serial port:
gateway (x.x.x.x)
dns (x.x.x.x)
subnet (x.x.x.x)
dst (0 or 1)
mqttretainflag (0 or 1)
messagedelay (ms)
ntphost (url)
timezone (minutes)
udpport (port number)
usentp (0 or 1)
work in serial and rules
Suppose you have two oled task with name FrontPanel and BackPanel. If you want turn off FrontPanel and print on BackPanel "Hi" at posintion 0,0 you must use the following instructions:
frontpanel.oledcmd off
backpanel.oled 0,0,Hi
if task name have space you must surround with square brackets. es: [task with space].oledcmd off
The /json page now also supports a limited view for the device page sensor updates.
The supported URLs for the json page are:
- `/json` All information in JSON format.
- `/json?view=sensorupdate` Limited view only for auto update on Devices tab.
- `/json?tasknr=N` with N being the task number, just outputs the information for the given task number.
N.B. these parameters can be combined, like: `/json?tasknr=1&view=sensorupdate`
Not sure how, but the headers of new JSON message can corrupt the buffer in the web log buffer.
In this attempt the log buffer lines are now moved to heap instead of stack.
Also the streaming webserver is given a bit more time to handle requests.
Steps to reproduce:
Set web log level to maximum and open web log viewer.
Then wait a few seconds to minutes to let the JSON stream stop and look at the last sent Json message. This will contain some typical Json web headers and thus no valid Json anymore.
Also added a quick fix for #1419
Previously I thought the body wasn't working correctly in email, however it was, with the exception of line breaks for text/html that have to be rewritten.
In communicating with the server, the sender and receiver needed to be surrounded by <> to be RFC2821 compliant.
The message body was coming out blank as an empty string was being sent instead of the correct string.
New Transformations:
#H: Hot/Cold
#A: Man/Auto
#a: M/A
New Justifications:
#Lx: Left (x=number of chars)
#Rx: Right (x=number of chars)
#Ux.y: Substring (x=first char; y=number of chars)
Plugin_041_update was being called before the plugin has been initialized, this resulted in an exception 28 type crash. Plugin_041_update clears the display and isn't required at the time of webform save.
This one is not yet complete, way more features and improvements are coming.
But for now it is already much much better than the old log viewer :)
So I'll merge it now and we'll see what it will become.
See #1351
Whenever a plugin_write returns success = true, the execute command will no longer be called.
It doesn't matter whether the plugin is enabled or present.
It should only return success = true when the command was actually meant for this plugin.
Previously the moment a timed function was called, the new timer was set. That would make the timer interval to be the minimum interval, with quite some margin of error.
Now the timers are at a more strict interval, unless the device cannot keep up.
See #1296
Rules got truncated when trying to save rules > 1520 Bytes.
Also added a bit more log information and some details about the used libraries in the sysinfo page and json output.
The reason is that inside PLUGIN_WRITE the variable [event->BaseVarIndex] is not set and is always = 0.
So actually this PR modifies the 1st value of task 1 and not the encoder counter.
Line 183 of P059_Encoder.ino should be removed:
UserVar[event->BaseVarIndex] = (float) event->Par1;
Apparently static IP needs to have IP config set before and after connection has been made.
The beginning is needed to make sure no DHCP client is started.
The second one is needed to make sure the wifi status is correct in the core library.
Many self compilers are reporting stuff, it's near to impossible to also support these since the different environments are so hard to set up for us developers to test.
I noticed that my latest commit introduced a small issue with Transformations:
The previous transformations were right justified. The new ones are left justified.
To maintain backwards compatibility I have modified the code.
- Reset wifi when DNS lookup returns *.0.0.0 (NTP lookup sometimes returns like these)
- Accept Wifi events out of order.
- Remove CRC from settings struct
- Patch settings with last few added items initialized
- Changed red question mark to white questionmark, for links to wiki.
Add core information to the log and info page
Add "more info" button to main page
Add question mark link button to sysinfo section describing wifi. This links to the wifi page on the wiki.
Message is sent to provide feedback on pressing the 'submit' button.
At that moment, it is not yet clear the data will be saved successful.
To prevent "Settings Saved" and "Error writing to..." to show on the same page, this text was changed.
See [this bug report](https://github.com/esp8266/Arduino/issues/4114), which is not fixed in 2.4.0.
This work-around will make sure no dhcp-client will be started when connecting to a network.
The active DHCP client could result in IP conflicts, difficulty in reconnect and other strange issues.
Sending LOG_LEVEL_ERROR as syslog error, LOG_LEVEL_INFO as syslog notice, and everything else as syslog deug
Also added Settings.Syslogfacility setting to be able to choose kernel (still default), user, daemon, message and local0-local7
Added Nextion plugin for testing from the Playground.
It is not yet tested on real hardware, but it has been in development for a while on the forum and playground.
Also requested in issue #1256 and by several others.
When a fixed IP setting is used, there will be no "Got IP" event, which will lead to a timeout and thus reconnect.
As a fix, the "Connected" event will also act like when a "Got IP" event was received when configured to use static IP.
A lot of issue reports do not include information about the used version of the core libraries and 'normal', 'dev', etc.
Since this information helps narrowing down the possible causes of the reported issues, it is best to add them in the general log.
I finally have one node acting as described by others and this one reported a disconnect before a connect attempt was made.
Now forcing the wifi in STA mode, should resolve this issue.
WiFi persistent settings were disabled after initialisation of the event handler.
This allowed the firmware to start WiFi connection with settings stored in the flash (not our settings, the settings kept by the core library). If these fail, then a connection failed event would occur before a connect attempt was started from ESPeasy, which would lead to strange results on some nodes while others work just fine.
A lot of functions in Webserver.ino were just appending to a ever increasing string. These strings were eventually sent to TXBuffer of the Webinterface.
So why not directly send them to the streaming buffer and thus reduce memory usage and gain speed.
A lot of functions in Webserver.ino were just appending to a ever increasing string. These strings were eventually sent to TXBuffer of the Webinterface.
So why not directly send them to the streaming buffer and thus reduce memory usage and gain speed.
The settings had 2 new values which would be overwriten by the checksum and there was still some issue about when to save the settings.
Also added a check to only save changed settings.
Known issue:
Sometimes after initial setup of wifi credentials, it is best to perform a reset.
Still existing problems:
- Credentials are not being saved from web interface and thus connection doesn't work from setup page.
- First time connect to SoftAP takes a lot of attempts, when the wifi was searching for an existing accesspoint. This searching does prevent the SoftAP to form a stable connection to the client.
Maybe the entire wifi stack has to be reset before switching to SoftAP. Now it is near to impossible to recover from incorrect settings or a changes accesspoint.
Still under investigation.
It looks to be a problem with the
Since event based wifi, it became more apparent the ESP8266 has some issues with running AP and STA mode simultaneous.
It appears this can only work when the channel remains constant. But when trying to connect to an accesspoint that channel will change.
This means Soft AP and STA cannot be active at the same time when searching for an accesspoint to connect to. For example login to the Soft AP to correct some settings or replace an accesspoint would not be possible.
This fix deals with all of these issues and keeps the fast try/fail connection attempts offered by the event based wifi.
In short:
- 3x attempt to connect to AP1 (each attempt takes about 2.5 seconds when failing)
- 3x attempt to connect to AP2
- Enable accesspoint
When accesspoint is active, the connect attempts will be done at a slower pace and STA mode is disabled. STA mode is also disabled as soon as someone connects to the Soft AP.
When the settings are saved, a retry to connect like normal is started almost immediately. N.B. This will result in a disconnect of the connected users to the Soft AP.
So the connection time is:
- AP1 is valid: 4 - 10 seconds
- AP1 is not valid, AP2 is: 12 - 20 seconds
- AP1 and AP2 are not valid: +/- 18 seconds before activating Soft AP
Since event based wifi, it became more apparent the ESP8266 has some issues with running AP and STA mode simultaneous.
It appears this can only work when the channel remains constant. But when trying to connect to an accesspoint that channel will change.
This means Soft AP and STA cannot be active at the same time when searching for an accesspoint to connect to. For example login to the Soft AP to correct some settings or replace an accesspoint would not be possible.
This fix deals with all of these issues and keeps the fast try/fail connection attempts offered by the event based wifi.
In short:
- 3x attempt to connect to AP1 (each attempt takes about 2.5 seconds when failing)
- 3x attempt to connect to AP2
- Enable accesspoint
When accesspoint is active, the connect attempts will be done at a slower pace and STA mode is disabled. STA mode is also disabled as soon as someone connects to the Soft AP.
When the settings are saved, a retry to connect like normal is started almost immediately. N.B. This will result in a disconnect of the connected users to the Soft AP.
So the connection time is:
- AP1 is valid: 4 - 10 seconds
- AP1 is not valid, AP2 is: 12 - 20 seconds
- AP1 and AP2 are not valid: +/- 18 seconds before activating Soft AP
In Deepsleep mode the wifi connect time is now minimum of 6 seconds.
Also the first loop after connect, the 'awake' timer will reset and start over. Without WiFi connection the set 'awake' timer starts at the moment the node boots.
While looking for issues regarding DeepSleep + MQTT and issue #1195, I came across a number of other issues related to high CPU load and WiFi disconnects when a MQTT controller cannot reach the MQTT broker or is set to be no longer enabled.
These fixes improve CPU load and WiFi stability and also send the following events:
- `MQTT#Connected`
- `MQTT#Disconnected`
- `MQTTimport#Connected`
- `MQTTimport#Disconnected`
The MQTTimport plugin still has some major issues which have to be taken care of, so #1195 is not fixed yet.
There is a problem with the PlatformIO builder since the last update of @mvdbro
It's an issue with the parsing of `#ifdef ESP32`.
It is very well explained here: [platformio/platformio-core#801 (comment)](https://github.com/platformio/platformio-core/issues/801#issuecomment-252447178)
In short, the event handling functions for the wifi have been moved to a separate .h file, since those files will be parsed properly by the Library Dependency Finder (LDF) in PlatformIO 3.x
While looking for issues regarding DeepSleep + MQTT and issue #1195, I came across a number of other issues related to high CPU load and WiFi disconnects when a MQTT controller cannot reach the MQTT broker or is set to be no longer enabled.
These fixes improve CPU load and WiFi stability and also send the following events:
- `MQTT#Connected`
- `MQTT#Disconnected`
- `MQTTimport#Connected`
- `MQTTimport#Disconnected`
The MQTTimport plugin still has some major issues which have to be taken care of, so #1195 is not fixed yet.
* Initial re-organisation of plugin sets (#1019)
* 12bit ADC values acceted up to 4095
MCP3221 is a 12bit ADC so accepted values should be up to 40195 not 1024
* automaticly updated release notes for v2.0-20180313
* - move all structs from ESPEasy.ino into header file
- add some fix for headers
- add const to rtttl notes array
* [issue #1066] Fix Webserver handle_control
There wasn't a proper start/end for the streaming webserver.
See discussion on issue #1066
* automaticly updated release notes for mega-20180314
* Custom controller GUI option
* Fixed #433
Not tested!
* #893, part 2 receiving
* Merge branch 'mega' of github.com:letscontrolit/ESPEasy into mega
# Conflicts:
# src/ESPEasy.ino
* Rules fix
* #893 part1, send messages
* Custom controller GUI option
* #893, part 2 receiving
* Rules fix
* automaticly updated release notes for mega-20180315
* - move all structs from ESPEasy.ino into header file
- add some fix for headers
- add const to rtttl notes array
* Merge branch 'mega' of github.com:letscontrolit/ESPEasy into mega
# Conflicts:
# src/ESPEasy.ino
* [v2.0 split globals] Base split on v2.0 version of ESPEasy.ino
* MCP3221 allow values for calibration (#1073)
MCP3221 allow values for calibration
* [issue #1066] Fix Webserver handle_control (#1079)
[issue #1066] Fix Webserver handle_control
* Fixed multi instance problem on SHT3x #433 (#1081)
Fixed multi instance problem on SHT3x #433
* [issue #1057] AM PM display issue
X:XX PM (for hours 1...9)
X:XX AM (for hours 1...9)
XX:XX PM (for hours 10...12)
XX:XX AM (for hours 10...12)
Added for H:MM (without seconds) notations:
- `%systm_hm%`
-`%systm_hm_am%`
* [issue #993] variable in MQTT subscribe topic
As [noted](https://github.com/letscontrolit/ESPEasy/issues/993#issuecomment-373140135) by @kluszcyn
* [issue #951] Changed System#Initialized => System#Wake
Changed System#Initialized => System#Wake
New event name makes more sense and Initialized may be used later to indicate all needed connections, etc. are ready.
* [issue #1057] AM PM display issue
X:XX PM (for hours 1...9)
X:XX AM (for hours 1...9)
XX:XX PM (for hours 10...12)
XX:XX AM (for hours 10...12)
Added for H:MM (without seconds) notations:
- `%systm_hm%`
-`%systm_hm_am%`
* [issue #993] variable in MQTT subscribe topic
As [noted](https://github.com/letscontrolit/ESPEasy/issues/993#issuecomment-373140135) by @kluszcyn
* [issue #951] Changed System#Initialized => System#Wake
Changed System#Initialized => System#Wake
New event name makes more sense and Initialized may be used later to indicate all needed connections, etc. are ready.
* automaticly updated release notes for mega-20180316
* automaticly updated release notes for v2.0-20180316
* Add download button for current rule set
* - add encoder write #1086
* changed memory tracker to uint64_t for the ESP32
* Changed so that running all tasks immediately with deep sleep enabled only happens on first iteration after wake up
* Keep uint. Just change the init value.
* [WiFi] Try to minimize effect of WiFi interruptions
And send event when connected to a different accesspoint.
Currently the impact on WiFi reconnects is enorm. The ESP stalls, won't react on events, etc.
* - fix success setting
* - fix P073 success setting in PLUGIN_WRITE callback
* - initialize pointer in P073
* [Relaxed WiFi] Perform WiFi initialization in steps
Doing WiFi initialization in multiple steps, will reduce boot time a lot.
For deepsleep the Setup is waiting for wifi initialization to complete, but for normal use the wifi connection is initiated during setup and checked on regular intervals to see if it is available.
The same for WiFi reconnect, which will hopefully not affect the performance of the ESP module during reconnects.
Also added a check + event when connected to another accesspoint with different BSSID (MAC address of accesspoint). Also the last used BSSID is used to reconnect to try to connect to the same device over and over, which may be useful with WiFi repeaters.
* [Travis error] Some #include test that wasn't meant to be included
... in the commit.
* [JSON] Add uint name (#1099) and WiFi information (PR #1113)
As suggested by @Grovkillen on PR #1113.
* [issue #1007] Allow user specific data in separate file
File will be ignored by git and can be simply included using `-D USE_OWN_DEFAULTS` in the build
* #ifndef instead of #ifdef
* [issue #1007] Add other defines as suggested by @uzi18
* [Memory] parseTemplate did not check if markers were found
"Free Mem" reported this function to be using quite a lot of memory.
Maybe that was related to parsing texts without matching ']' or '#'
Just added some checks to see if they were found.
* [issue #1097] MQTT publish after deep sleep
The MQTTConnect was only called after a while. This is a problem for deepsleep.
So now the MQTT connect is done at the first loop when deep sleep is enabled.
* Add download button for current rule set (#1102)
Add download button for current rule set
* - add encoder write command #1086 (#1103)
- add encoder write command #1086
* Changed so that running all tasks immediately with deep sleep enabled… (#1110)
Changed so that running all tasks immediately with deep sleep enabled only happens on first iteration after wake up
* Merge pull request #1112 from uzi18/fix-p073
Fix p073 - #1111
* Merge pull request #1114 from TD-er/feature/wifi_details_json
[JSON] Add uint name (#1099) and WiFi information (PR #1113)
* Merge pull request #1113 from TD-er/feature/reduce_impact_wifi_disconnect
[Relaxed WiFi] Perform WiFi initialization in steps
* Merge pull request #1116 from TD-er/feature/allow_own_defaults
[issue #1007] Allow user specific data in separate file
* Merge pull request #1118 from TD-er/bugfix/mqtt_publish_after_deep_sleep
[issue #1097] MQTT publish after deep sleep
* [merge] MIssing #endif due to merging.
* automaticly updated release notes for mega-20180319
* automaticly updated release notes for v2.0-20180319
* Fix wiring description for SN75176 transceiver
* Revert "Merge pull request #1116 from TD-er/feature/allow_own_defaults"
This reverts commit 8ccbdcadf0.
* Fix wiring description for SN75176 transceiver
* Revert "Merge pull request #1116 from TD-er/feature/allow_own_defaults"
This reverts commit 8ccbdcadf0.
* [issue #1097] WiFi connect with deepsleep enabled trigger watchdog reset
Did not allow for enough time to do background tasks while waiting for wifi connect with DeepSleep enabled.
* [issue #1097] WiFi connect with deepsleep enabled trigger watchdog reset
Did not allow for enough time to do background tasks while waiting for wifi connect with DeepSleep enabled.
* automaticly updated release notes for mega-20180320
* automaticly updated release notes for v2.0-20180320
* [wifi] Setup with factory settings could not complete
* [wifi] Setup with factory settings could not complete
* [merge issue] Forgotten #endif in merge
* - P012 fix command interpretation
* - P023 fix command interpretation
* - P035 move strings to flash
* - P048 fetch params only when needed
* automaticly updated release notes for mega-20180321
* automaticly updated release notes for v2.0-20180321
* Serial WD crash
* [wifi] Make more robust checks and increase timeout
See #1145
* - P012 fix command interpretation
* - P023 fix command interpretation
* - P035 move strings to flash
* - P048 fetch params only when needed
* Serial WD crash
* [wifi] Make more robust checks and increase timeout
See #1145
* [Memory] parseTemplate did not check if markers were found
"Free Mem" reported this function to be using quite a lot of memory.
Maybe that was related to parsing texts without matching ']' or '#'
Just added some checks to see if they were found.
* [WiFi] Take much more time for initial WiFi connect during setup
Accesspoint is still active, so it may take a lot more time to make the initial connection
* [WiFi] Take much more time for initial WiFi connect during setup
Accesspoint is still active, so it may take a lot more time to make the initial connection
* automaticly updated release notes for mega-20180322
* ESP32 fix
* [Command] Parsing improvement for commands
Use more intelligent parsing of commands and switch statement to improve speed
* automaticly updated release notes for mega-20180323
* [WiFi] Reverted those temp String uses for ssid/pass
Was introduced due to misunderstanding of reported issues with WiFi.
* [issue #1131] Add %unixtime%
Show the current time as [Unix time](https://en.wikipedia.org/wiki/Unix_time) (numbers of seconds that have elapsed since midnight 1970-01-01, UTC)
* [issue #1097] Call MQTTclient.loop() during deepsleep
The `MQTTclient.loop()` function should be called quite often.
This does the actual MQTT handling.
In normal operations, this is called quite frequently, but it should also be called when deepsleep is active and right before deepsleep is activated again.
* [P1] Support for latest standard
* [wifi] Event based connect/reconnect
Now using the core WiFiEvents to act on:
- connect
- disconnect
- gotIP
This will make polling for a status no longer needed.
It also allows to get a better understanding in why diconnects happen, since the disconnect reason is given in the events.
This extra information is also present on the information panel on the webinterface and also in the JSON output.
The entire connect/disconnect/reconnect is now done completely asynchronous and thus takes much less resources from the ESP.
A disconnect will now also send an event: "WiFi#Disconnected"
For deepsleep this means there has to be a minimum awake time set and perhaps use rules to set the ESP into sleep again when done.
Typical connection times to an accesspoint are about 3 seconds + about 1 second for DHCP.
This also resolves the issues where services my try to connect while there is a WiFi connection, but not yet an IP address set.
I already noticed a lot of NTP servers from pool.ntp.org are non responsive the last few weeks, so that may still take some time, but that's another issue.
* automaticly updated release notes for mega-20180324
* [NTP] Speedup NTP again with async WiFi
Previously it would only start calling "now" when the WiFi was already setup.
And in calling `now()`, a call to an NTP server is being made. When this fails, retry again in a minute.
But now the WiFi initialization is asynchronous, so the first NTP query was already failing and thus the retry is already set to a minute.
This is fixed now and also the pool.ntp.org will pick a random one from 0...3 (.pool.ntp.org).
The DNS queries from this pool change about every minute, so if you want to retry because one of the servers is offline, you should try one from the other `N.pool.ntp.org` or else you have to wait for another minute.
* - fix for #1170 - uservar not setted on encwrite
* automaticly updated release notes for mega-20180326
* [issue #1174] Show degree sign via external writes to LCD
Fix suggested by [elmicha](https://github.com/letscontrolit/ESPEasy/issues/1174#issuecomment-376244766)
* [ESP32] Event driven WiFi for ESP32
Not tested, just got some inspiration by these files:
- https://github.com/espressif/arduino-esp32/blob/master/libraries/WiFi/examples/WiFiClientEvents/WiFiClientEvents.ino
- https://github.com/espressif/arduino-esp32/blob/master/libraries/WiFi/src/WiFiGeneric.cpp
- https://github.com/espressif/arduino-esp32/blob/master/tools/sdk/include/esp32/esp_event.h
* automaticly updated release notes for mega-20180327
* Fix nesting level check
* [Build] Cleanup/split builds using defines
See PR #1034 and #1040 made by @soif
* [build] Disabled a few PlatformIO profiles for now.
There were way too many.
Just placed them in comments and Travis had already built them all to test first.
* automaticly updated release notes for mega-20180328
* [Arduino IDE] Revert changes in include paths
Were changed to be able to test the PlatformIO feature to compile only files that are actually used.
Apparently the Arduino IDE cannot find the files anymore because that IDE needs the parent directory to be named as the main project file, not "src"
* automaticly updated release notes for mega-20180329
Were changed to be able to test the PlatformIO feature to compile only files that are actually used.
Apparently the Arduino IDE cannot find the files anymore because that IDE needs the parent directory to be named as the main project file, not "src"
Previously it would only start calling "now" when the WiFi was already setup.
And in calling `now()`, a call to an NTP server is being made. When this fails, retry again in a minute.
But now the WiFi initialization is asynchronous, so the first NTP query was already failing and thus the retry is already set to a minute.
This is fixed now and also the pool.ntp.org will pick a random one from 0...3 (.pool.ntp.org).
The DNS queries from this pool change about every minute, so if you want to retry because one of the servers is offline, you should try one from the other `N.pool.ntp.org` or else you have to wait for another minute.
Now using the core WiFiEvents to act on:
- connect
- disconnect
- gotIP
This will make polling for a status no longer needed.
It also allows to get a better understanding in why diconnects happen, since the disconnect reason is given in the events.
This extra information is also present on the information panel on the webinterface and also in the JSON output.
The entire connect/disconnect/reconnect is now done completely asynchronous and thus takes much less resources from the ESP.
A disconnect will now also send an event: "WiFi#Disconnected"
For deepsleep this means there has to be a minimum awake time set and perhaps use rules to set the ESP into sleep again when done.
Typical connection times to an accesspoint are about 3 seconds + about 1 second for DHCP.
This also resolves the issues where services my try to connect while there is a WiFi connection, but not yet an IP address set.
I already noticed a lot of NTP servers from pool.ntp.org are non responsive the last few weeks, so that may still take some time, but that's another issue.
The `MQTTclient.loop()` function should be called quite often.
This does the actual MQTT handling.
In normal operations, this is called quite frequently, but it should also be called when deepsleep is active and right before deepsleep is activated again.
"Free Mem" reported this function to be using quite a lot of memory.
Maybe that was related to parsing texts without matching ']' or '#'
Just added some checks to see if they were found.
The MQTTConnect was only called after a while. This is a problem for deepsleep.
So now the MQTT connect is done at the first loop when deep sleep is enabled.
"Free Mem" reported this function to be using quite a lot of memory.
Maybe that was related to parsing texts without matching ']' or '#'
Just added some checks to see if they were found.
Doing WiFi initialization in multiple steps, will reduce boot time a lot.
For deepsleep the Setup is waiting for wifi initialization to complete, but for normal use the wifi connection is initiated during setup and checked on regular intervals to see if it is available.
The same for WiFi reconnect, which will hopefully not affect the performance of the ESP module during reconnects.
Also added a check + event when connected to another accesspoint with different BSSID (MAC address of accesspoint). Also the last used BSSID is used to reconnect to try to connect to the same device over and over, which may be useful with WiFi repeaters.
And send event when connected to a different accesspoint.
Currently the impact on WiFi reconnects is enorm. The ESP stalls, won't react on events, etc.
Changed System#Initialized => System#Wake
New event name makes more sense and Initialized may be used later to indicate all needed connections, etc. are ready.
Changed System#Initialized => System#Wake
New event name makes more sense and Initialized may be used later to indicate all needed connections, etc. are ready.
According to the MH-Z19B data sheet version 1.2, valid from: 2017.03.22 (received 2018-03-07), the offset should be [6]..[7] instead.
Fixing the implementation accordingly.
Changed the sleep checkbox to allow a number of seconds awake from deep sleep.
Also added the following events:
- MQTT#Connected
- WiFi#Connected
- System#Initialized
- Time#Set Time set by an update from NTP.
- Time#Initialized Time set for the first time since boot.
- Login#Failed
See #951
Changed the sleep checkbox to allow a number of seconds awake from deep sleep.
Also added the following events:
- MQTT#Connected
- WiFi#Connected
- System#Initialized
- Time#Set Time set by an update from NTP.
- Time#Initialized Time set for the first time since boot.
- Login#Failed
See #951
Also made some clean-up of calls to string replacements.
Improved the lookup function to determine the wind direction (was 11.25 degree off)
Now it is also possible to add simple standard conversions like Celcius-Fahrenheit, m/s - Beaufort, etc.
_P072_HDC1080 add success and break statement.
it seems that without the break statement and success set to true, the values aren't sent back to the controller(s).
_P072_HDC1080 add success and break statement.
it seems that without the break statement and success set to true, the values aren't sent back to the controller(s).
* - pcfgpio,port,2 sets pin as input
- fix for #222,#702 - we can mix inputs and outputs now
* - extend conditions with AND/OR, now it is possible to simplify rules
test rules:
on test do
if [test#a]=0 or [test#b]=0 or [test#c]=0
event ok
else
event nok
endif
endon
on test2 do
if [test#a]=1 and [test#b]=1 and [test#c]=1
event ok
else
event nok
endif
endon
on test3 do
if [test#a]=1 and [test#b]=1 or [test#c]=0
event ok
else
event nok
endif
endon
on test4 do
if [test#a]=0
event ok
else
event nok
endif
endon
* - remove Serial print
* - add format #O to templates to show OFF/ON instead 0/1 - eg.: Pump:[Outputs#pump#O]
* - add formating for active low outputs eg.: #O!
- Use peek instead of read, to make sure a complete packet is in the buffer.
- Flush buffer after processing a packet.
- Increased software serial buffer to the size of 3 packets.
- Peek (+ read garbage) 10 times per second to get the buffer in sync to start with start byte of packet.
- Decent delete + clean up of software serial allocation when changing settings (prevent memory leak)
- Move log String allocation to inside scope of function, not permanent allocated.
- Split into separate functions to make it better readable.
* - pcfgpio,port,2 sets pin as input
- fix for #222,#702 - we can mix inputs and outputs now
* - extend conditions with AND/OR, now it is possible to simplify rules
test rules:
on test do
if [test#a]=0 or [test#b]=0 or [test#c]=0
event ok
else
event nok
endif
endon
on test2 do
if [test#a]=1 and [test#b]=1 and [test#c]=1
event ok
else
event nok
endif
endon
on test3 do
if [test#a]=1 and [test#b]=1 or [test#c]=0
event ok
else
event nok
endif
endon
on test4 do
if [test#a]=0
event ok
else
event nok
endif
endon
* - remove Serial print
* - add format #O to templates to show OFF/ON instead 0/1 - eg.: Pump:[Outputs#pump#O]
* - add formating for active low outputs eg.: #O!
* - fix #964, add timeStringToSeconds and use it to compare time conditions
* - fix number of pages available to browse
* - pcfgpio,port,2 sets pin as input
- fix for #222,#702 - we can mix inputs and outputs now
* - extend conditions with AND/OR, now it is possible to simplify rules
test rules:
on test do
if [test#a]=0 or [test#b]=0 or [test#c]=0
event ok
else
event nok
endif
endon
on test2 do
if [test#a]=1 and [test#b]=1 and [test#c]=1
event ok
else
event nok
endif
endon
on test3 do
if [test#a]=1 and [test#b]=1 or [test#c]=0
event ok
else
event nok
endif
endon
on test4 do
if [test#a]=0
event ok
else
event nok
endif
endon
* - remove Serial print
* - add format #O to templates to show OFF/ON instead 0/1 - eg.: Pump:[Outputs#pump#O]
* - add formating for active low outputs eg.: #O!
* - pcfgpio,port,2 sets pin as input
- fix for #222,#702 - we can mix inputs and outputs now
* - extend conditions with AND/OR, now it is possible to simplify rules
test rules:
on test do
if [test#a]=0 or [test#b]=0 or [test#c]=0
event ok
else
event nok
endif
endon
on test2 do
if [test#a]=1 and [test#b]=1 and [test#c]=1
event ok
else
event nok
endif
endon
on test3 do
if [test#a]=1 and [test#b]=1 or [test#c]=0
event ok
else
event nok
endif
endon
on test4 do
if [test#a]=0
event ok
else
event nok
endif
endon
* - remove Serial print
* - add format #O to templates to show OFF/ON instead 0/1 - eg.: Pump:[Outputs#pump#O]
* - add formating for active low outputs eg.: #O!
* - fix #964, add timeStringToSeconds and use it to compare time conditions
* - fix number of pages available to browse
* - pcfgpio,port,2 sets pin as input
- fix for #222,#702 - we can mix inputs and outputs now
* - extend conditions with AND/OR, now it is possible to simplify rules
test rules:
on test do
if [test#a]=0 or [test#b]=0 or [test#c]=0
event ok
else
event nok
endif
endon
on test2 do
if [test#a]=1 and [test#b]=1 and [test#c]=1
event ok
else
event nok
endif
endon
on test3 do
if [test#a]=1 and [test#b]=1 or [test#c]=0
event ok
else
event nok
endif
endon
on test4 do
if [test#a]=0
event ok
else
event nok
endif
endon
* - remove Serial print
* - add format #O to templates to show OFF/ON instead 0/1 - eg.: Pump:[Outputs#pump#O]
* - add formating for active low outputs eg.: #O!
See #922 and #847
Problem with DNS resolve is that it is quite slow when resulting in a failure and it tends to keep the ESP occupied and make it unresponsive.
Changed the way it is connecting to a controller.
Not sure if http requests are still OK, maybe we should make an exception for those when selected to use DNS.
* - pcfgpio,port,2 sets pin as input
- fix for #222,#702 - we can mix inputs and outputs now
* - extend conditions with AND/OR, now it is possible to simplify rules
test rules:
on test do
if [test#a]=0 or [test#b]=0 or [test#c]=0
event ok
else
event nok
endif
endon
on test2 do
if [test#a]=1 and [test#b]=1 and [test#c]=1
event ok
else
event nok
endif
endon
on test3 do
if [test#a]=1 and [test#b]=1 or [test#c]=0
event ok
else
event nok
endif
endon
on test4 do
if [test#a]=0
event ok
else
event nok
endif
endon
* - remove Serial print
test rules:
on test do
if [test#a]=0 or [test#b]=0 or [test#c]=0
event ok
else
event nok
endif
endon
on test2 do
if [test#a]=1 and [test#b]=1 and [test#c]=1
event ok
else
event nok
endif
endon
on test3 do
if [test#a]=1 and [test#b]=1 or [test#c]=0
event ok
else
event nok
endif
endon
on test4 do
if [test#a]=0
event ok
else
event nok
endif
endon
* preparations for lwip2
* Add CRC32 to settings
* Add CRC to progmem
* Add crc of program memory to stettings and security settings
.. so that there is a warning if the settings are used by another binary than they were written with.
* Moved to md5
* Flash included, moved to MD5 now
* Broken comment
* Stability improvements
free memory went as low as 3000 bytes which made the webserver unresponsive.
* Add binary filename to crc2.py and sysinfo
* Update WebServer.ino
* Updating template structure, adding viewport meta name for mobile devices, feature ready for responsive layout
* Adding meta viewport, feature ready nad support for mobile devices, responsive layout, update template structure, adding article html5 tag, easier to style interface, find/replace uppercase to lowercase, matter of elegance and preference code readability :-)
* revert to default state and change only template related lines
* final check, revert uppercase
* Last template changes, lost in undo process :-)
* h6 footer TR
* [isue #877] Add VCC enable firmware file to release list
Added one for the testing build.
Not sure if we should add one for every build, since these flags will lead to an explosion of release versions.
But at least we will test builds with FEATURE_ADC_VCC define enabled more often.
* Add define FEATURE_ADC_VCC to the PUYA build
Since it is so hard to make a puya version on your own.
* [issue #890] Split overlap for both Domoticz controllers to helper
Both Domoticz controllers had quite some overlap in code.
And where they differ, one of them was faulty and/or already fixed.
Now this overlap is split into a Domoticz helper file to keep code duplication to a minimum.
* [issue #890] Fix some wierd data corruption
Do not store references in a Json object, but just the string :)
* [Domoticz] Add WiFi strength and battery info
%mac% will be replaced by the MAC-address of the ESP board.
%mac_int% will show the integer representation of the last 24 bits (MAC address without the OUI part) for use in rules.
* [issue #847 ] OpenHAB MQTT rewrite topic parser
When OpenHAB MQTT controller was selected, the web interface becomes unresponsive when the controller tab was selected.
Also the ESP almost freezes when MQTT messages were sent.
This is an attempt to make them work faster.
Also a lot of string manipulation, copies and resizes are now no longer needed and the received values are checked to be valid int or float before used.
* signed unsigned warning
* [issue #869] Added 'LWT' to last will topic and improved CPU load
See #869 for discussion on Last Will Topic.
Also changed the way it tried to reconnect to make it return a lot faster when connection is not (yet) possible and call the PubSubClient::loop() at a much slower pace to reduce CPU usage. (See #847)
This higher CPU load was probably introduced when fixing #683.
* [MQTT] Fix error reporting success status with longer payloads
Applied PR https://github.com/knolleary/pubsubclient/pull/360/files
* made MQTT_CALLBACK_SIGNATURE for esp32 functional
Applied PR https://github.com/knolleary/pubsubclient/pull/336
* [issue #853] Favicon.ico
Added a very small favicon.ico of the ESPeasy logo. (1150 Bytes, 16x16)
* [Favicon] Added instructions to change icon.
In the comments. Just use 'xxd' from the (Linux) commandline.
First attempt, not clear yet how to detect it.
See #866
Also preparation for future improvement on logging. (to detect whether there is some logging active so Strings may not have to be prepared.
* update Blynk controller
- use of real controller index
- we use idx
- check if password not empty
- use real password
* fix for Blynk Controller
- use of real controller index
- we use idx
- check if password not empty
- use real password
- use proper port
* Update _C012.ino
add SENSOR_TYPE_SWITCH support
* [v2.0] Blynk controller
* fix for Blynk Controller
- use of real controller index
- we use idx
- check if password not empty
- use real password
- use proper port
* Update _C012.ino
add SENSOR_TYPE_SWITCH support
- on 2.4.0 git /low mem LWIP ram goes never below 20k, during TX core dives down to 18,7k (each main menu clicked once, plain new config.)
- Fixed json output
- cleanup of send function#
- un-split css, transfer to buffer byte by byte (prevents 1.7k temporary string)
- removed commented-out function
Recent changes in 'early exit' when not connected, triggered lots of retry events.
Added some function to allow to wait for WiFi and in the meantime do some background tasks.
See #825
Added option for controllers to change their display string on some controller fields in the web interface.
When password field label is non-default it also implies to use a visible textfield instead of a password field.
Re-implementation of PR #482 which was done on Mega branch.
Just to keep merges simple between branches. (and improve readabilit)
Also added a simple check to C005 (OpenHAB MQTT) on receiving messages. (see #847 )
* [OLED] Move font to oled lib dir
It is specific for use wth that library.
* [OLED framed] Stop reading from flash constantly and live update WiFi
See #857
The OLED Framed plugin was reading from spiffs all of the time (on every display update)
Now the data is only read from SPIFFS when needed.
Also made the WiFi strength indicator update every second (only when changed) to be able to see changes in WiFi status much easier.
* Update Library LiquidCrystal_I2C to the latest version
* Fix LCD command (when message is longer than columns) that get split into the wrong lines - issue #603
* Added a "LCD command mode" parameter to handle how exceeding message would be treated, and if the line should be first padded with space.
It was causing issues when people upgraded from previous builds.
Leaving it would cause high CPU loads, instable wifi, and incorrect set switch type when upgrading from older builds.
Only thing is when people were using it as a dimmer and used one of the builds in the last few weeks.
Then it will be used as a 'switch', not a dimmer. Change and set and all is fine again.
* [issue #839] Add command support for setting contrast for OLED Framed
See #839
* [issue #839] Should not use 0 as off value, since that is default
With 0 as "off", the display would be off when not set.
Changed it to 1, which is not a value that can be set other than with the commands
* Blynk controler (re-implementation of PR#92)
See #92
This plugin is just ported from the old implementation, which was not merged into the Mega branch.
It now is using a lot of the newly created functions and optimizations.
But not yet tested.
* Update _C012.ino
memory never goes below 10k now.
Added wait for memory return on header send,
Added wait for memory return on chunk end send,
removed duplicate of data stashing with getWebPageTemplateVar
See #727
And it only took 4 bytes extra storage :)
When initialized with an invalid setting for DST, (like fresh after flashing), it will use the CEST/CET setting.
* [issue #817] Added mail header to SMTP
N.B. use only mail address (no name, no '<>' etc) as sender.
* [SMTP] Add user/pass to send email.
* [issue #817] Added user + passwd authentication to SMTP notifications
Tested with smtp2go.com (non TLS mail proxy)
It is now possible to add username + passwd when sending mail.
If both left empty, authentication will not be used.
As part of #698 and also since these system variable replacement may grow.
Some replacement strings may need some work to create and such effort is wasted if the matching string does not occur.
To improve this and still remain readable, I added a simple macro to check first and then create the strings only when needed.
Some strings are already present, so these do not use the macro since searching first and then look again to replace will take more effort.
* [#784] Add %rssi% as system variable
See #784
* [#787] Add %unit% and %ssid% system variable
See #787
Unit is the unit number of the ESP device.
SSID is the name of the WiFi accesspoint the ESP device is connected with.
* [issue #740] Allow MQTT controller to be on any controller
See #740
Still there is an issue when >1 MQTT controller is selected and enabled.
Currently only one MQTT controller may be active.
* [issue #740] Add warning when >1 MQTT controller is active
Add a warning to the web interface when >1 MQTT controller is active.
See #740
* [Mega] Force 2.3.0 for all builds and add an option for 2.4.0 core
This way we can test issues easier and people are still using 2.3.0 core version.
* Update platformio.ini
Environment labels should not use dots. Then they will not show in the build selection box.
* [V2.0] Allow IRremoteESP8266 to be build with core 2.4.0
A partial cherrypick of #772, to make merging easier.
Just some simple patches on the use of min() and max() in the library to allow it to compile using the 2.4.0 core lib. Actual use of this core lib is still prohibited by the check in ESPEasy.ino.
* [core 2.3.0] Force PlatformIO to use the 2.3.0 core libs
This update forces the PlatformIO environment to load the 1.5.0 version of espressif8266@1.5.0, which uses Core 2.3.0
Last few days, lots of issues reported by users who installed the 2.4.0 core libraries.
e.g. #769 and #763
It appeared the default PlatformIO Espressif 8266 1.6.0 libs now include the 2.4.0 core libraries.
Now I have to find a way to get my own environment back to the 2.3.0 core libs and see how I can get PlatformIO Espressif 8266 library back to version 1.5.0
* preparations for lwip2
* Add CRC32 to settings
* Add CRC to progmem
* Add crc of program memory to stettings and security settings
.. so that there is a warning if the settings are used by another binary than they were written with.
* Moved to md5
* Flash included, moved to MD5 now
* Broken comment
* preparations for lwip2
* Add CRC32 to settings
* Add CRC to progmem
* Add crc of program memory to stettings and security settings
.. so that there is a warning if the settings are used by another binary than they were written with.
* Moved to md5
* Flash included, moved to MD5 now
* Broken comment
* preparations for lwip2
* Add CRC32 to settings
* Add CRC to progmem
* Add crc of program memory to stettings and security settings
.. so that there is a warning if the settings are used by another binary than they were written with.
* Moved to md5
* Flash included, moved to MD5 now
* Central function for system variable replacement
Related to:
- #698 => Not complete
- #709 => fixed
- #751 => fixed
Redesign of PR #485 (in mega branch)
One note: no sensor values can be used in controllers. Is this what we want, or should we call parseTemplate everywhere parseSystemVariables is being used?
Also not all controllers apparently allow system variables. Is this also correct?
* [issue 757] Add %lcltime% to display date + time
As requested by @PsychoAndi at PR #757
* [issue 757] Add local time to JSON output
As suggested by @PsychoAndi
See #728
Also looked into the very strange configuration settings lookup for MQTT settings. The way it was, the settings for the first MQTT controller were used even when the actual MQTT controller was inactive or using different settings.
Now the controller selected in the the plugin is being used and when no plugin setting is available (and also for P037 MQTT import) the first active MQTT controller will be used.
* removed note for 74HC595
74HC595 pin reminder not needed as this chip won't be supported anymore
* deleted GPIO notes referring to 75HC595 not supported
* [Time] Moved time related code to separate file
* [AutoDST] Added Auto DST
Preliminary support for Auto DST, as requested in #569
Also did a little refactorin of time related code, with #698 in mind.
All time related code is split into a few files based on its function.
The currently selected DST will start on Last Sunday March 2am and end on Last Sunday October 3am.
This is the most frequently used DST, according to https://en.wikipedia.org/wiki/Daylight_saving_time_by_country
To change it, currently the code has to be changed in the function applyTimeZone(). Several examples are given right below that function.
Problem is where to store the information of the timezone, how to use it in the web interface and how convenient it is to set by hand.
The UTC offset in minutes still has to be entered and whether or not DST should be enabled.
Prevent sending of invalid values (NaN, inf) to any controller.
Simple test is to output any plugin value with formula set to "%value%/0" and try to send it to any controller.
Is a fix for #470 and #693
* [switch] Fixed switch behavior and default settings. (#675)
As described in #673 .
The problem was partly related to the default values stored in flash ("0"), which was not a valid value for the switch type.
When upgrading from an older version of ESPeasy, make sure to check the switch type (normal switch or dimmer) and save the settings for the switch device again, even when nothing was changed.
Default configuration and new added switches will now work like intended.
When a controller is enabled (e.g. Domoticz MQTT or -HTTP) and the button is pressed multiple times, the ESP may reboot. See issue #674.
* ABC calibration feature added (#606)
* [Flash info] Detailed flash information (#678)
Last few days a number of issues and forum topic was about the type of flash used on the ESP boards.
This is an extension of the detailed information page.
Perhaps also merge with the newer and more clear layout of pull request #624?
That pull request was only merged to the mega branch.
I kept the changes local, but perhaps they should be placed in the "Storage" section introduced with #624.
Maybe also that pull request should get merged into the v2.0 branch.
* Bugfix/v2.0 crash switch (#682)
* [crashes] Added constructors to initialize all members in structs
Numerous structs are defined, but none of them have default constructors and there is no guarantee the members will be set when used.
With these default constructors, the parameters at least have an initialized value.
* [PubSubClient] Add bound checks on the internal buffer
Not sure if this was really causing an issue, but proper bound checks are always a good thing.
* [Crash Switch] Disabled delayBackground and added yield() calls
Something really fishy is going on with the delayBackground function, which will result in crashes when pressing the switch multiple times, with Domoticz MQTT enabled as first controller.
Disabled for now and delay(1) added to give background tasks a chance to do their work and make sure the watchdog doesn't perform a reset.
* [CI build errors] Commented out some unused variables
Travis considers them as error and fails the checks.
* [CI check] Out-of-bounds check fix
* actually ignore MQTT messages that are too big.
* moved mqtt stuff outside of backgroundtasks(). fixes #683 in my test scenario
* [Adafruit MPR121] Change deprecated name setThreshholds to setThresholds (#685)
See #684
* fixed plugin id of "Communication - Kamstrup Multical 401". (accidental octal notation)
* changed devicecombobox handling to save a lot of memory on device page. fixes #654#676 and could be triggered by #683 in some cases.
* [CPPcheck] v2.0 ControllerSettingsStruct some variables not initialized (#692)
Fixing these cppcheck errors:
101.43s$ cppcheck --enable=warning src/*.ino -q --force -I src --include=src/ESPEasy.ino --error-exitcode=1
[src/ESPEasy.ino:500]: (warning) Member variable 'ControllerSettingsStruct::HostName' is not initialized in the constructor.
[src/ESPEasy.ino:500]: (warning) Member variable 'ControllerSettingsStruct::Publish' is not initialized in the constructor.
[src/ESPEasy.ino:500]: (warning) Member variable 'ControllerSettingsStruct::Subscribe' is not initialized in the constructor.
Fixing these cppcheck errors:
101.43s$ cppcheck --enable=warning src/*.ino -q --force -I src --include=src/ESPEasy.ino --error-exitcode=1
[src/ESPEasy.ino:500]: (warning) Member variable 'ControllerSettingsStruct::HostName' is not initialized in the constructor.
[src/ESPEasy.ino:500]: (warning) Member variable 'ControllerSettingsStruct::Publish' is not initialized in the constructor.
[src/ESPEasy.ino:500]: (warning) Member variable 'ControllerSettingsStruct::Subscribe' is not initialized in the constructor.
* [crashes] Added constructors to initialize all members in structs
Numerous structs are defined, but none of them have default constructors and there is no guarantee the members will be set when used.
With these default constructors, the parameters at least have an initialized value.
* [PubSubClient] Add bound checks on the internal buffer
Not sure if this was really causing an issue, but proper bound checks are always a good thing.
* [Crash Switch] Disabled delayBackground and added yield() calls
Something really fishy is going on with the delayBackground function, which will result in crashes when pressing the switch multiple times, with Domoticz MQTT enabled as first controller.
Disabled for now and delay(1) added to give background tasks a chance to do their work and make sure the watchdog doesn't perform a reset.
* [CI build errors] Commented out some unused variables
Travis considers them as error and fails the checks.
* [CI check] Out-of-bounds check fix
Last few days a number of issues and forum topic was about the type of flash used on the ESP boards.
This is an extension of the detailed information page.
Perhaps also merge with the newer and more clear layout of pull request #624?
That pull request was only merged to the mega branch.
I kept the changes local, but perhaps they should be placed in the "Storage" section introduced with #624.
Maybe also that pull request should get merged into the v2.0 branch.
As described in #673 .
The problem was partly related to the default values stored in flash ("0"), which was not a valid value for the switch type.
When upgrading from an older version of ESPeasy, make sure to check the switch type (normal switch or dimmer) and save the settings for the switch device again, even when nothing was changed.
Default configuration and new added switches will now work like intended.
When a controller is enabled (e.g. Domoticz MQTT or -HTTP) and the button is pressed multiple times, the ESP may reboot. See issue #674.
* [SDS011] Add send commands to sensor
In the library used to communicate to the SDS011 sensor was only support to receive data from the sensor and not query the sensor or set another mode.
This is needed for #499 , to let the sensor sleep.
N.B. code is not yet tested, only implemented while reading the datasheet "Laser Dust Sensor Control Protocol V1.3"
* [SDS011] Lessen load on ESP by polling less frequent and use SoftSerial
The default setting were to set the delay to 0 and use an own software serial implementation.
This caused frequent timeouts on the web interface, WiFi reconnects, etc.
Now the already present SoftSerial is being used. This will gather all the data from the serial port and thus there is no need to poll 50 times a second.
Now the ESP is much more responsive.
* [SDS011] Allow the sensor to sleep to extend sensor lifetime
The internal laser of the SDS011 only will last for about 1 year when ran continuously.
When the RX of the sensor is connected, it can be set to sleep for N minutes between measurements. This will extend the lifetime of the sensor and reduce power consumption.
This sleep time is stored inside the flash of the sensor, so it can be set once and then the RX on the sensor could be disconnected again to be used for other purposes.
As discussed in pull request #629 and the new issue #658 and also on https://github.com/knolleary/pubsubclient/issues/375
In short, the PubSubClient does not store the domainname used to connect to, but only a pointer to the string.
However, PubSubClient should not expect this pointer to remain valid, since it is outside its scope. So PubSubClient should keep the domainname stored in its own variables.
This fixes the problem where the MQTT broker is no longer reachable after a while when using DNS instead of IP.
* initial support for TSL2591 sensor
* return lux, visible, ir and full light separately
* better plugin init
* check sensor initialization before reading it..
* incorporated a few pending fixes for the adafruit library
* minor typo
* [mega] Detect client IP for SysInfo page and some cleanup
Added formatIP functions for readability and add client IP to SystemInfo page as preparation to detect origin just to get an idea of possibilities for #647.
Also added some reserve() statements to Strings to prevent heap fragmentation.
* [mega] Cleanup formatIP calls
* [security] #647 Add IP filtering to web interface and commands
As discussed in #647:
In the Config tab, a "Client IP filtering" section is added.
This allows for 3 levels of IP filtering:
* "Allow All" - does not imply any filtering based on IP address of the client.
* "Allow Local Subnet" - Allow only clients from within the local subnet, based on IP and subnetmask of the ESP.
* "Allow IP range" - Allow only clients within a range of IP-addresses.
Settings like these are very likely to lock out the rightful owner, so there are also two commands added, which can be sent via the serial connection.
* accessinfo
* clearaccessblock
The first one just displays the current active IP filtering.
The "clearaccessblock" command will temporarily disable the access filtering. This allows the user to login and reset the access filtering.
"Allow Local Subnet" is set as factory default.
Only when first loading a new firmware with this feature and existing configuration, the "All Allowed" is active (the old default)
* [DNS/IP] Obey UseDNS setting for all controllers
As described in #381#261 and #521
A first attempt to let all controllers use the same logic to connect to external hosts.
* [WiFi] Avoid timeouts when not connected to WiFi
As discussed in #589
Stil needed to actively disconnect network services when network was disconnected.
* [WiFi] Actively ignore network services when disconnected
All controllers now stop sending when WiFi disconnected.
Also add NTP update directly after connection was made.
Delay with waiting for unavailable network is now about 30 seconds, then normal boot continues. Every 60 seconds the WiFi will be polled again.
* [time overflow] Use separate function to compute time differences
As discussed in #594
The timeOut() function had already a remark that it was behaving fishy.
It is now split into a timeDiff function and two convenience functions:
- timeOutReached
- timePassedSince
The timeDiff function may be a bit more elaborate than strictly needed, but it is very important to do it right and the original notation was very hard to read and understand.
Almost all locations in the code where millis() was used to compute a time difference or check for timeouts now use these functions.
Potentially all of these locations could cause issues when the timer wraps.
* [time overflow] Fix for a one-off error
2^31-1 can be casted to a long value.
Thus changed "<" into "<="
* [addLib] Added SoftwareSerial library
Added latest version from: https://github.com/plerup/espsoftwareserial
* [renLib] Renamed files to avoid conflicts with existing code
* [renLib] Changed include according to rename
* [renLib] Renamed all occurences and includes and removed unused pins
Renamed to make sure all plugins use the 'new' ESPeasySoftwareSerial.
Also added pinToIndex function to reduce memory footprint with about 150 Bytes, as described in issue #630
* [unused pins] Adjust indices in object list
Forgot to change the indices in the object list of SoftwareSerial
* Simple patch for timeouts
As mentioned in this issue: https://github.com/plerup/espsoftwareserial/issues/54
* [SoftSerial] Set ObjList static
Set the object list static to share all SoftwareSerial iRAM used as described in #630
* [revertLib] Revert to old version lib, since new version uses more iram
Just to test with old version, originally available in 2.3.0 library, to see if memory usage improves.
* [test] Reduce number of ports to 1 and lower buffer size to 18 for MHZ19
Just as a test, to see what happens to the iRAM usage, lower the number of concurrent softserial ports to 1.
Also the default buffer size = 64 Bytes. The MH-Z19 sensor can do with less, since a response will be up to 9 bytes, a 18-byte buffer allows for 2 messages to be stored.
* Enable usage of up to 10 concurrent softserial and reduce variable sizes
Re-enable use of up to 10 concurrent software serials.
Also reduce the variable sizes to smaller ranges. (e.g. uint8 instead of int)
* [test] Limit number of concurrent software serial devices
Earlier tests show the amount of iRAM used is somewhat related to the maximum number of allowed software serial ports.
In this test it is set to 3 and they are assigned through first come first served a slot.
* Optimisation: save RAM.
* Another RAM optimisation (freeing RAM by moving static data from RAM to program memory).
* Fixing user-visible typos.
* Fixing typos in variables and comments.
* Fixing typos in comments.
* Revert changes of other pull request.
The system variable %ip% truncates the last octet or so when printed on small displays. Now there are four new variables %ip1%, %ip2%... so that the octet printout can be distibuted across two lines.
Possible fix for #581.
Just looking at the description of the problem, this may be causing the crashes,since the commands may be trying to dereference the LCD pointer while it still is NULL.
Cppcheck warned for 'suspicious code':
[src\_P039_Thermocouple.ino:254]: (warning) Suspicious code: sign conversion of -1 in calculation because '-1' has a negative value
I agree with cppcheck that the code is at least suspicious and probably compiler dependent.
So in order to let cppcheck no longer output a warning and make it a bit more readable, I made this change.
Also added logs to indicate errors reported by the sensor.
Possible fix for #581.
Just looking at the description of the problem, this may be causing the crashes,since the commands may be trying to dereference the LCD pointer while it still is NULL.
* [SSD1306] Upgrade library to version 3.0
The library at https://github.com/squix78/esp8266-oled-ssd1306 has to be initialized differently in version 3.0
Known issue: The font for 3 lines is not working, so temporary used the same font as for 4 ilnes. The online font generator is currently unavailable at http://oleddisplay.squix.ch/
* OLED framed improve header footer
The header now has better visible WiFi bars indicator and alternates the device name and the connected WiFi SSID.
The bottom part now only shows dots for the pages with visible data instead of the maximum number of pages possible.
* [SSD1306] Upgrade library to version 3.2.7
Forgot to commit deletion of obsolete files in previous commit.
* [SSD1306] Added 12pt font for version 3.x of the library
The font generator is online again: http://oleddisplay.squix.ch/#/home
Added Dialog Plain 12 font for the 3-line display mode.
* [OLED_Framed] Allow to use either SSD1306 or SH1106
The new OLED library allows to use SH1106 and SSD1306 controler.
Added support for both with an selector to select the available controler.
* [OLED_Framed] Only destruct and construct display object when changed
* [OLED Framed] Add contrast setting to display
Both SSD1306 and SH1106 support setting the contrast.
* Update _P036_FrameOLED.ino
* [MH-Z19] Allow for B-version and add filtering
The "B" version of the sensor does not output an S value, but does internally apply a dynamic response filter on the samples based on the amount of fluctiation in the data.
The implemented filter does something similar for the "A" version and for both adds the option for an extra delay filter to smooth the data.
Default filter setting ("off") is the old behavior, where only stable values are allowed.
* [MH-Z19] Improve label texts and logging
The first commit for the filtering had some confusing text labels.
Also it would be nice to see the effect of filtering in the logs.
Retaining will messages allows monitoring agent to receive full info about clients state.
Without retaining, the monitoring agent will only be informed about events (connect/connection lost) happening during agent's connection to broker. Any reconnect would cause monitoring agent to lose state.
* [SSD1306] Upgrade library to version 3.0
The library at https://github.com/squix78/esp8266-oled-ssd1306 has to be initialized differently in version 3.0
Known issue: The font for 3 lines is not working, so temporary used the same font as for 4 ilnes. The online font generator is currently unavailable at http://oleddisplay.squix.ch/
* OLED framed improve header footer
The header now has better visible WiFi bars indicator and alternates the device name and the connected WiFi SSID.
The bottom part now only shows dots for the pages with visible data instead of the maximum number of pages possible.
* [SSD1306] Upgrade library to version 3.2.7
Forgot to commit deletion of obsolete files in previous commit.
* [SSD1306] Added 12pt font for version 3.x of the library
The font generator is online again: http://oleddisplay.squix.ch/#/home
Added Dialog Plain 12 font for the 3-line display mode.
The header now has better visible WiFi bars indicator and alternates the device name and the connected WiFi SSID.
The bottom part now only shows dots for the pages with visible data instead of the maximum number of pages possible.
* Enhanced Dallas pooling to avoid use of delay(800)
DS_readTemp has been split in 2: DS_convertTemp and DS_readonlyTemp.
DS_convertTemp is first called after DS_setResolution.
Then DS_convertTemp is called after temp has been read.
DS_readTemp has been kept for compatibility.
The only downside is that you read the temperature of previous query (value set by Timer/TDT option).
* typo
* Moved to Environment + code cleaning
- Moved Plugin from Temperature to Environment
- Modified Plugin_004_DS_crc8 to check CRC8, not return it
- Renamed Plugin_004_DS_convertTemp to Plugin_004_DS_startConvertion and removed useless vars in it
- Removed unneed braces and empty lines
- Added comments
* Single function for format to user defined number decimals
In a number of files the same long definition was cut and paste a lot to format values to a user defined number of decimals.
Now a new simple function is added to Misc to perform this formatting, which results in more clean code, less prone to errors and a reduction in use of resources.
* Single function for format to user defined number decimals
In a number of files the same long definition was cut and paste a lot to format values to a user defined number of decimals.
Now a new simple function is added to Misc to perform this formatting, which results in more clean code, less prone to errors and a reduction in use of resources.
* P028 now supports both BME280 and BMP280
Both plugins P028 and P030 had a lot of code duplication. This takes up resources and is hard to maintain.
Now the P028 plugin can detect and use both sensors so P030 may be removed.
Only caveat is that the BMP280 does not measure humidity and thus actually is a 2-value sensor. The Domotics MQTT controller did not distinguish between them, but other controllers may do so.
When needed, the P030 plugin can still be a mere stub for the output and plugin definition and still share all code with P028.
* [BME280] Add temperature offset and improve read stability
The BME280/BMP280 may heat up internally if read too often and too long.
Also when built in a small container along with other sensors and the ESP, the sensor may read values which are too high.
To compensate for these higher readings, a constant offset may be applied in the device parameters.
This value is a signed integer value representing the offset in 1/10th degree Celsius.
Since the humidity is a relative value, depending on the temperature, this should be adjusted also.
Only this computed dew point temperature is also too high, due to the fact the sensor is warmer than the air and thus the perceived humidity is off.
To correct for this, half the offset temperature is being used to compute the dew point temperature.
The other improvement is the routine to read the sensor.
Using this routine, the sensor is only active for about 1.6 seconds each minute.
This prevents the sensor to heat up from its own readings and also allows stable readings using some filtering. (slamming a door does not affect the readings)
* [BMx280] Auto detect connected chip ID and show in Device config tab
Detect connected chip (BME280/BMP280) automatically and show detected device immediately in the Device config page next to the I2C address selection.
* [BME/BMP280] Perform reset at init
Just to make the reading a bit more stable when the sensor stops responding.
This is also done in the "official" Bosch github: https://github.com/BoschSensortec/BME280_driver
* [BMx280] Allow for more than one sensor
As suggested in #491 for another sensor, its I2Caddress was handled incorrectly. The same applied to this plugin.
As described in #491.
The calibration settings are now stored per instance and the I2C address is now taken from the taskvalue array and no longer a global variable.
%eventvalue% parsing didn't correctly process literal strings (that
start with '!'). It tried to extract the value from the righthand of
'=', where it should parse the entire string.
* Create _P070_Kamstrup401.ino
* Update and rename _P070_Kamstrup401.ino to _P071_Kamstrup401.ino
* Update _P071_Kamstrup401.ino
accidentally inserted a line break...
* Added [TESTING] to plugin name
* P010 plugin optimization
optimized code in P010 plugin (probably leftovers od previous versions)
* P010 Optimization
* HDC1080 plugin
HDC1080 plugin
* HDC1080 support
HDC1080 support
* Changed Plugin Number to 072
as 070 was used by another pull-request I renamed this to 072
* Update plugin name to fulfill developping guidelines
* NeoPixel ring clock
A clock that uses a ring of 60 NeoPixel LEDs as display for a classic
clock.
The hours are RED, the minutes are GREEN, the seconds are BLUE and the
hour marks are WHITE.
The brightness of the clock hands and the hour marks can be set in the
device page, or can be set by HTTP or Rules commands. The format is as
follows:
Clock,1,128,32 → 1=enable display, 128=hand brightness, 32=mark
brightness
Clock,0,, → 0=disable display, without changing the saved values of the
brightness
Clock,,65, → change only the brightness of the clock hands
Clock,,,10 → change only the brightness of the hour marks
* - The plugin declaration was cleaned up
- The commands are working
- Correction of offset
* Update _P070_NeoPixel_Clock.ino
* Fix
* Update _P070_NeoPixel_Clock.ino
* Changed the name of the plugin
Changed the name of the plugin to "Output - NeoPixel Ring Clock [TESTING]"
* GlobalSyncOption not needed
GlobalSyncOption not needed, therefore set to false.
* [MH-Z19] Add 'ABC disable' option to web config
As discussed in #466.
The default setting is the current behavior.
When changing the setting, it will be applied as soon as there is a stable reading.
* [MH-Z19] Read settings first before determine must apply flag.
Changes:
Added PLUGIN_GET_DEVICEGPIONAMES to retreive GPIO-names from plugins
Changed Webserver to ask for GPIO-names (backward compatibility for old plugins)
Added GPIO-names to plugins
- Chiming
- Encoder
- TTP229_KeyPad
- DRF0299_MP3
- HX711_Load_Cell
- (more will follow)
Changed GPIO-names in hardware-page for uniformity
And because it was on the way:
Added PLUGIN_EXIT and prepared to unload members and memory from deselected device plugins
* First draft
* Work release
* work release
* Working release
Known BUG: While performing a gesture the reader function blocks rest of ESPEasy processing!!! (Feel free to fix...)
* Updated the way errorcodes are handled.
* Update of code after taliking with Trieb. Implemented function getBitOfInt(int reg, int pos).
* Read all bits
* Small update
Changed the way mask was defined
* PMSx003: fix typo in description
* PMSx003: remove unused variable
* P053_PMSx003: make preparations for supporting hw and sw serial, read on plugin_read only
* P053_PMSx003: fix build and buffer reading (hw serial tested, sw not yet)
* P053_PMSx003: move serial reading to 10x sec, add debug levels, fix empty buffer read
* P053_PMSx003: drop log message in read, already posted as EVENT
* Plugin_008-RFID extended with wiegand 34-bits and key-pad (4-bits per key) support
* removed millis from interupt-handler and volatile from keyBuffer because of high IRAM usage
* Renaming
* Fixed DEVICES_MAX for testing and dev
* Experiments with delivering HTML
* Step back to style-based-css for speed up
* pimp menu
* pimp menu
Fixed GUI of plugin adding correct GPIO request
Fixed code for "NeoPixelAll" command
Tested on ESP8266 and WemosD1Mini with various WS2812 configuration
hardware
* First draft
* work release
* work release
* Work release
* Work release
* Work release
* Work release
* rename file
* Work release (not working)
* Rework with library
* Working LED plugin with Clock
* Added plugins for HT16K33 LED matrix driver and key pad scanner
* Fixed typing of Arduino.h
* Documentation
Changed the device select box to show the one wire address for each connected sensor instead of just a number.
Added a blank option to the device address select box so that in the event that multiple devices are present and the configured device is not currently available, the select box will be blank instead of selecting a different device.
* First draft
* work release
* work release (not working)
* optimized css
* Pimp device-GUI and optimized HTML
* Handle cppcheck error
* Round help button
* Minor bug fixes
* + pmsx005: add all values as output
* - PMSx005: remove additional measurements from values
* + PMSx005: fix return values for plugin function
* * PMSx003: rename filename to match devices (PMS3003, 5003, 7003, A003)
* * PMSx003: fix valuecount and prevent sending to controllen when nothing recveid yet
* * PMSx003: rename _P050 to _P053
* + PMSx003: add PLUGIN_BUILD_TESTING
* - PMSx003: remove old _P050 that made place for _P053
* First draft of templates
* Added templates for customization
* Fixed dept_onchange(frmselect)
* Moved javascript to sendWebPage()
* moved javascript to template var
* Preparation for selected menus
and bugfix if 2 vars are stand near together
* removed libs from prev. commit
* rework of menu
* Some cleanup
* GUI touchup on Tools
I added some space between settings-firmware and firmware-filesystem to
make it look nicer (my opinion).
* Implemented addButton function
* Limits to NumericBox and a bit of security to PasswordBox
* Limits to NumericBox and a bit of security to PasswordBox
Password handling: Deliver "*****" to password box accept changes if not equal to "*****"
* solved merge conflicts
I am working on an RGBW lightbulb plugin and 3 variables are not enough
to control it. Rather than add variables in the plugin (like neopixel
does) i think it is better to add them to EventStruct. I only needed 4,
but neopixel uses 5
* make the Settings - Save. Filename more descriptive, didn't like this also. solves issue: #241
* added getDateString + getTimeString + getDateTimeString Functions and replaced dublicate code with the new functions...
* more comments :)
* add getFormItemFloat, because we have some float input also
* more form-functions optimizations...
* addFormNumeric with min and max parameters
* ...and more formFunctions replacements
* ...and more formFunctions replacements
* ...and more formFunctions replacements
* ...and more formFunctions replacements
* ...so first round done... will do another round when addFormSelector is merged...
* and a few controller text boxes can be replaced also...
* one char to much...
* Moving plugin from playground
I am now moving this plugin from playground to main repo. It is tested
for long time and works fine.
* Forgot #endif
* Exclude readme.
* Wrong plugin number
* seems to be a type, but return type must be int!
* for form-function optimizations
* even more form-functions....
* even more form-functions + type fix
* lots of form-functions...
* first draft
* work release
* work release
* work release
* work release
* work release
* work release
* Added addForm*-functions for easy web-interface and pimp GUI
Changes many HTML-code to function calls for less code and more readability. More changes are coming soon.
Some groupings in Web-Interface.
* add support for i2c am2320 temperature and humidity sensor based on this https://github.com/hibikiledo/AM2320 library
* add i2cScanner detection of AM2320 Sensor
* minor
* http advanced controller, correct passing of hostname
fixes an error reported by mikrom in the forum: https://www.letscontrolit.com/forum/viewtopic.php?f=4&t=2973
* http request must close mit double newline...
wrong newline in case of get request without body
the request ends with a double newline, each in the form of a carriage return followed by a line feed
use classic usage with single varables:
if (Settings.TaskDevicePin1[event->TaskIndex] >= 0)
pinMode(Settings.TaskDevicePin1[event->TaskIndex], OUTPUT);
if (Settings.TaskDevicePin2[event->TaskIndex] >= 0)
pinMode(Settings.TaskDevicePin2[event->TaskIndex], OUTPUT);
if (Settings.TaskDevicePin3[event->TaskIndex] >= 0)
pinMode(Settings.TaskDevicePin3[event->TaskIndex], OUTPUT);
or use in a more compact way as array:
for (byte i=0; i<3; i++)
if (Settings.TaskDevicePin[i][event->TaskIndex] >= 0)
pinMode(Settings.TaskDevicePin[i][event->TaskIndex], OUTPUT);
or use in combination simultaneously (memory for single vars and array overlaps)
"Environment" naming will better fit in instead of the long "Temperature & Pressure", and we will get a few char space more to use and it will fit nicely into the drop-down combo box too, otherwise is way to long!
"Environment" naming will better fit in instead of the long "Temperature & Humidity", and we will get a few char space more to use and it will fit nicely into the drop-down combo box too, otherwise is way to long!
"Environment" naming will better fit in instead of the long "Temperature & Humidity", and we will get a few char space more to use and it will fit nicely into the drop-down combo box too, otherwise is way to long!
"Environment" naming will better fit in instead of the long "Temperature & Pressure", and we will get a few char space more to use and it will fit nicely into the drop-down combo box too, otherwise is way to long!
"Environment" naming will better fit in instead of the long "Temperature & Pressure", and we will get a few char space more to use and it will fit nicely into the drop-down combo box too, otherwise is way to long!
"Environment" naming will better fit in instead of the long "Temperature & Humidity", and we will get a few char space more to use and it will fit nicely into the drop-down combo box too, otherwise is way to long, plus added sensor naming like DHT11/12/22!
"Environment" naming will better fit in instead of the long "Temperature & Humidity", and we will get a few char space more to use and it will fit nicely into the drop-down combo box too, otherwise is way to long!
"Environment" naming will better fit in instead of the long "Temperature & Humidity & Pressure", and we will get a few char space more to use and it will fit nicely into the drop-down combo box too, otherwise is way to long!
The SONY IR protocol calls for the remote code to be sent >= 3 times for it to work. Thus you should probably call this with a repeat=2.
Note however, don't merge this until you've updated easyesp to use the correct IRremoteESP8266 library (#188#189) which implements the repeat feature.
Replace the url to the old un-maintained fork of the IRremoteESP8266 library to its upstream canonical (and maintained) library.
This might explain why we've had some odd non-reproducible reports of our (IRremoteESP8266) library not working as expected.
* Addition of ESP8285 targets
In addition to the normal ESP8266 targets there are now targets for
normal_8285, test_8285 and dev_8285. Each of these targets provides an
additional build flag with -DESP8285
* Added ESP8285 build targets with correct flash size
Correction of the build modification done before, now with correct flash
siez of 1M
* Provide different GPIO dropdown lists for 8266 and 8285
The ESP8266 and ESP8285 expose different sets of GPIOs. This new version
of the web server provides different dropdown lists depending on the
build flag -DESP8285 (which is set in the new targets for building
ESP8285 fw).
* added missing sensor types: LONG & WIND
* did a bit of code cleanup, like you suggested... removed a lot of code, and works as before! :)
* fixed typo
* added date to the time displays... changed password fields to type=password
* motorshield library should be a submodule, enhanced the motorshield plugin, with better command parsing, but still work to do..
* fully implemented steppers and DCMotors
* add replacement variable for systime, vcc, ip, sysload, uptime
* fixed bug with sleep mode
* 20 ms delay to wakeup should be enough
complete rewrite, now has better support for lower lux values, also better handling of higher values, add ability to change gain and sleep mode, based on sparkfun library
re-did the following pull requests to mega repository:
#89 Fix url link to setup after the first WiFi setup
#93 Allow use it with rain gauge
setting hostname on arduinoOTA
warning to not change filename on setting save/load (had the issue myself)
Based on the specification it is necessary that the sensor is in sleep
mode when the configuration registers are changed. So the call with the
config registers should also be the last call since we are leaving the
sleep mode and are changing to the forced mode.
* added missing sensor types: LONG & WIND
* did a bit of code cleanup, like you suggested... removed a lot of code, and works as before! :)
* fixed typo
* added date to the time displays... changed password fields to type=password
* motorshield library should be a submodule, enhanced the motorshield plugin, with better command parsing, but still work to do..
* fully implemented steppers and DCMotors
* add replacement variable for systime, vcc, ip, sysload, uptime
According to Bosch Sensortec the suggested settings for climate /
weather monitoring are:
Sensor mode: forced mode, 1 sample / minute
Oversampling settings: pressure ×1, temperature ×1, humidity ×1
IIR filter settings: filter off
To measure new values in the forced mode a write to the
"BME280_REGISTER_CONTROL" is necessary, which I added to the temperature
reading.
* Added commands to set the measurement range to 1000/2000/3000/5000ppm.
* Added command to do sensor zero calibration (actually 400ppm
calibration)
* Added command to en/disable Automatic Background Calibration
* Added command to reset sensor
* Ignore (but log) any sensor boot time values
* Ignore (but log) any sensor values where stability isn't optimal
* Report undocumented U value (minimum CO2 per time period for ABC?) to log and MQTT
* Much more verbose logginga
* Shifts serial read buffer upon CRC errors (usually happens when sensor
restarts during operation, or timing is off at device boot)
* added missing sensor types: LONG & WIND
* did a bit of code cleanup, like you suggested... removed a lot of code, and works as before! :)
* fixed typo
* added date to the time displays... changed password fields to type=password
* motorshield library should be a submodule, enhanced the motorshield plugin, with better command parsing, but still work to do..
* fully implemented steppers and DCMotors
I have changed http request from GET to POST as already suggested by @mvdbro to fulfill RFC compliance. Furthermore the obsolte commands from url were removed and I added build information to JSON data.
- [ ] The title of this issue is "to the point" and descriptive.
- [ ] This issue describes what is happening.
- [ ] This issue describes what components are affected (e.g. name of plugin/controller)
- [ ] This issue describes how to reproduce it.
- [ ] This issue describes when it was introduced (when known) and what version is now showing the problem.
### I have...
- [ ] searched the [issue tracker](https://github.com/letscontrolit/ESPEasy/issues) or the [forum](https://www.letscontrolit.com/forum/viewforum.php?f=1) for a similar issue. (include links when applicable)
- [ ] entered a system description using "Copy info to clipboard" on the sysinfo page. (when possible)
- [ ] entered the full filename of the used version (e.g. `ESP_Easy_mega-20181001_test_ESP8266_4096_VCC.bin` )
- [ ] given a list of active plugins or controllers when applicable.
- [ ] filled out all applicable fields below.
### Steps already tried...
- [ ] Tried a clean install (empty `.bin` files are included in the ZIP)
- [ ] Tested previous/other build (mention which one already tested)
- [ ] Tested on other node to make sure hardware isn't defective.
- [ ] Verified if the problem is limited to a single plugin/controller
### If you self compile, please state this and PLEASE try to ONLY REPORT ISSUES WITH OFFICIAL BUILDS! ###
<!--- If you self compile, please state this and PLEASE try to ONLY REPORT ISSUES WITH OFFICIAL BUILDS! --->
<!--- NOTE: This is not a support forum! For questions and support go here: --->
For ways to *support* us, see [this announcement on the forum](https://www.letscontrolit.com/forum/viewtopic.php?f=14&t=5787), or have a look at the [Patreon](https://www.patreon.com/GrovkillenTDer), [Ko-Fi](https://ko-fi.com/grovkillentder) or [PayPal](https://www.paypal.me/espeasy) links above.
# ESPEasy (development branch)
Introduction and wiki: https://www.letscontrolit.com/wiki/index.php/ESPEasy#Introduction
**MEGA**
:warning:This is the development branch of ESPEasy. All new untested features go into this branch. If you want to do a bugfix, do it on the stable branch, we will merge the fix to the development branch as well.:warning:
This is the development branch for the next upcoming release (2.0.0). This is also known as ESPEasyMega.
Check here to learn how to use this branch and help us improving ESPEasy: http://www.letscontrolit.com/wiki/index.php/ESPEasy#Source_code_development
Binary development releases are here: https://github.com/letscontrolit/ESPEasy/releases
Details and discussion are on the Experimental forum: http://www.letscontrolit.com/forum/viewtopic.php?f=18&t=2257&p=13600#p13600
## Automated binary releases
Every night our build-bot will build a new binary release: https://github.com/letscontrolit/ESPEasy/releases
The releases are named something like 'mega-20190225' (last number is the build date)
Depending on your needs, we release different types of files:
- normal_IR => "Normal" + IR receiver/transmitter plugins and library
- hard_xxxxx => Special builds for some off-the-shelf hardware.
- minimal_ESP82xx_1M_OTA => Minimum number of plugins and a limited set of controllers included to be able to perform a 2-step OTA on 1 MB flash nodes.
- normal_core_241 => "Normal" using core 2.4.1, since 2.4.2 has issues with PWM
- xxx_core_260_sdk2_alpha -> core 2.6.0 alpha version (under development) using SDK 2.2.1
- xxx_core_260_sdk222_alpha -> core 2.6.0 alpha version (under development) using SDK 2.2.2
- xxx_core_260_sdk3_alpha -> core 2.6.0 alpha version (under development) using SDK 3.0.0-dev (under development too)
Chip can be:
- ESP8266 => Most likely option
- ESP8285 => Used in some Sonoff modules
- ESP32 => Experimental support at this moment
MemorySize can be:
- 1M => 1 MB flash modules (e.g. almost all Sonoff modules)
"MessageBody":"We are in need for support. Currently we need to do a whole lot of consulting to keep us floating. If we could get funding for at least 50% of our time we could make a lot more than with our current 10-15%. Ideal would be 100% funding but we're realistic :) <br><br>We will add extra goodies for those who support us through monthly payments using Patreon.<br><br><br>Thanks for your support (from TD-er and Grovkillen)!",
"MessagePicture":"",
"MessageWriter":"Grovkillen",
"MessageColorBG":"",
"MessageColorFont":"",
"MessageDate":"2019-01-07",
"MessageType":"general",
"MessageLink1text":"Patreon",
"MessageLink1":"",
"MessageLink2text":"Ko-Fi",
"MessageLink2":"",
"MessageLink3text":"Paypal",
"MessageLink3":""
},{
"MessageTitle":"First announcement test",
"MessageBody":"We're planning on using the ESP Easy Flasher to push announcements to the users. Hopefully this will work out good and make more people aware of how things are evolving. This will be used as a channel for pretty much anything regarding the prject. Thanks for your support!",
Implementation of secure communication and check for valid data.
..versionadded:: 1.0
...
|added|
Initial release version.
Description
-----------
ESPEasy is able to communicate between nodes itself.
It is an IANA registered service: `espeasy-p2p <https://www.iana.org/assignments/service-names-port-numbers/service-names-port-numbers.xhtml?search=8266#ESPeasy>`_
* Service Name: espeasy-p2p
* Port Number: 8266
* Transport Protocol: UDP
* Description: ESPeasy peer-2-peer communication
* Registration date: 2018-11-28
This protocol is targeted specific for use by ESPeasy to let ESPeasy nodes
communicate with each other to create a big swarm of nodes working together
without the need for a hosted service like MQTT, which needs a central broker.
It is currently used for:
* Discovery of nodes
* Sharing sensor data among nodes
Later updates may add:
* Distribution of settings
* Sending commands
Sharing Plugins among Nodes
---------------------------
It is possible to share the data collected by a plugin on one node so it can be used on another node.
This data can be used as if it is actually being run on the second node.
For example, a Dallas DS18b20 sensor on Node-1 is shared using the ESPeasy p2p controller.
This plugin can then automatically be setup on Node-2 and using the data collected by Node-1.
This is a rather non-intuitive process to setup.
Prerequisites
^^^^^^^^^^^^^
* Same UDP port must be setup on both nodes. (preferrably UDP port 8266) This can be done in Tools -> Advanced -> UDP port
* Nodes must be rebooted after UDP port has changed.
* Each node must have an unique unit number. This must not be 0 and not 255, but anything inbetween is fine.
How to share a plugin
^^^^^^^^^^^^^^^^^^^^^
* Check to see if all nodes can see eachother. This will be visible on the main page showing a list of all nodes.
* Enable p2p networking controller on receiving node
* Make sure the receiving node has the spot free which is being used on the 'sending' node (For example slot 12)
* Enable p2p networking controller on sending node
* Set the plugin you want to share to use the p2p controller
Any node that is setup to receive data like this will see a plugin being added if the spot in the device list was still free.
Builds made after 2019/08/08 will show in the device overview page from which unit the shared plugin does get its data.
This also means the plugin must be removed and re-created if the sending node is changed. (e.g. another node or change of unit number)
In later builds there will be added an option to update this node number.
Some tips on trouble shooting
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
* Make sure to reboot the node after changing the UDP port.
* Make sure all nodes have an unique unit number and share the same UDP port.
* If you have ArduinoOTA enabled, use another port for ESPeasy p2p UDP (port suggested in most OTA examples use port 8266)
* Ping the nodes from some other host to keep their WiFi awake.
* Disable "Eco mode" in the advanced settings.
* Sharing a plugin to be auto installed on another node is only sent right after the plugin is set to use the p2p controller. So if you don't see it appear on the other node, save it again on the source node.
* Make sure the same plugin is available in the build on both nodes. (e.g. both supporting Dallas DS18b20, if that's the one you want to share)
* When using the "Guest" feature of an access point, some will not allow direct communication between clients on the same AP. This will also prevent this p2p protocol to share data.
* If updating from builds before 2019/08/08, you may need to remove and add again a plugin receiving data from a remote node.
Sending & Known Nodes
---------------------
ESPEasy keeps track of all nodes advertising themselves via Sysinfo messages.
This knowledge is kept in a ``NodeStruct`` for at least 10 minutes.
If a node is not sending a Sysinfo message in this period, it will be removed from the list.
Data Format Versions
--------------------
During the IANA port assignment assessment, a number of issues were pointed out by their experts.
* Versioning
* Security
* Data validation
* Traffic limiting and congestion handling
There are now 2 versions available:
* Version "0" - No security, no data validation.
* Version "1" - Introduced in ESPeasy build <???>
Data Format Version 0
---------------------
Sending and receiving is causing issues when the swarm of nodes increases.
* All nodes with this service enabled will advertise their presence every 30 seconds via broadcast
* Nodes can not subscribe to receiving sensor data updates
* Non broadcast messages are sent to each individual known node, regardless if the receiving node will use the data
* Sensor Data messages are sent to each individual known node
* Sensor Info updates are sent to each individual known node when a plugin coupled to this plugin is saved.
Of each known node the following data is kept:
..code-block::C++
structNodeStruct
{
StringnodeName;
byteip[4];
uint16_tbuild;
byteage;
bytenodeType;
};
The key to index this ``NodeStruct`` is the nodes unit number.
ASCII Data
~~~~~~~~~~
Command Message
***************
First byte is not 0xFF.
The entire message processed as a command like this:
This controller connects to a MQTT Server providing auto-discover information and a communication protocol according to the Homie convention 3.0.1 and the future development version 4.0.0.
For more information head over to `Homie convention <https://homieiot.github.io/>`_
Idea is to provide an easy way to include ESPEasy in modern home automation systems without any or with as less effort as possible. Imagine your device pops up in openHAB 2.4 or higher as a new device and you only have to pic the values you are interested in. You can immediately see measurements or switch GPIOs without a single line of code.
When a MQTT connection is established after (re-)boot the controller sends auto-discovery information for system services like commands, basic GPIO functions and for all configured devices and there values. When all messages where sent successfully a homie compatible home automation server/hub or other compatible controllers should be able to detect the unit and establish two way communication.
The :ref:`P086_page` plug-in can be used to set values and trigger actions / rules.
MQTT topic scheme
-----------------
A homie topic scheme always starts with the root topic homie followed by the **unit name** (homie uses the term **device**), **device name** (**node** in homie) and a **value name**.
``homie/%unitname%/%devicename%/%valname%``
updates or commands can be sent by appending ``/set`` to the topics for values which can receive data.
``homie/%unitname%/%devicename%/%valname%/set``
Prequesites
-----------
A MQTT server capable of storing messages sent with ``retain=true`` when ``QoS=0``. Due to limitation (intentional not implemented due to low memory footprint and performance considerations) of the MQTT library (pubsubclient) used in ESPEasy it is only possible to send messages with ``QoS=0`` which basically means `fire and forget`. The current MQTT specification says that the server SHOULD store these messages when they arrive via ``QoS=0``. Some servers like the MQTT server currently build into openHAB 2.4 (moquette) is configured to ignore the retain flag and drop the message after delivery to the currently subscribed clients when ``QoS=0``. Mosquito on the other hand store messages when retain flag is set even when they are sent with ``QOS=0``.
Check with a MQTT client like MQTTspy or MQTTfx if the auto-discover messages are stored (retained).
A home automation server/controller capable talking Homie like openHAB since 2.4. (Be aware there are issues in the Homie implementation 2.4 including 2.5M1 milestone release not working as expected after restart). Recent snapshot builds should work.
Setup
-------------
- add the Homie **Homie MQTT (Version 4.0.0 dev)** or **Homie MQTT (Version 3.0.1 dev)** controller to your controller lists depending on your build.
- insert your broker address
- and user credentials if necessary
- the publish scheme is fixed to meet the homie requirements to ``homie/%sysname%/%tskname%/%valname%``
- the subscription scheme can be modified. Current defaults to ``homie/%sysname%/+/+/set`` to reduce incoming traffic to a minimum. Homie only expects messages via the ``homie/%sysname%/%tskname%/%valname%/set`` topic.
- last will topic (LWT) should set to ``homie/%sysname%/$state``
- LWT Connect Message to ``ready``
- LWT Disconnect Message to ``lost``
- save and reboot, best with connected serial monitor or syslog server with debug set to 4 (debug) or greater (alternatively use a MQTT client and subscribe to ``homie/%sysname%/#`` - replace %sysname% by the unit-name shown on the top of the webpage).
..image:: C0014_Setup_0.png
-``homie/%sysname%/$nodes`` enumerating all devices will be sent as final message of the auto-discover header.
- The final event log should look like this:
..code-block::html
5584 : EVENT: MQTT#Connected
5754 : C014 : autodiscover information of 4 Devices and 6 Nodes sent with no errors! (26 messages)
Troubleshoot
------------
The auto-discover information is sent through a big number of messages (usual more than 20). If your controller software not recognize your device or shows errors during the auto-discover process try the following steps:
- For testing purposes start with a basic setup with none or only one device configured and enabled.
- More devices can be added or (re-)enabled later.
- Disable already configured devices (devices without the enabled box ticked will be ignored)
- Check with a MQTT client if all messages are sent. The last message sent is ``$nodes`` attribute listing minimum the ``SYSTEM`` node if no other devices are enabled.
- check your WIFI connection. Perhaps bring your device nearer to your access point. (only necessary during the setup process because the messages should be stored by the broker)
- check via syslog or serial console if the messages are sent successful (you normaly can't see the log output in the web log)
- use the `mqqt-forget <https://www.npmjs.com/package/mqtt-forget>`_ tool to delete unused retained messages from your broker via wildcards
Features
--------
The controller currently supports these features
- send auto-discover nodes for all sending and enabled plug-ins to ``homie/%unitName%/%deviceName%/%valueName%``
- receive commands through the ``homie/%unitName%/SYSTEM/cmd/set`` topic.
- switch GPIOs through ``homie/%unitName%/SYSTEM/gpio#/set`` topic. The GPIO port must be set to **default low** or **default high** in the hardware tab to be included during auto-discover.
- send updates of GPIO ports to ``homie/%unitName%/SYSTEM/gpio#`` regardless from where the change is triggered (to be fully tested).
- in conjunction with :ref:`P086_page` actuators can be used according to the Homie convetion using rules.
- receive values for dummy devices via ``homie/%unitName%/%dummyDeviceName%/%valueName%/set``. From there the values can be processed further by using rules.
- handle ``$state`` attribute (for complete list see attribute table below)
-``init`` during boot process
-``ready`` during normal operation and as a heartbeat every 30sec (to be tested)
-``alert`` currently only if auto-discover fails. But if sending the auto-discover messages fails it is more than likely that sending the alert message will fail to. (ToDo: inform about other error states like low ram or stack available, repeating reboots or failed sensors)
-``sleeping`` sent before deep sleep
-``lost`` configured as LWT
-``disconnected`` sent to the old topic if the unit name changes to inform that the old topic is not valid any more. Auto-discover messages are sent automagically to the new topics afterwards.
- acknowledge received message by the ``homie/%unitName%/%deviceName%/%valueName%/set`` topic to the corresponding value ``homie/%unitName%/%deviceName%/%valueName%`` even if the value was changed by a different source like HTTP or rule to keep the state in your home automation system allays up to date. (Needs further testing)
Future / planned features
-------------------------
- a special Homie Plugin is in devolopment to pass ``\set`` messages to rules for further handling. Here ``$datatype`` and ``$format`` attributes for ``$setable`` values can be specified there. This will enable ESPEasy to handle direct inputs to plug-ins like dimmers (%,0:100), colors (RGB & HSV, 255,255,255), enum devices like remote controls (Play, Pause, Vol+, Vol-, ...). :yellow:`Testing` see :ref:`P086_page`
- Further in field testing with different MQTT brokers and home automation systems.
- Handling units via the ``$unit`` attribute. As ESPEasy is currenty "unitless" this needs a global concept within ESPEasy
- Handling ``$datatype`` attribute. Currenly all values (except cmd and gpio) are defined as ``float``. :yellow:`Testing` see :ref:`P086_page`
- Prepare some "working examples".
Under the hood
--------------
Auto-dicover information is sent by several $attributes
currently the following attributes will be sent during boot
"``$name``", "Friendly name of the device", "EPSEasy#1", "YES", ":green:`required`", "YES", ":green:`required`"
"``$homie``", "The implemented Homie convention version", "4.0.0", "YES",":green:`required`", "YES", ":green:`required`"
"``$state``", "See chapter features", "ready", "YES",":green:`required`", "YES", ":green:`required`"
"``$localip``", "IP of the device on the local network", "192.168.2.10", "YES", ":green:`required`", "NO", ":red:`void`"
"``$mac``", "Mac address of the device network interface.", "A1:B2:C3:D4:E5:F6", "YES", ":green:`required`", "NO", ":red:`void`"
"``$fw/name``", "Name of the firmware running on the device.", "ESPEasy mega", "YES", ":green:`required`", "NO", ":red:`void`"
"``$fw/version``", "Version of the firmware running on the device.", "20103 - Mega", "YES", ":green:`required`", "NO", ":red:`void`"
"``$nodes``", "Nodes which the device exposes separated by commas. Sent at the end for performance reasons.", "SYSTEM,SysInfo", "YES",":green:`required`", "YES", ":green:`required`"
"``$implementation``", "An identifier for the Homie implementation.", "ESP8266", "YES", ":green:`required`", "NO", ":red:`void`"
"``$stats/interval``", "Interval in seconds at which the device refreshes.", "60", "YES", ":green:`required`", "NO", ":red:`void`"
"``$stats/uptime``", "Time elapsed in seconds since the boot of the device.", "12345", "YES", ":green:`required`", "NO", ":red:`void`"
"``$stats/signal``", "Signal strength in %.", "75", "YES", ":blue:`optional`", "NO", ":red:`void`"
"``$name``","Friendly name of the property.","Command", "YES",":green:`required`", "YES",":green:`required`"
"``$datatype``","Describes the format of data. integer/float/boolean/string/enum/color","float", "YES",":green:`required`", "YES",":green:`required`"
"``$settable``","Specifies whether the property is settable (true) or read-only (default false). True for cmd, GPIO and dummy device values.","true", "YES",":yellow:`required true` for settable values", "YES",":yellow:`required true` for settable values"
"``$retained``","Specifies whether the property is retained (true) or non-retained (false).","false", "NO",":green:`required`", "NO",":blue:`optional`"
"``$unit``","A string containing the unit of this property.","°C", "NO",":blue:`optional`", "NO",":blue:`optional`"
"``$format``","Describes what are valid values for this property.","-30:40", "NO",":blue:`optional`", "NO",":blue:`optional`"
`The Things Network (TTN) <https://www.thethingsnetwork.org/>`_ is a global open LoRaWAN network.
LoRaWAN allows low power communication over distances of several km.
A typical use case is a sensor "in the field" which only has to send a few sample values every few minutes.
Such a sensor node does broadcast its message and hopefully one or more gateways may hear the message and route it over the connected network to a server.
The data packets for this kind of cummunication have to be very short (max. 50 bytes) and a sender is only allowed to send for a limited amount of time.
On most frequencies used for the LoRa networks there is a limit of 1% of the time allowed to send.
Such a time limit does also apply for a gateway. This implies that most traffic will be "uplink" data from a node to a gateway.
The analogy here is that the gateway is often mounted as high as possible while the node is at ground level ("in the field")
There is "downlink" traffic possible, for example to notify some change of settings to a node, or simply to help the node to join the network.
In order to communicate with the gateways in the TTN network, you need a LoRa/LoRaWAN radio module.
The radio module does communicate via the LoRa protocol. On top of that you also need a layer for authentication, encryption and routing of data packets.
This layer is called LoRaWAN.
There are several modules available:
- RFM95 & SX127x. These are LoRa modules which needs to have the LoRaWAN stack implemented in software
- Microchip RN2384/RN2903. These are the modules supported in this controller. They have the full LoRaWAN stack present in the module.
Nodes, Gateways, Application
----------------------------
A typical flow of data on The Things Network (TTN) is to have multiple nodes collecting data for a specific use case.
Such a use case is called an "Application" on The Things Network.
For example, a farmer likes to keep track of the feeding machines for his cattle.
So let us call this application "farmer-john-cattle".
For this application, a number of nodes is needed to keep track of the feeding machines in the field.
These nodes are called "Devices" in TTH terms.
For example a device is needed to measure the amount of water in the water tank and one for the food supply.
Such a device must be defined on the TTN console page.
There are two means of authenticating a device to the network (this is called "Join" in TTN terms):
- OTAA - Over-The-Air Authentication
- ABP - activation by personalization
With OTAA, a device broadcasts a join request and one of the gateways in the neighborhood that received this request,
will return a reply with the appropriate application- and network- session keys to handle further communication.
This means the device can only continue if there is a gateway in range at the moment of joining.
It may happen that a gateway does receive the join request, but the device is unable to receive the reply.
When that's happening, the device will not be able to send data to the network since it cannot complete the join.
Another disadvantage of OTAA authenticating is the extra time needed to wait for the reply.
Especially on battery powered devices the extra energy needed may shorten the battery life significantly.
With OTAA, the device is given 3 keys to perform the join:
- Device EUI - An unique 64 bit key on the network.
- Application EUI - An unique 64 bit key generated for the application.
- App Key - A 128 bit key needed to exchange keys with the application.
The result of such an OTAA join is again a set of 3 keys:
- Device Address - An almost unique 32 bit address of your device.
- Network Session Key - 128 bit key to access the network.
- Application Session Key - 128 bit key to encrypt the data for your application.
The other method of authenticating a device is via ABP.
ABP is nothing other than storing the last 3 keys directly on the device itself and thus skipping the OTAA join request.
This means you don't need to receive data on the device and can start sending immediately, and even more important, let your device sleep immediately after sending.
A disadvantage is the deployment of the device. Every device does need to have an unique set of ABP keys generated and stored on the device.
Updating session keys may also be a bit hard to do, since it does need to ask for an update and must also be able to receive that update.
Hybrid OTAA/ABP
---------------
TODO TD-er.
Configure LoRaWAN node for TTN
------------------------------
A LoRaWAN device must join the network in order to be able to route the packets to the right user account.
Prerequisites:
- An user account on the TTN network.
- A TTN gateway in range to send data to (and receive data from)
- Microchip RN2384 or RN2903 LoRaWAN module connected to a node running ESPeasy. (UART connection)
On the TTN network:
- Create an application
- Add a device to the application, either using OTAA or ABP.
In order to create a new device using OTAA, one must either copy the hardware Device EUI key from the device to the TTN console page,
or generate one and enter it into the controller setup page in ESPeasy.
The Application EUI and App Key must be copied from the TTN console page to the ESPeasy controller configuration page.
Using these steps, a device address is generated.
Such an address looks like this: "26 01 20 47"
Also the Network Session Key and Application Session Key can be retrieved from this page and can even be used as if the device is using ABP to join the network.
But keep in mind, these 3 keys will be changed as soon as an OTAA join is performed.
Device configuration with solely an ABP setup are more persistent.
-**Protocol** - The type of controller (e.g. ThingSpeak/OpenHAB MQTT/etc.)
-**Locate Controller** - Selection between hostname/IP
-**Controller Hostname/IP** - The address to reach the selected service
-**Controller Port** - TCP/UDP Port number (0...65536)
-**Enabled** - Whether or not the controller is active.
Send queue parameters
---------------------
Controllers have a queue to keep unsent messages.
This queue is used to handle message bursts and also store messages which are recorded
before WiFi connection is made or during lost connection.
-**Minimum Send Interval** - Minimum time between two messages in msec.
-**Max Queue Depth** - Maximum length of the buffer queue to keep unsent messages.
-**Max Retries** - Maximum number of retries to send a message.
-**Full Queue Action** - How to handle when queue is full, ignore new or delete oldest message.
-**Check Reply** - When set to false, a sent message is considered always successful.
-**Client Timeout** - Timeout in msec for an network connection used by the controller.
-**Sample Set Initiator** - Some controllers (e.g. C018 LoRa/TTN) can mark samples to belong to a set of samples. A new sample from set task index will increment this counter.
Especially useful for controllers which cannot send samples in a burst. This makes the receiving time stamp useless to detect what samples were taken around the same time.
The sample set counter value can help matching received samples to a single set.
Sample ThingSpeak configuration
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Some controllers, like ThingSpeak, need a specific configuration.
ThingSpeak only allows a message every 15 seconds for the free accounts.
-**Minimum Send Interval** - 15000 msec
-**Max Queue Depth** - 1 (only report the last value)
RTTTL (Ring Tone [Text] Transfer Language) was developed by Nokia to play more "easy on the ear" melodies as ringtones for mobile phones. The tunes over all characteristics are created by using three different commands:
**d** - duration
**o** - octave
**b** - tempo (beat)
After that the actual tune is then created using standard notes (a, b, c, d, e, f, and g), before the note the duration is set, after the note the octave is set:
..code-block::html
<duration><note><octave>
To compose a jingle you separate the notes with a comma.
Specifications:
* Output sound
Wiring
------
..code-block::html
ESP Buzzer
GPIO <--> I/O
Power
3.3V <--> VCC
GND <--> GND
Setup
-----
No device is needed, generally you use rules to activate different notifications, or you send commands to activate them. Below you find more information on how to do this.
Rules examples
--------------
From ESP Easy v2.0.0 its possible to play melodies via `RTTTL <https://en.wikipedia.org/wiki/Ring_Tone_Transfer_Language#Technical_specification>`_ (don't forget to remove the spaces and replace # with -, this might be fixed in future releases):
Level-converters, aka level-shifters, aka voltage dividers, are used to adapt between a 3.3V device like the ESP8266 and devices using 5V or more internally.
The ESP8266 runs with 3.3V - many devices need 5V or more, for example a LCD display or a Wiegand card reader. It is said that the ESP8266 can
take 5V at its inputs. Basically this is correct and confirmand by Espressif, the manufacturer. Anyways this as always has some limitations.
**First**, overcurrent. If you use a GPIO as input and the output of the connected device has 5V it should work. But if the internal resistance
of the device is low the current might exceed the limits of the ESP8266. With some specific settings of the ESP8266 the GPIO can not take 5V,
who checks every plugin or never made a setting mistake? So for making sure no GPIO is blown accidentally or by a bug some measurements should be taken.
**Second**, some devices need higher voltage if GPIO used as output. For example the PCF8574 or the MCP23017, port multiplexer. This chips use
3.3V or 5V as you choose. For some purpose higher voltage is useful. If using 5V there is a point you have to take care for:
The High and Low levels depend on the voltage!
With the PCF8574 the minimum "High" level Vih = 0.7 × Vdd, with 5V as Vdd it is 3.5V. With the MCP23017 the Vih = 0.8 × Vdd, with 5V as Vdd it is 4V.
(Vdd is the supplied voltage) So with 3.3V max from the ESP we are too low. It might work, it might fail. Worse, it might work with one chip
and fail with another one due to tolerances. In this case a level-converter is needed.
Specifications:
* Level shifter, aka logic converter. Used to turn logics of higher voltage (5V) down to ESP friendly voltage (3.3V).
..note::
**Troubleshooting**:
If your level converter does not work, please check cabling first. As said cabling mistakes and slack joints with the usual cheap breadboard cables are the most likely reason.
If you use breakout board type level converters have a second one at hand. We've seen some "dead on arrival", other died by electrostatic discharge.
And again, breadboards are somewhat unreliable. Use a digital multi-meter to check contacts and wires.
Wiring
------
..warning::
Be careful with wiring. A wrong connection from 5V to the 3.3V rail can cause damages of the ESP and/or the power supply.
A direct connection by mistake from 5V to a GPIO may fry your ESP! Handle level-shifters with some care.
The used FET transistors are somewhat sensible against electrostatic discharge. Use a anti-static mat.
..code-block::html
ESP Level converter Connected hardware
GPIO (X) <--> 3A, LV1, A1 etc. <--> 5A, HV1, B2 etc.
GPIO (Y) <--> 3B, LV2, A2 etc. <--> 5B, HV2, B2 etc.
Power
3.3V <--> 3V3, LV, VA, 3V etc.
5.0V <--> VIN, HV, VB, +5V etc.
GND <--> GND
Different ways of level converting
----------------------------------
Other than using a level converter it is possible to do it "manually" through resistors.
Just Input - simple unidirectional
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
As an example we will use a HC-SR04 ultrasonic distance metering module. The HC-SR04 needs 5V, it will not work with 3.3V.
It works like bat ears, sending ultrasonic pulses and waiting for the echo. It has an input "Trigger" for sending ultrasonic pulses and an output "Echo" for the received signals.
The "trigger" input is no problem as it can take 3.3V for "High". Just connect it to the desired GPIO. But the "Echo" pin sends back 5V signals!
As this signaling is working just in one direction ("unidirectional") from the HC-SR04 to the ESP8266, a simple voltage divider does the job. Look at the schematic:
..image:: P000_Level_converter_2.jpg
Note the two resistors R1 and R2, configured as a voltage divider. The divider gives 2.2/(1.2+2.2) = 0.65 so with 5V you get 5V × 0.65 = 3.25V at the GPIO pin.
Just Input - precise unidirectional
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The simple circuit with two resistors has one disadvantage. It is calculated for 5V. For other voltages you have to calculate another pair of resistor values. And worse,
spikes, short spikes of high voltage from unstable power supply or other reasons) pass through the divider. A better and more precise way is using a Zener diode.
A Zener diode simplified is a semiconductor that gets conductive at a specific voltage.
..image:: P000_Level_converter_3.jpg
Here a Zener diode is used as voltage limiter. The resistor must not be omitted, it is necessary to limit the current. If a 5V signal comes the diode gets conductive - it would
short circuit the device output without the resistor. This circuit is dimensioned for input voltages from 5V to 9V (resistor should have 0.25W!). It can be used nicely for Wiegand
card readers for example. You may use even higher voltages, for example if you want to check a 24V pump. You need an adapted resistor value for that.
Input and Output - Bidirectional Level Converter
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
For devices that use one wire for input and output ("bidirectional") or devices that need higher voltage on an input an active level converter is necessary.
This applies mainly to I²C devices as SCL (the clock signal) comes with 3.3V from the ESP and the SDA (data signal) goes in both directions. There are
specialized chips for this purpose. Most of them have 8 channels - bit of an overkill for an ESP. There is a much simpler way you can buy as a cheap
breakout board or solder together yourself.
..image:: P000_Level_converter_4.jpg
A little FET and two resistors do the job. This is the circuit most level shifters you can buy at the market use.
How does it work? Lets have a simplified look in a nutshell. A FET gets conductive if the voltage at the gate (pin 1) is higher then the voltage at
the source (pin 2). So if the ESP gives 3.3V (High), gate and source have same voltage - the FET isolates both sides (pin 2 & 3) from each other.
If the ESP goes to 0.3V (Low), the gate still has 3.3V - now the FET gets conductive pulling the 5V-side down. If the 5V-side goes to zero (low)
because your device sends data, the diode inside the FET gets conductive and pulls the 3.3V side down to nearly zero (Low).
Use of a dedicated level converter
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Quite an easy job. The pins on a level shifter are usually divided in a LV (Low Voltage) and a HV (High Voltage) side. Sometimes it is just called 3V and 5V.
Connect the 3V pin to 3.3V from ESP and the 5V pin to 5V from your device, for example a LCD display. Don't forget ground, some breakouts have some additional
capacitors which need it. Then connect the GPIOs from the ESP to the LV side, the equivalent pins from your 5V device to the HV side. That's all.
RTTTL (Ring Tone [Text] Transfer Language) was developed by Nokia to play more "easy on the ear" melodies as ringtones for mobile phones. The tunes over all characteristics are created by using three different commands:
**d** - duration
**o** - octave
**b** - tempo (beat)
After that the actual tune is then created using standard notes (a, b, c, d, e, f, and g), before the note the duration is set, after the note the octave is set:
..code-block::html
<duration><note><octave>
To compose a jingle you separate the notes with a comma.
Specifications:
* Output sound
Wiring
------
..code-block::html
ESP Piezo
GPIO <--> Positive (red)
GND <--> Negative (black)
Setup
-----
No device is needed, generally you use rules to activate different notifications, or you send commands to activate them. Below you find more information on how to do this.
Rules examples
--------------
From ESP Easy v2.0.0 its possible to play melodies via `RTTTL <https://en.wikipedia.org/wiki/Ring_Tone_Transfer_Language#Technical_specification>`_ (don't forget to remove the spaces and replace # with -, this might be fixed in future releases):
The ESP8266 can't switch high currents or voltages and no AC at all. But it can switch a relay that can switch high load, isolating high
voltage from the ESP circuit. There are several relay types in the wild.
The ESP can control a relay using one of it's GPIO pins. All relay boards that work with Arduino should also work with the ESP module.
Note this is only a possible application of the ESPs ability to send a logic 1/0 (TTL at 3.3V) on a GPIO. These relay are usually available
as 1,2,4,8,16 Relay modules and work electromagnetically. They can switch both AC/DC(or imitate a button press of a remote for example)
as they are "power operated mechanical switches". Each relay has the screw terminal. The middle one is usually "always connected" terminal.
The NC contact will be connected to the middle terminal when the relay is not powered. The NO is connected when the relay is powered
and activated. Note that there are "active high" and "active low" versions of these relays.
There are mainly two relay types in the wild: The good old mechanical relay with the nice "click-clack" sound and the electronic relays, so called
"Solid State Relays" (SSR) which are completely silent.
Specifications:
* Opto coupler (mechanical)
* Solid state (SSR)
Relays are the most used actuators in home automation. Most people use breakout boards with a relay on it. Sadly there is no "standard" relay board.
It seems every small manufacturing garage in china has it's own layout and schematic. Some use 5V, some use 12V, some do with opto couplers, some without...
the perfect chaos. Several problems result from this chaos. Relays keeping switched on no mater what your ESP says. Relays not switching at all.
And last but not least - sometimes they work. Let's get some order into that chaos.
..note::
You have just got your brand new relay board and it does not work. What to do?
At first you should check the switching level. Is it switching on with "high" or with "low"?
* Connect the board to power only (5V or 12V usually).
* Plug a jumper cable to one of the inputs.
* With the other end of the cable touch GND and +Vcc (5V or 12V).
On one of these touches the relay should switch. If it switches when connecting to GND the board uses "low" as active (relay on) signal.
In this case diodes or a transistor / FET as described above might help.
Connect the board to the ESP carefully. Check voltages, the power supply should be able to deliver enough current for the relays!
Check the connection cables. Jumper cables are well known for slack joints.
Mechanical relay
----------------
The mechanical relay is a simple construction.
It consist of a coil, one or more contacts and a spring. The spring keeps the contact in the "open" position. If the coil gets current, the magnetic
field pulls the contact into the second position, the contact closes. As soon as the current is switched off the spring pulls the contact back.
Mechanical relays may just have one contact switching to closed if the coil works (Normally open or NO). The contact might be a changeover contact which
has a "common" connector and a NO (open without coil current, "normally open") and a NC (closed without coil current, "normally closed") connection.
There might even be several contacts in one relay.
There are several special types of mechanical relay
One current pulse switches on and keeps on when current goes off, a second pulse switches off.
Polarized relay:
..image:: P000_Relay_3.jpg
These relays have a defined + and - pin for the coil that must be followed.
..warning:: These micro relays can not switch mains voltage! Use them for low voltage door openers or similar.
Pros and cons of mechanical relays
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
:green:`+` Several contacts in one relay available.
:green:`+` NO/NC available.
:green:`+` Limited resistance to overload and overvoltage.
:red:`-` Noisy, might disturb in a living room or bedroom.
:red:`-` Mechanical, moving parts that might wear out over time.
:red:`-` Contact bumping when switching.
:red:`-` High current for the coil, needs a transistor or FET for driving and generates peaks on power supply.
:red:`-` The coil induces high voltage when switching off.
Solid state relay
-----------------
The solid state relay, SSR for short, is a complex electronic circuit. It uses an opto coupler for input, this isolating the driving circuit from the load voltage.
Isolation voltage is usually 2000V, 4000V or more. The switching element usually is a triac for AC switching types. For DC there are types with a MOSFET as switching element.
There are several special types of SSR relay
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
..image:: P000_Relay_4.jpg
As with the mechanical relays there are specialized types of SSR's.
**AC Type** : Can only (!!) switch AC. AC with zero crossing circuit. This type switches on and off if the AC voltage is at the zero point. **Expensive** and necessary only for special applications.
**DC Type** : Can only (!!) switch DC! And a lot more that are reserved for special cases.
Pros and cons of SSR relays
^^^^^^^^^^^^^^^^^^^^^^^^^^^
:green:`+` Completely noiseless
:green:`+` Low driving current and voltage available. Some types can be driven directly from the ESP.
:green:`+` No mechanical parts, no wearing out.
:green:`+` No contact bumping.
:green:`+` No voltage peaks on the low voltage side.
:green:`+` Available for very high current for an affordable price.
:red:`-` Very sensitive to overvoltage and overcurrent.
:red:`-` No NC available usually.
:red:`-` Usually with only one or sometimes three "normally open" circuits.
:red:`-` Needs cooling! Smaller relays up to 5A must be mounted with at least 1cm distance to other parts.
:red:`-` Bigger relays usually need a heat sink. Watch out:Heat sink may carry mains voltage with some types!
:red:`-` Leak current! These relays leak some current even if switched off.
Leak currents
~~~~~~~~~~~~~
Leak Current from SSR's might lead into problems under certain circumstances.
The both types shown above ("Hoymk D3805KH" and "Mager GJ-6-L", 5A AC) were tested here.
The Mager GJ-5-L showed a low leaking current and is useable for most purposes.
The D3805HK showed a really high leaking current, enough for a 10W LED to glow and a small solenoid valve to keep open!
This is not recommended for normal use.
Meanwhile a third sample arrived: The SSR-D32A380/5 sold by Pollin.
Similar to the D3805HK it shows a leaking current, as the test LED is slightly glowing in the dark when off.
It seems to be a lower leaking then with the D3805HK, this is subject to some further investigation.
The advantage of the Pollin SSR: It contains a small LED on the top indicating if the relay is on.
This SSR is a bit bigger then the other two types tested, it just fits the case. So holes for the LEDs
can be drilled on the top side of the case.
..danger::
Always remember that a switched-off SSR is not completely switched off!
Even a small leaking current is enough to give a shock. Nice surprise if you're on the ladder changing bulbs....
Choosing your relay
~~~~~~~~~~~~~~~~~~~
Which relay should be used?
Well, this depends on what you want to switch. If you control a heavy motor or pump, I'd always prefer a mechanical relay.
The resistance against short overcurrent is a good point here.
For experimenting we prefer mechanical relays too - we just love the "click" sound, i.e. we don't have to connect a load to see if it works.
If noise counts or if you place the relay in a dusty or humid environment a SSR is the better choice. It's completely encapsulated so dust
and humidity can't damage it. As it has no mechanical parts it is completely noise-free. So it's the perfect choice to switch lighting in a living room or sleeping room.
Of course you have to chose a relay that fits your parameters.
Which voltage you want to switch? AC or DC? Which current?
If you want to use a SSR for high current you have to calculate the space for a heat sink and you have to use a vented case. All these parameters
have to be figured into your project. It is also possible to use a small SSR to drive a really heavy external relay for a heavy machine for example.
Wiring
------
..code-block::html
ESP Relay (board)
GPIO (X) <--> IN1
GPIO (Y) <--> IN2
Power
5.0V <--> VCC
GND <--> GND
Setup
-----
No device is needed, generally you use rules to activate relays, or you send commands to activate them. Below you
find more information on how to do this.
..note::
If you want to monitor and have the GPIO state published you do this by adding as a |P001_typename| ,
it will not be a switch per say but you will get the state published automatically.
Rules examples
--------------
..code-block::html
On Switch#State Do
if [Switch#State]=1
GPIO,12,1
else
GPIO,12,0
endif
EndOn
This rule will turn the relay ON when the button is pressed, and OFF when released.
Indicators (recommended settings)
---------------------------------
No device is needed.
Commands
--------
..include:: P001_commands_GPIO.repl
How to connect your relay
-------------------------
You can connect the relay in multiple ways, we explain them all below.
Basic ESP circuit: mechanical relays
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The basic circuit is simple.
As the relay usually consumes more current as the ESP can handle it needs a transistor or FET to drive the relay.
To suppress the voltage peak when switching off the coil a free-wheeling diode is needed. This can be a standard silicium diode, a 1N4148 for example.
..image:: P000_Relay_5.jpg
Well, there is another way to switch the relay. In the above example we used a NPN transistor or a N-channel FET. A PNP transistor or P-Channel FET can be used too.
Some board manufacturers do this and now we run into problems promptly. The relays usually need some higher voltage then the ESP, 5V or 12 V in most cases.
The PNP transistor in the example is connected to +5V. It will switch the relay to "on" if the voltage at the input is at least 0.7V below the Vcc of 5V.
The ESP delivers a maximum of 3.3V if the GPIO is "high", around 0.5V if it is "low". Both voltages are far below the 5V-0.7V = 4.3V threshhold of the relay board.
The relay is permanently on, no matter what your ESP says. We can get this to work in a simple way with a 5V relay board. A standard diode has a loss of around 0.7V.
We can use this to get a higher output level from the ESP. We simply use two diodes in the connection between relay board and ESP. This raises the voltage from the
ESP up to 3.3v + 1.4V = 4.7V. This is above the threshhold of 4.3V. If the board uses a FET it might be necessary to use three diodes. That usually will work.
On top: This circuit switches the relay off if the GPIO is "high", this leading to irritations sometimes.
The picture shows the basic circuit with a PNP transistor, and the " 2 Diodes " solution:
..image:: P000_Relay_6.jpg
More complex: using an opto coupler
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Many widespread relay boards use opto couplers. Honestly we don't know the reason besides it looks good in advertising.
In theory the opto coupler isolates the relay coil from the ESP circuit. Well, that's nice theory. In real world we use the same power supply for relays and ESP.
This bridges the opto coupler as the circuits are connected via power supply making the opto coupler completely useless. Anyways the relay isolates the load from
the ESP anyways. It might be useful only if relay switching interferes with the ESP. In this case you might try a separate power supply for relay coils.
This isolates the ESP completely from the coil circuits. Note that a jumper has to be set for that on some boards.
Again there are two possible ways to use this circuit. The opto coupler input has one pin to the ESP and one to ground - this works without any problem but it is not widespread.
..image:: P000_Relay_7.jpg
Most boards we've seen connect the opto coupler to 5V or 12V and the other input pin to the ESP.
..image:: P000_Relay_8.jpg
This runs into same issues as with the PNP transistor above. The high voltage of 3.3V from ESP is far below 5V, this keeping the relay permanently active.
The solution is same as with the transistor board above. Use some diodes between ESP and relay board usually does the job with relay boards using 5V.
Depending on the circuit you will have to experiment how many diodes are necessary.
Boards with 12V
~~~~~~~~~~~~~~~
If your relay board uses 12V and needs "Low" to switch the relay on it gets somewhat more complex. Basically it is possible to use a lot of diodes but
it's not very handy. You may try a Zener diode of around 8.5.. 8.7 V. Honestly we don't recommend it. In this case it is better to use an additional
transistor or FET to get it to work. This has one advantage: It inverts the switching signal so a "low" output says the relay is off.
..image:: P000_Relay_9.jpg
Special designed boards
~~~~~~~~~~~~~~~~~~~~~~~
There are some boards in the wild which can be configured if "low" or "high" should switch the relay on.
With this boards you will have to experiment a bit with your ESP and the board, there should be a combination that works.
..image:: P000_Relay_10.jpg
Note the jumpers down left - that's the configuration for switching on high or low level.
Basic ESP circuit: SSR
~~~~~~~~~~~~~~~~~~~~~~
This is more simple. If you got a SSR that has an input of "3...12V" or "3...30V" it usually can be driven directly from the ESP.
The only thing you should keep in mind: Do not omit the varistor (RVx in the schematics). It protects the SSR from voltage peaks that
may kill it within some milliseconds. Instead of the varistor a TVS diode can be used, for example a P6K400CA.
Be careful, you have to use a bidirectional type!
..image:: P000_Relay_11.jpg
It is possible to direct drive a SSR from the ESP but we won't recommend this. We prefer the same circuit as with the mechanical relay.
It makes the relay circuit more universal and reduces load on the ESP.
..image:: P000_Relay_12.jpg
Instead of the 2N2222/BC547 you may use a small FET, a BSS138 or 2N7000 / 7002. Omit the 22K resistor if useing a FET.
R2 is needed if your relay can't take the Vcc directly. If you use a "3...30V" input SSR it's not necessary.
Any opto coupler is completely needless if you use a SSR. The SSR has an opto coupler built in to isolate the load from the ESP.
At this time there are not that much relay boards with SSR in the market, this will change over time as they get more popular.
From what is on the market be careful what you buy. Most boards we've seen nowadays on AliExpress and Ebay have a DC relay installed - they can switch DC only! They can't switch mains voltage.
Some words about DIY relay boards
---------------------------------
All in all it's no problem to build your own relay board fitting your needs exactly. But watch out if you want to switch
mains voltage. There is a reason why in some countries the policies specify a minimum distance between the parts with high
voltage and the low voltage circuits. Do not use experimental PCB's with copper pads or stripes!
Good breakout boards are milled out, there is a gap in the PCB for isolating mains from low voltage.
Prefer these boards over others without milling.
..danger::
Be very careful - mains voltage can burn your home or kill you. In case of doubt ask an expert!
RTTTL (Ring Tone [Text] Transfer Language) was developed by Nokia to play more "easy on the ear" melodies as ringtones for mobile phones. The tunes over all characteristics are created by using three different commands:
**d** - duration
**o** - octave
**b** - tempo (beat)
After that the actual tune is then created using standard notes (a, b, c, d, e, f, and g), before the note the duration is set, after the note the octave is set:
..code-block::html
<duration><note><octave>
To compose a jingle you separate the notes with a comma.
Specifications:
* Output sound
Wiring
------
..code-block::html
ESP Speaker
GPIO <--> Positive (red)
GND <--> Negative (black)
Setup
-----
No device is needed, generally you use rules to activate different notifications, or you send commands to activate them. Below you find more information on how to do this.
Rules examples
--------------
From ESP Easy v2.0.0 its possible to play melodies via `RTTTL <https://en.wikipedia.org/wiki/Ring_Tone_Transfer_Language#Technical_specification>`_ (don't forget to remove the spaces and replace # with -, this might be fixed in future releases):
As described already, each task can produced one or more events, one for each measured value. You should not name your devices and value names so that the combination equals to any of the below listed system events!
","
.. code-block:: html
on DHT11Outside#Temperature>20 do
GPIO,2,1
endon
"
"
``System#Wake``
Triggered after power on.
","
.. code-block:: html
on System#Wake do
GPIO,15,1
endon
"
"
``System#Boot``
Triggered at boot time.
","
.. code-block:: html
on System#Boot do
GPIO,2,1
timerSet,1,30
endon
"
"
``System#Sleep``
Triggered just before the ESP goes to deep sleep.
","
.. code-block:: html
on System#Sleep do
GPIO,2,0
endon
"
"
``MQTT#Connected``
Triggered when the ESP has connected to broker.
","
.. code-block:: html
on MQTT#Connected do
Publish,%sysname%/status,First message!
endon
"
"
``MQTT#Disconnected``
Triggered when the ESP has disconnected from the broker.
","
.. code-block:: html
on MQTT#Disconnected do
Reboot
endon
"
"
``MQTTimport#Connected``
Triggered when the ESP has connected to broker (the MQTT Import plugin uses a separate connection than the generic one).
","
.. code-block:: html
on MQTTimport#Connected do
Publish,%sysname%/status,MQTT Import is now operational
endon
"
"
``MQTTimport#Disconnected``
Triggered when the ESP has disconnected from the broker (the MQTT Import plugin uses a separate connection than the generic one).
Triggered when the ESP has changed to access point, will also trigger first time the unit connects to the Wi-Fi.
","
.. code-block:: html
on WiFi#ChangedAccesspoint do
Publish,%sysname%/status,AP changed
endon
"
"
``WiFi#APmodeEnabled``
Triggered when the ESP has set the AP mode (access point) active.
This may happen when no valid WiFi settings are found or the ESP cannot connect to the set AP, but it can also be enabled via some command.
N.B. Sending a publish command may not be very useful on this event, since this will mainly happen when there is no WiFi connection.
","
.. code-block:: html
on WiFi#APmodeEnabled do
... // Some command
endon
"
"
``WiFi#APmodeDisabled``
Triggered when the ESP has disabled the AP mode (access point).
This can happen some time (default 60 seconds) after a WiFi connection has been made. Or disabled using some command.
","
.. code-block:: html
on WiFi#APmodeDisabled do
Publish,%sysname%/status,AP disabled
endon
"
"
``Login#Failed``
Triggered when (someone) has tried to login to a ESP unit with admin password enabled, but have failed to enter correct password.
","
.. code-block:: html
on Login#Failed do
Publish,%sysname%/warning,Intruder alert!
endon
"
"
``Time#Initialized``
Triggered the first time (after boot) NTP is updating the unit.
","
.. code-block:: html
on Time#Initialized do
Publish,%sysname%/Time,%systime%
endon
"
"
``Time#Set``
Triggered when the time is set by an update from NTP.
","
.. code-block:: html
on Time#Set do
Publish,%sysname%/Time,%systime%
Publish,%sysname%/NTP,Updated time at: %systime%
endon
"
"
``Rules#Timer=``
As described already, triggered when a rules timer ends (setting a timer to 0 will disable the timer).
","
.. code-block:: html
on Rules#Timer=1 do
GPIO,2,1
endon
"
"
``Clock#Time=``
Triggered every minute with day and time like: Mon,12:30 or Tue,14:45. You can define triggers on specific days or all days using 'All' for days indicator. You can also use wildcards in the time setting like All,**:00 to run every hour.
","
.. code-block:: html
on Clock#Time=All,12:00 do //will run once a day at noon
GPIO,2,1
endon
on Clock#Time=All,**:30 do //will run half past every hour
GPIO,2,1
endon
on Clock#Time=All,%sunrise% do //will run at sunrise (%sunset% is also available)
GPIO,2,1
endon
"
"
``GPIO#N``
If the command 'Monitor' is used to monitor a given pin you will receive an event for that GPIO as soon as it's state changes. As seen in the example you can always use the square brackets together with the task/value name of ``Plugin#GPIO#Pinstate#N`` to get the state, but to trigger events you need to add the monitor command (preferably at boot).
"State", "State", "0", "N/A", "Usually you just want the state being published when door is actually being opened/closed. If you want a continuous publishing of the state you may use the interval setting to do so."
"State", "Detection", "0", "N/A", "Usually you just want the state being published when door is actually being opened/closed. If you want a continuous publishing of the state you may use the interval setting to do so."
"State", "State", "0", "N/A", "Usually you just want the state being published when an actual push has been happening. If you want a continuous publishing of the state you may use the interval setting to do so."
We can control a pin with simple http URL commands. To change the pin to high or low steady output. Setting GPIO to **2** means
that it will be able to detect low level relays (with high impedance, Z).
"
"
``GPIOtoggle,<GPIO>``
GPIO: 0 ... 16
","
**Toggle on/off.**.
Toggle the current (output) state of the given GPIO pin.
This will only be executed on pins set to be in output mode.
"
"
``LongPulse,<GPIO>,<state>,<duration>``
GPIO: 0 ... 16
State: 1/0
Duration: 1 ... 999 S
","
**To send a *long* pulse to a certain pin.**.
A long pulse is basically the same as the plain pulse. Duration is defined in seconds, which makes it more suitable for longer duration.
This command is not blocking, but will send 2 events to start and stop the pulse. This may have some variation depending on the system load of the module.
Variation is typically up-to 10 msec, but may be up-to a second, depending on active plugins and controllers performing blocking operations.
"
"
``LongPulse_mS,<GPIO>,<state>,<duration>``
GPIO: 0 ... 16
State: 1/0
Duration: 10 ... 15000 msec
","
**To send a *long* pulse to a certain pin.**
A ``LongPulse_mS`` is the same as the regular ``LongPulse``. The only difference is the time base in milliseconds rather than in seconds.
"
"
``Pulse,<GPIO>,<state>,<duration>``
GPIO: 0 ... 16
State: 1/0
Duration: 0 ... 1000 msec
","
**To send a *short* pulse to a certain pin.**
Example to send an active high (1) pulse on GPIO 14 for 500 mSeconds. Pulse duration is in milliseconds. State is 1 or 0.
N.B. this is a blocking call, meaning no other actions will be performed during the pulse.
"
"
``PWM,<GPIO>,<duty>``
``PWM,<GPIO>,<duty>,<duration>``
``PWM,<GPIO>,<duty>,<duration>,<frequency>``
GPIO: 0 ... **15**
Duty: 0 ... 1023
Duration: 100 ... 15000 msec (optional)
Frequency: 100 ... 40000 Hz (optional)
","
**To set a certain PWM level.**
If you have set a certain GPIO to a PWM level and want to use it as a regular HIGH/LOW pin you need to reset by setting the PWM level to 0.
Duration (in msec) parameter will create a fading.
Value of 0 will not set a duration.
Frequency (in Hz) will be set to 1000 Hz when not given.
Frequencies above 30 kHz are not stable and will likely crash the ESP.
"
"
``Servo,<servo>,<GPIO>,<position>``
GPIO: 0 ... **15**
Servo: 1/2
Position: -180 ... 180 (see warning below)
","
**To control a servo motor.**
We currently support a maximum of two servo motors so you can build a pan & tilt device if you like.
.. warning::
Most servos are not able to turn full 360°! Normally the servos are able to go from **-90°** to **90°**, some rare servos do allow for -135° to 135°.
A position value of 9000 will stop the PWM signal.
This can be useful to save energy on servos which do not need power to remain at the same position.
"
"
``Monitor,<GPIO>``
GPIO: 0 ... 16
","
**To monitor a GPIO state.**
By the use of the command you will receive events when the GPIO state of that pin is changed from 1 to 0 and from 0 to 1.
"
"
``GPIOtoggle,<GPIO>``
GPIO: 0 ... 16
","
**To toggle a GPIO state.**
With this command you can change the given state of a pin from either 1 to 0 or from 0 to 1.
Some files were not shown because too many files have changed in this diff
Show More
Reference in New Issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.