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
Introduction and wiki: https://www.letscontrolit.com/wiki/index.php/ESPEasy#Introduction
This is the development branch for the next upcoming release (2.0.0). This is also known as ESPEasyMega.
**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:
Next stable branch: https://github.com/letscontrolit/ESPEasy/tree/v2.0 (bug fixes only, since oct 2017))
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
## Versions
* v2.0.0-devX: these are the current development releases. use these if you want bleeding edge features, or if you want to help us testing and developing. new release every month.
* v2.0.0-betaX: as soon as we think its stable/complete enough for real testing, we will start numbering beta's.
#define SENSORS_MAGFIELD_EARTH_MAX (60.0F) /**< Maximum magnetic field on Earth's surface */
#define SENSORS_MAGFIELD_EARTH_MIN (30.0F) /**< Minimum magnetic field on Earth's surface */
#define SENSORS_PRESSURE_SEALEVELHPA (1013.25F) /**< Average sea level pressure is 1013.25 hPa */
#define SENSORS_DPS_TO_RADS (0.017453293F) /**< Degrees/s to rad/s multiplier */
#define SENSORS_GAUSS_TO_MICROTESLA (100) /**< Gauss to micro-Tesla multiplier */
/** Sensor types */
typedefenum
{
SENSOR_TYPE_ACCELEROMETER=(1),/**< Gravity + linear acceleration */
SENSOR_TYPE_MAGNETIC_FIELD=(2),
SENSOR_TYPE_ORIENTATION=(3),
SENSOR_TYPE_GYROSCOPE=(4),
SENSOR_TYPE_LIGHT=(5),
SENSOR_TYPE_PRESSURE=(6),
SENSOR_TYPE_PROXIMITY=(8),
SENSOR_TYPE_GRAVITY=(9),
SENSOR_TYPE_LINEAR_ACCELERATION=(10),/**< Acceleration not including gravity */
SENSOR_TYPE_ROTATION_VECTOR=(11),
SENSOR_TYPE_RELATIVE_HUMIDITY=(12),
SENSOR_TYPE_AMBIENT_TEMPERATURE=(13),
SENSOR_TYPE_VOLTAGE=(15),
SENSOR_TYPE_CURRENT=(16),
SENSOR_TYPE_COLOR=(17)
}sensors_type_t;
/** struct sensors_vec_s is used to return a vector in a common format. */
typedefstruct{
union{
floatv[3];
struct{
floatx;
floaty;
floatz;
};
/* Orientation sensors */
struct{
floatroll;/**< Rotation around the longitudinal axis (the plane body, 'X axis'). Roll is positive and increasing when moving downward. -90°<=roll<=90° */
floatpitch;/**< Rotation around the lateral axis (the wing span, 'Y axis'). Pitch is positive and increasing when moving upwards. -180°<=pitch<=180°) */
floatheading;/**< Angle between the longitudinal axis (the plane body) and magnetic north, measured clockwise when viewing from the top of the device. 0-359° */
};
};
int8_tstatus;
uint8_treserved[3];
}sensors_vec_t;
/** struct sensors_color_s is used to return color data in a common format. */
typedefstruct{
union{
floatc[3];
/* RGB color space */
struct{
floatr;/**< Red component */
floatg;/**< Green component */
floatb;/**< Blue component */
};
};
uint32_trgba;/**< 24-bit RGBA value */
}sensors_color_t;
/* Sensor event (36 bytes) */
/** struct sensor_event_s is used to provide a single sensor event in a common format. */
typedefstruct
{
int32_tversion;/**< must be sizeof(struct sensors_event_t) */
int32_tsensor_id;/**< unique sensor identifier */
int32_ttype;/**< sensor type */
int32_treserved0;/**< reserved */
int32_ttimestamp;/**< time is in milliseconds */
union
{
floatdata[4];
sensors_vec_tacceleration;/**< acceleration values are in meter per second per second (m/s^2) */
sensors_vec_tmagnetic;/**< magnetic vector values are in micro-Tesla (uT) */
sensors_vec_torientation;/**< orientation values are in degrees */
sensors_vec_tgyro;/**< gyroscope values are in rad/s */
floattemperature;/**< temperature is in degrees centigrade (Celsius) */
floatdistance;/**< distance in centimeters */
floatlight;/**< light in SI lux units */
floatpressure;/**< pressure in hectopascal (hPa) */
floatrelative_humidity;/**< relative humidity in percent */
floatcurrent;/**< current in milliamps (mA) */
floatvoltage;/**< voltage in volts (V) */
sensors_color_tcolor;/**< color in RGB component values */
};
}sensors_event_t;
/* Sensor details (40 bytes) */
/** struct sensor_s is used to describe basic information about a specific sensor. */
typedefstruct
{
charname[12];/**< sensor name */
int32_tversion;/**< version of the hardware + driver */
int32_tsensor_id;/**< unique sensor identifier */
int32_ttype;/**< this sensor's type (ex. SENSOR_TYPE_LIGHT) */
floatmax_value;/**< maximum value of this sensor's value in SI units */
floatmin_value;/**< minimum value of this sensor's value in SI units */
floatresolution;/**< smallest difference between two values reported by this sensor */
int32_tmin_delay;/**< min delay in microseconds between events. zero = not a constant rate */
Many small embedded systems exist to collect data from sensors, analyse the data, and either take an appropriate action or send that sensor data to another system for processing.
One of the many challenges of embedded systems design is the fact that parts you used today may be out of production tomorrow, or system requirements may change and you may need to choose a different sensor down the road.
Creating new drivers is a relatively easy task, but integrating them into existing systems is both error prone and time consuming since sensors rarely use the exact same units of measurement.
By reducing all data to a single **sensors\_event\_t** 'type' and settling on specific, **standardised SI units** for each sensor family the same sensor types return values that are comparable with any other similar sensor. This enables you to switch sensor models with very little impact on the rest of the system, which can help mitigate some of the risks and problems of sensor availability and code reuse.
The unified sensor abstraction layer is also useful for data-logging and data-transmission since you only have one well-known type to log or transmit over the air or wire.
## Unified Sensor Drivers ##
The following drivers are based on the Adafruit Unified Sensor Driver:
Any driver that supports the Adafruit unified sensor abstraction layer will implement the Adafruit\_Sensor base class. There are two main typedefs and one enum defined in Adafruit_Sensor.h that are used to 'abstract' away the sensor details and values:
**Sensor Types (sensors\_type\_t)**
These pre-defined sensor types are used to properly handle the two related typedefs below, and allows us determine what types of units the sensor uses, etc.
```
/** Sensor types */
typedef enum
{
SENSOR_TYPE_ACCELEROMETER = (1),
SENSOR_TYPE_MAGNETIC_FIELD = (2),
SENSOR_TYPE_ORIENTATION = (3),
SENSOR_TYPE_GYROSCOPE = (4),
SENSOR_TYPE_LIGHT = (5),
SENSOR_TYPE_PRESSURE = (6),
SENSOR_TYPE_PROXIMITY = (8),
SENSOR_TYPE_GRAVITY = (9),
SENSOR_TYPE_LINEAR_ACCELERATION = (10),
SENSOR_TYPE_ROTATION_VECTOR = (11),
SENSOR_TYPE_RELATIVE_HUMIDITY = (12),
SENSOR_TYPE_AMBIENT_TEMPERATURE = (13),
SENSOR_TYPE_VOLTAGE = (15),
SENSOR_TYPE_CURRENT = (16),
SENSOR_TYPE_COLOR = (17)
} sensors_type_t;
```
**Sensor Details (sensor\_t)**
This typedef describes the specific capabilities of this sensor, and allows us to know what sensor we are using beneath the abstraction layer.
```
/* Sensor details (40 bytes) */
/** struct sensor_s is used to describe basic information about a specific sensor. */
typedef struct
{
char name[12];
int32_t version;
int32_t sensor_id;
int32_t type;
float max_value;
float min_value;
float resolution;
int32_t min_delay;
} sensor_t;
```
The individual fields are intended to be used as follows:
- **name**: The sensor name or ID, up to a maximum of twelve characters (ex. "MPL115A2")
- **version**: The version of the sensor HW and the driver to allow us to differentiate versions of the board or driver
- **sensor\_id**: A unique sensor identifier that is used to differentiate this specific sensor instance from any others that are present on the system or in the sensor network
- **type**: The sensor type, based on **sensors\_type\_t** in sensors.h
- **max\_value**: The maximum value that this sensor can return (in the appropriate SI unit)
- **min\_value**: The minimum value that this sensor can return (in the appropriate SI unit)
- **resolution**: The smallest difference between two values that this sensor can report (in the appropriate SI unit)
- **min\_delay**: The minimum delay in microseconds between two sensor events, or '0' if there is no constant sensor rate
**Sensor Data/Events (sensors\_event\_t)**
This typedef is used to return sensor data from any sensor supported by the abstraction layer, using standard SI units and scales.
```
/* Sensor event (36 bytes) */
/** struct sensor_event_s is used to provide a single sensor event in a common format. */
typedef struct
{
int32_t version;
int32_t sensor_id;
int32_t type;
int32_t reserved0;
int32_t timestamp;
union
{
float data[4];
sensors_vec_t acceleration;
sensors_vec_t magnetic;
sensors_vec_t orientation;
sensors_vec_t gyro;
float temperature;
float distance;
float light;
float pressure;
float relative_humidity;
float current;
float voltage;
sensors_color_t color;
};
} sensors_event_t;
```
It includes the following fields:
- **version**: Contain 'sizeof(sensors\_event\_t)' to identify which version of the API we're using in case this changes in the future
- **sensor\_id**: A unique sensor identifier that is used to differentiate this specific sensor instance from any others that are present on the system or in the sensor network (must match the sensor\_id value in the corresponding sensor\_t enum above!)
- **type**: the sensor type, based on **sensors\_type\_t** in sensors.h
- **timestamp**: time in milliseconds when the sensor value was read
- **data[4]**: An array of four 32-bit values that allows us to encapsulate any type of sensor data via a simple union (further described below)
**Required Functions**
In addition to the two standard types and the sensor type enum, all drivers based on Adafruit_Sensor must also implement the following two functions:
```
bool getEvent(sensors_event_t*);
```
Calling this function will populate the supplied sensors\_event\_t reference with the latest available sensor data. You should call this function as often as you want to update your data.
```
void getSensor(sensor_t*);
```
Calling this function will provide some basic information about the sensor (the sensor name, driver version, min and max values, etc.
**Standardised SI values for sensors\_event\_t**
A key part of the abstraction layer is the standardisation of values on SI units of a particular scale, which is accomplished via the data[4] union in sensors\_event\_t above. This 16 byte union includes fields for each main sensor type, and uses the following SI units and scales:
- **acceleration**: values are in **meter per second per second** (m/s^2)
- **magnetic**: values are in **micro-Tesla** (uT)
- **orientation**: values are in **degrees**
- **gyro**: values are in **rad/s**
- **temperature**: values in **degrees centigrade** (Celsius)
- **distance**: values are in **centimeters**
- **light**: values are in **SI lux** units
- **pressure**: values are in **hectopascal** (hPa)
- **relative\_humidity**: values are in **percent**
- **current**: values are in **milliamps** (mA)
- **voltage**: values are in **volts** (V)
- **color**: values are in 0..1.0 RGB channel luminosity and 32-bit RGBA format
## The Unified Driver Abstraction Layer in Practice ##
Using the unified sensor abstraction layer is relatively easy once a compliant driver has been created.
Every compliant sensor can now be read using a single, well-known 'type' (sensors\_event\_t), and there is a standardised way of interrogating a sensor about its specific capabilities (via sensor\_t).
An example of reading the [TSL2561](https://github.com/adafruit/Adafruit_TSL2561) light sensor can be seen below:
Thank you for opening an issue on an Adafruit Arduino library repository. To
improve the speed of resolution please review the following guidelines and
common troubleshooting steps below before creating the issue:
- **Do not use GitHub issues for troubleshooting projects and issues.** Instead use
the forums at http://forums.adafruit.com to ask questions and troubleshoot why
something isn't working as expected. In many cases the problem is a common issue
that you will more quickly receive help from the forum community. GitHub issues
are meant for known defects in the code. If you don't know if there is a defect
in the code then start with troubleshooting on the forum first.
- **If following a tutorial or guide be sure you didn't miss a step.** Carefully
check all of the steps and commands to run have been followed. Consult the
forum if you're unsure or have questions about steps in a guide/tutorial.
- **For Arduino projects check these very common issues to ensure they don't apply**:
- For uploading sketches or communicating with the board make sure you're using
a **USB data cable** and **not** a **USB charge-only cable**. It is sometimes
very hard to tell the difference between a data and charge cable! Try using the
cable with other devices or swapping to another cable to confirm it is not
the problem.
- **Be sure you are supplying adequate power to the board.** Check the specs of
your board and plug in an external power supply. In many cases just
plugging a board into your computer is not enough to power it and other
peripherals.
- **Double check all soldering joints and connections.** Flakey connections
cause many mysterious problems. See the [guide to excellent soldering](https://learn.adafruit.com/adafruit-guide-excellent-soldering/tools) for examples of good solder joints.
- **Ensure you are using an official Arduino or Adafruit board.** We can't
guarantee a clone board will have the same functionality and work as expected
with this code and don't support them.
If you're sure this issue is a defect in the code and checked the steps above
please fill in the following fields to provide enough troubleshooting information.
You may delete the guideline and text above to just leave the following details:
#define TSL2591_COMMAND_BIT (0xA0) // 1010 0000: bits 7 and 5 for 'command normal'
#define TSL2591_CLEAR_INT (0xE7)
#define TSL2591_TEST_INT (0xE4)
#define TSL2591_WORD_BIT (0x20) // 1 = read/write word (rather than byte)
#define TSL2591_BLOCK_BIT (0x10) // 1 = using block read/write
#define TSL2591_ENABLE_POWEROFF (0x00)
#define TSL2591_ENABLE_POWERON (0x01)
#define TSL2591_ENABLE_AEN (0x02) // ALS Enable. This field activates ALS function. Writing a one activates the ALS. Writing a zero disables the ALS.
#define TSL2591_ENABLE_AIEN (0x10) // ALS Interrupt Enable. When asserted permits ALS interrupts to be generated, subject to the persist filter.
#define TSL2591_ENABLE_NPIEN (0x80) // No Persist Interrupt Enable. When asserted NP Threshold conditions will generate an interrupt, bypassing the persist filter
This is an Arduino library for the TSL2591 digital luminosity (light) sensors.
Pick one up at http://www.adafruit.com/products/1980
To download. click the DOWNLOADS button in the top right corner, rename the uncompressed folder Adafruit_TSL2591. Check that the Adafruit_TSL2591 folder contains Adafruit_TSL2591.cpp and Adafruit_TSL2591.h
Place the Adafruit_TSL2591 library folder your <arduinosketchfolder>/libraries/ folder. You may need to create the libraries subfolder if its your first library. Restart the IDE.
You'll also need the Adafruit_Sensor library from https://github.com/adafruit/Adafruit_Sensor
paragraph=With this library an ESP8266 can ping a remote machine and know if it's reachable. It provide some basic measurements on ping messages (avg response time). Lib name renamed to avoid conflicts in Arduino IDE.
HLW8012 library for Arduino and ESP8266 using the [Arduino Core for ESP8266][1].

This is the IC present in some chinese products like [Itead's Sonoff POW][2].
The HLW8012 is a current, voltage and power monitor IC that outputs a pulse of a frequency inversely proportional to the value to be read.
This IC provides two PWM outputs, the first one for power and the second one for current or voltage, depending on the SEL pin. The output values are always RMS. Power measurements are very consistent but current or voltage measurements require a minimum time lapse after changing the SEL pin value to become stable. This fact reduces sampling frequency.
Higher values (of power, current or voltage) mean shorter pulses.
Typical values are:
* A 1Hz pulse on CF pin means around 12W RMS
* A 1Hz pulse on CF1 pin means 15mA or 0.5V RMS depending on the value in SEL pin
These ratios are per datasheet typical application, but the actual circuitry might be different.
Even if the circuit matches that on the datasheet the IC tolerances are quite loosy (+-15% for clock frequency, for instance).
## Features
The main features of the HLW8012 library are:
* Two available modes: interrupt-driven or non-interrupt-driven.
* Default calibration based on product datasheet (3.1 Typical Applications).
* You can specify the resistor values for your circuit.
* Optional manual calibration based on expected values.
## Usage
Check the examples for indications on how to use the library.
### Interrupt driven mode
When using interrupts, values are monitored in the background. When calling the get***() methods the last sampled value is returned, this value might be up to a few seconds old if they are very low values. This is specially obvious when switching off the load. The new value of 0W or 0mA is ideally represented by infinite-length pulses. That means that the interrupt is not triggered, the value does not get updated and it will only timeout after 2 seconds (configurable through the pulse_timeout parameter in the begin() method). During that time lapse the library will still return the last non-zero value.
### Non interrupt mode
On the other hand, when not using interrupts, you have to let some time for the pulses in CF1 to stabilize before reading the value. So after calling setMode or toggleMode leave 2 seconds minimum before calling the get methods. The get method for the current mode will measure the pulse width and return the corresponding value, the other one will return the cached value (or 0 if none).
Use non-interrupt approach and a low pulse_timeout (200ms) only if you are deploying a battery powered device and you care more about your device power consumption than about precission. But then you should know the HLW8012 takes about 15mW...
### Notes
I've put together this library after doing a lot of tests with a Sonoff POW[2]. The HLW8012 datasheet (in the "docs" folder) gives some information but I couldn't find any about this issue in the CF1 line that requires some time for the pulse length to stabilize (apparently). Any help about that will be very welcome.
## Manual calibration
Use a pure resistive load with a well-known power consumption or use a multimeter to monitor it. A bulb is usually a good idea, although a toaster would be better since it's power consumption is higher.
Then use the expected*() methods and feed the values. For instance, for a 60W bulb in a 230 line that would be:
voidsendJVC(unsignedlongdata,intnbits,intrepeat);// *Note instead of sending the REPEAT constant if you want the JVC repeat signal sent, send the original code value and change the repeat argument from 0 to 1. JVC protocol repeats by skipping the header NOT by sending a separate code value like NEC does.
paragraph=The library allows to control I2C displays with functions extremely similar to LiquidCrystal library. THIS LIBRARY MIGHT NOT BE COMPATIBLE WITH EXISTING SKETCHES.
/** Gets the actual counter value as long operator.
*
*@returnActualcountervalueaslongoperator
*/
operatorlong(){// int-Operator
returnread();
}
/** Sets the counter value at actual encoder position to given value.
*
*@paramCountervalue
*/
voidwrite(longcounter){
_counter=counter;
}
/** Sets the counter value at actual encoder position to given value as assign operator.
*
*@paramCountervalue
*/
intoperator=(longcounter){// Assign-Operator
write(counter);
returncounter;
}
voidsetLimit(longlimitMin,longlimitMax)
{
_limitMin=limitMin;
_limitMax=limitMax;
}
/** Sets the flag for zeroing on next high on index pin while AB lines triggers next counting. The trigger calls tha callback function in which the counter can be set to zero or the actual counter can be latched in for later offset calculation
Arduino library for reading and debouncing mechanical inputs Like buttons, switches and encoders.
After downloading, rename folder to 'MechInputs' and install in Arduino Libraries folder. Restart Arduino IDE, then open File->Sketchbook->Library->MechInputs->* sketches.
# QEI (quadrature encoder interface) library, for decoding AB signals from a rotary encoder
Use cases:
- Rotary encoder in closed loop motor regulation
- Hand wheel
- Input device for motion control (MoCo)
A class to decode pulses on a rotary encoder with AB signals (quadrature encoder).
It uses all 4 edges of the AB signals to increase the counter resolution 4 times of cycles per rotation/revolution (CPR) (e.g. an encoder with 500 CPR get 2000 counts per rotation)
In opposite to most common QEI implementation this is resistant to jitter and chatter on AB signals and motor vibrations.
Whes reaching the next position the edge that triggerd this position (state) is ignored to aboid oscillating up/down counts.
It can also be used in polling mode i.g. in idle routines if interrupts are not desired.
At this mode be sure that the sampling frequency is heigher than the maximum rotation speed (expeced counts per second)
The internal state machine is based on a look up table (LUT) to minimize interrupt retention time and get all necessary flags at once.
The library is designed to support closed loop speed- and motion-controller for also slow and smooth motions like movie camera motion control.
_triggerBit=digitalPinToBitMask(trigger_pin);// Get the port register bitmask for the trigger pin.
_echoBit=digitalPinToBitMask(echo_pin);// Get the port register bitmask for the echo pin.
_triggerOutput=portOutputRegister(digitalPinToPort(trigger_pin));// Get the output port register for the trigger pin.
_echoInput=portInputRegister(digitalPinToPort(echo_pin));// Get the input port register for the echo pin.
_triggerMode=(uint8_t*)portModeRegister(digitalPinToPort(trigger_pin));// Get the port mode register for the trigger pin.
#else
_triggerPin=trigger_pin;
_echoPin=echo_pin;
#endif
set_max_distance(max_cm_distance);// Call function to set the max sensor distance.
#if (defined (__arm__) && defined (TEENSYDUINO)) || DO_BITWISE != true
pinMode(echo_pin,INPUT);// Set echo pin to input (on Teensy 3.x (ARM), pins default to disabled, at least one pinMode() is needed for GPIO mode).
pinMode(trigger_pin,OUTPUT);// Set trigger pin to output (on Teensy 3.x (ARM), pins default to disabled, at least one pinMode() is needed for GPIO mode).
#endif
#if defined (ARDUINO_AVR_YUN)
pinMode(echo_pin,INPUT);// Set echo pin to input for the Arduino Yun, not sure why it doesn't default this way.
#endif
#if ONE_PIN_ENABLED != true && DO_BITWISE == true
*_triggerMode|=_triggerBit;// Set trigger pin to output.
*_triggerMode|=_triggerBit;// Set trigger pin to output.
#endif
*_triggerOutput&=~_triggerBit;// Set the trigger pin low, should already be low, but this will make sure it is.
delayMicroseconds(4);// Wait for pin to go low.
*_triggerOutput|=_triggerBit;// Set trigger pin high, this tells the sensor to send out a ping.
delayMicroseconds(10);// Wait long enough for the sensor to realize the trigger pin is high. Sensor specs say to wait 10uS.
*_triggerOutput&=~_triggerBit;// Set trigger pin back to low.
#if ONE_PIN_ENABLED == true
*_triggerMode&=~_triggerBit;// Set trigger pin to input (when using one Arduino pin, this is technically setting the echo pin to input as both are tied to the same Arduino pin).
_max_time=micros()+_maxEchoTime+MAX_SENSOR_DELAY;// Maximum time we'll wait for ping to start (most sensors are <450uS, the SRF06 can take up to 34,300uS!)
while(*_echoInput&_echoBit)// Wait for ping to start.
if(micros()>_max_time)returnfalse;// Took too long to start, abort.
_max_time=micros()+_maxEchoTime+MAX_SENSOR_DELAY;// Maximum time we'll wait for ping to start (most sensors are <450uS, the SRF06 can take up to 34,300uS!)
while(!(*_echoInput&_echoBit))// Wait for ping to start.
if(micros()>_max_time)returnfalse;// Took too long to start, abort.
#endif
#else
#if ONE_PIN_ENABLED == true
pinMode(_triggerPin,OUTPUT);// Set trigger pin to output.
#endif
digitalWrite(_triggerPin,LOW);// Set the trigger pin low, should already be low, but this will make sure it is.
delayMicroseconds(4);// Wait for pin to go low.
digitalWrite(_triggerPin,HIGH);// Set trigger pin high, this tells the sensor to send out a ping.
delayMicroseconds(10);// Wait long enough for the sensor to realize the trigger pin is high. Sensor specs say to wait 10uS.
digitalWrite(_triggerPin,LOW);// Set trigger pin back to low.
#if ONE_PIN_ENABLED == true
pinMode(_triggerPin,INPUT);// Set trigger pin to input (when using one Arduino pin, this is technically setting the echo pin to input as both are tied to the same Arduino pin).
_max_time=micros()+_maxEchoTime+MAX_SENSOR_DELAY;// Maximum time we'll wait for ping to start (most sensors are <450uS, the SRF06 can take up to 34,300uS!)
while(digitalRead(_echoPin))// Wait for ping to start.
if(micros()>_max_time)returnfalse;// Took too long to start, abort.
_max_time=micros()+_maxEchoTime+MAX_SENSOR_DELAY;// Maximum time we'll wait for ping to start (most sensors are <450uS, the SRF06 can take up to 34,300uS!)
while(!digitalRead(_echoPin))// Wait for ping to start.
if(micros()>_max_time)returnfalse;// Took too long to start, abort.
#endif
#endif
_max_time=micros()+_maxEchoTime;// Ping started, set the time-out.
#if defined (__AVR_ATmega32U4__) // Use Timer4 for ATmega32U4 (Teensy/Leonardo).
timer_stop();// Disable Timer4 interrupt.
TCCR4A=TCCR4C=TCCR4D=TCCR4E=0;
TCCR4B=(1<<CS42)|(1<<CS41)|(1<<CS40)|(1<<PSR4);// Set Timer4 prescaler to 64 (4uS/count, 4uS-1020uS range).
TIFR4=(1<<TOV4);
TCNT4=0;// Reset Timer4 counter.
#elif defined (__AVR_ATmega8__) || defined (__AVR_ATmega16__) || defined (__AVR_ATmega32__) || defined (__AVR_ATmega8535__) // Alternate timer commands for certain microcontrollers.
timer_stop();// Disable Timer2 interrupt.
ASSR&=~(1<<AS2);// Set clock, not pin.
TCCR2=(1<<WGM21|1<<CS22);// Set Timer2 to CTC mode, prescaler to 64 (4uS/count, 4uS-1020uS range).
TCNT2=0;// Reset Timer2 counter.
#elif defined (__arm__) && defined (TEENSYDUINO)
timer_stop();// Stop the timer.
#else
timer_stop();// Disable Timer2 interrupt.
ASSR&=~(1<<AS2);// Set clock, not pin.
TCCR2A=(1<<WGM21);// Set Timer2 to CTC mode.
TCCR2B=(1<<CS22);// Set Timer2 prescaler to 64 (4uS/count, 4uS-1020uS range).
TCNT2=0;// Reset Timer2 counter.
#endif
}
voidNewPing::timer_ms_cntdwn(){
if(!_ms_cnt--){// Count down till we reach zero.
intFunc2();// Scheduled time reached, run the main timer event function.
_ms_cnt=_ms_cnt_reset;// Reset the ms timer.
}
}
#if defined (__AVR_ATmega32U4__) // Use Timer4 for ATmega32U4 (Teensy/Leonardo).
ISR(TIMER4_OVF_vect){
intFunc();// Call wrapped function.
}
#elif defined (__AVR_ATmega8__) || defined (__AVR_ATmega16__) || defined (__AVR_ATmega32__) || defined (__AVR_ATmega8535__) // Alternate timer commands for certain microcontrollers.
// trigger_pin & echo_pin - Arduino pins connected to sensor trigger and echo.
// NOTE: To use the same Arduino pin for trigger and echo, specify the same pin for both values.
// max_cm_distance - [Optional] Maximum distance you wish to sense. Default=500cm.
//
// METHODS:
// sonar.ping([max_cm_distance]) - Send a ping and get the echo time (in microseconds) as a result. [max_cm_distance] allows you to optionally set a new max distance.
// sonar.ping_in([max_cm_distance]) - Send a ping and get the distance in whole inches. [max_cm_distance] allows you to optionally set a new max distance.
// sonar.ping_cm([max_cm_distance]) - Send a ping and get the distance in whole centimeters. [max_cm_distance] allows you to optionally set a new max distance.
// sonar.ping_median(iterations [, max_cm_distance]) - Do multiple pings (default=5), discard out of range pings and return median in microseconds. [max_cm_distance] allows you to optionally set a new max distance.
// NewPing::convert_in(echoTime) - Convert echoTime from microseconds to inches (rounds to nearest inch).
// NewPing::convert_cm(echoTime) - Convert echoTime from microseconds to centimeters (rounds to nearest cm).
// sonar.ping_timer(function [, max_cm_distance]) - Send a ping and call function to test if ping is complete. [max_cm_distance] allows you to optionally set a new max distance.
// sonar.check_timer() - Check if ping has returned within the set distance limit.
// NewPing::timer_us(frequency, function) - Call function every frequency microseconds.
// NewPing::timer_ms(frequency, function) - Call function every frequency milliseconds.
// NewPing::timer_stop() - Stop the timer.
//
// HISTORY:
// 07/30/2016 v1.8 - Added support for non-AVR microcontrollers. For non-AVR
// microcontrollers, advanced ping_timer() timer methods are disabled due to
// inconsistencies or no support at all between platforms. However, standard
// ping methods are all supported. Added new optional variable to ping(),
// ping_in(), ping_cm(), ping_median(), and ping_timer() methods which allows
// you to set a new maximum distance for each ping. Added support for the
// ATmega16, ATmega32 and ATmega8535 microcontrollers. Changed convert_cm()
// and convert_in() methods to static members. You can now call them without
// an object. For example: cm = NewPing::convert_cm(distance);
//
// 09/29/2015 v1.7 - Removed support for the Arduino Due and Zero because
// they're both 3.3 volt boards and are not 5 volt tolerant while the HC-SR04
// is a 5 volt sensor. Also, the Due and Zero don't support pin manipulation
// compatibility via port registers which can be done (see the Teensy 3.2).
//
// 06/17/2014 v1.6 - Corrected delay between pings when using ping_median()
// method. Added support for the URM37 sensor (must change URM37_ENABLED from
// false to true). Added support for Arduino microcontrollers like the $20
// 32 bit ARM Cortex-M4 based Teensy 3.2. Added automatic support for the
// Atmel ATtiny family of microcontrollers. Added timer support for the
// ATmega8 microcontroller. Rounding disabled by default, reduces compiled
// code size (can be turned on with ROUNDING_ENABLED switch). Added
// TIMER_ENABLED switch to get around compile-time "__vector_7" errors when
// using the Tone library, or you can use the toneAC, NewTone or
// Shouldn't need to change these values unless you have a specific need to do so.
#define MAX_SENSOR_DISTANCE 500 // Maximum sensor distance can be as high as 500cm, no reason to wait for ping longer than sound takes to travel this distance and back. Default=500
#define US_ROUNDTRIP_CM 57 // Microseconds (uS) it takes sound to travel round-trip 1cm (2cm total), uses integer to save compiled code space. Default=57
#define US_ROUNDTRIP_IN 146 // Microseconds (uS) it takes sound to travel round-trip 1 inch (2 inches total), uses integer to save compiled code space. Defalult=146
#define ONE_PIN_ENABLED true // Set to "false" to disable one pin mode which saves around 14-26 bytes of binary size. Default=true
#define ROUNDING_ENABLED false // Set to "true" to enable distance rounding which also adds 64 bytes to binary size. Default=false
#define URM37_ENABLED false // Set to "true" to enable support for the URM37 sensor in PWM mode. Default=false
#define TIMER_ENABLED true // Set to "false" to disable the timer ISR (if getting "__vector_7" compile errors set this to false). Default=true
// Probably shouldn't change these values unless you really know what you're doing.
#define NO_ECHO 0 // Value returned if there's no ping echo within the specified MAX_SENSOR_DISTANCE or max_cm_distance. Default=0
#define MAX_SENSOR_DELAY 5800 // Maximum uS it takes for sensor to start the ping. Default=5800
#define ECHO_TIMER_FREQ 24 // Frequency to check for a ping echo (every 24uS is about 0.4cm accuracy). Default=24
#define PING_MEDIAN_DELAY 29000 // Microsecond delay between pings in the ping_median method. Default=29000
#define PING_OVERHEAD 5 // Ping overhead in microseconds (uS). Default=5
// Detect non-AVR microcontrollers (Teensy 3.x, Arduino DUE, etc.) and don't use port registers or timer interrupts as required.
#if (defined (__arm__) && defined (TEENSYDUINO))
#undef PING_OVERHEAD
#define PING_OVERHEAD 1
#undef PING_TIMER_OVERHEAD
#define PING_TIMER_OVERHEAD 1
#define DO_BITWISE true
#elif !defined (__AVR__)
#undef PING_OVERHEAD
#define PING_OVERHEAD 1
#undef PING_TIMER_OVERHEAD
#define PING_TIMER_OVERHEAD 1
#undef TIMER_ENABLED
#define TIMER_ENABLED false
#define DO_BITWISE false
#else
#define DO_BITWISE true
#endif
// Disable the timer interrupts when using ATmega128 and all ATtiny microcontrollers.
#if defined (__AVR_ATmega128__) || defined (__AVR_ATtiny24__) || defined (__AVR_ATtiny44__) || defined (__AVR_ATtiny84__) || defined (__AVR_ATtiny25__) || defined (__AVR_ATtiny45__) || defined (__AVR_ATtiny85__) || defined (__AVR_ATtiny261__) || defined (__AVR_ATtiny461__) || defined (__AVR_ATtiny861__) || defined (__AVR_ATtiny43U__)
#undef TIMER_ENABLED
#define TIMER_ENABLED false
#endif
// Define timers when using ATmega8, ATmega16, ATmega32 and ATmega8535 microcontrollers.
#if defined (__AVR_ATmega8__) || defined (__AVR_ATmega16__) || defined (__AVR_ATmega32__) || defined (__AVR_ATmega8535__)
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.