Coder Social home page Coder Social logo

signalk / sensesp Goto Github PK

View Code? Open in Web Editor NEW
138.0 29.0 78.0 113.21 MB

Universal Signal K sensor framework for the ESP32 platform

Home Page: https://signalk.org/SensESP/

License: Apache License 2.0

C++ 46.05% C 51.26% Python 0.23% HTML 0.75% JavaScript 1.58% Shell 0.13%
esp32 arduino platformio signalk

sensesp's Introduction

Signal K

signal-k-logo-tagline

Signal K is a modern and open data format for marine use. Built on standard web technologies including JSON, WebSockets and HTTP, Signal K provides a method for sharing information in a way that is friendly to WiFi, cellphones, tablets and the Internet. A format available to everyone, where anyone can contribute, Signal K is the first truly open data format for the marine industry and is set to revolutionize how we consume and interact with data on boats.

https://signalk.org

sensesp's People

Contributors

ba58smith avatar bjarnebitscrambler avatar bwssytems avatar captigmu avatar doubledutch2 avatar eschlotfeldt avatar fabdrol avatar free-x avatar frewie avatar ghbloos avatar gregsyoung avatar gzahl avatar iuriaranda avatar jcaprano avatar joabakk avatar joelkoz avatar johnyseven avatar kegustafsson avatar mairas avatar moorcoder avatar norbert-walter avatar plerenius avatar rberliner avatar rogerlittin avatar rszemeti avatar smr547 avatar techstyleuk avatar tedenda avatar tkurki avatar zschramm avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

sensesp's Issues

Add more status indicators using the LED (led_blinker.cpp)

It would be helpful to have more status indicators using the LED.

  • Network needs to be configured. (SSID and password.)
  • Any kind of fatal error that will prevent a sensor from sending valid data (such as an invalid address for an I2C sensor).
  • Any other status that's less than "everything is perfect".

Some ESP's broadcast their AP when they shouldn't

This may be a firmware issue with some clones of the original Wemos D1 Mini - not sure. But some ESP8266's will activate the "Unconfigured SensESP Device" AP even after successfully connecting to the network and sending deltas to Signal K. If you connect to it, and go to 192.168.4.1, you see the config web page, the same as if you go to the IP address of the ESP. Same config web page, and both are active.

BME280, SensESP fails to start if sensor not present

If BME280 device is not present then SensESP startup fails and device is halted.
␛[0m(I) (check_status) Could not find a valid BME280 sensor. Check wiring, address, and sensor ID. ␛[0m(I) (check_status) SensorID is: 0x255 ␛[0m(I) (check_status) 0xFF: is a BMP180 or BMP085, or a bad address ␛[0m(I) (check_status) 0x56-0x58 is a BMP280 ␛[0m(I) (check_status) 0x60 is a BME280 ␛[0m(I) (check_status) 0x61 is a BME680 ␛[0m
Log reporting stops here.

Program stops here.
https://github.com/SignalK/SensESP/blob/master/src/sensors/bme280.cpp#L27

Would be much better to catch the issue internally and just disable reading the values for the sensor and allow the rest of the program to continue.

Support ESP01 1Mb flash, options to trim memory usage

I'm trying to flash an ESP8266 ESP01 unit with 1M flash, and get the following error:

Checking size .pio/build/esp01_1m/firmware.elf
Error: The program size (786016 bytes) is greater than maximum allowed (761840 bytes)

I have uncommented the line

board_build.partitions = no_ota.csv

in the platformio.ini file

DS18B20

Please write an example of connecting a DS18B20 sensor.

SensESP config page issue

A SensESP node with an BME280 sensor attached generates faulty foldout meny on config page.
Humidity value is listed outside the foldout where pressure and temperature is listed:

Skärmavbild 2020-10-07 kl  12 15 10

The humidity link is not working:

Skärmavbild 2020-10-07 kl  12 34 34

Allow device to fill in requested permissions in token request to server

Hello,

it's just small think but it will allow devices to define what SK permissions they need in order to work, some of them needs just "readonly", mostly they need "readwrite" or "admin".

My sugestion is to change the token request to provide "permissions" in JSON token request and add new method in SensESP builder to configure this. Default permission will be "readwrite" as most devices needs to pull the data in.

This scenario is supported by SK server here:
(https://github.com/SignalK/signalk-server/blob/1c80214bd86272c04c47b8cf8be363e617d202a3/src/tokensecurity.js#L1035)

Just let me know what you think about this.

I'm willing to make PR.

Thanks,
Jan

PlatformIO fails to resolve all SensESP dependencies

As a long-time user of VSC I uploaded the PlatformIO IDE, and set out to run one or more of the examples. I di it without issue and left the boat for home. At home, using the same computer, I modified the code to utilize the different network and I get errors that I did not have before. I have tried starting the examples from scratch with the same result. What could possibly be wrong? I have not found any log files, although I have to believe they exist. This is the first of the errors and the rest refer to the same bmp280 sensor which is not needed for any on the examples I am trying. Thank you.

compilation terminated.
*** [.pio\build\d1_mini\libaf9\SensESP\sensors\bmp280.cpp.o] Error 1
In file included from .pio\libdeps\d1_mini\SensESP\src\sensors\bme280.h:5:0,
from .pio\libdeps\d1_mini\SensESP\src\sensors\bme280.cpp:1:
.pio\libdeps\d1_mini\Adafruit BME280 Library/Adafruit_BME280.h:26:29: fatal error: Adafruit_Sensor.h: No such file or directory

Add support for BME280 temp/pressure/humidity sensor

Someone on Slack asked about this, and it looked easy, so I did it. But I don't have a BME280, so I can't test it. I will hopefully get the person on Slack to test it for me, and then I will make the PR. #coronavirus #quarantine #boredomsettingin

Options in platformio.ini have been deprecated

Near the end of a build, I get: Warning! '-Wl,-T' option for specifying linker scripts is deprecated. Please use 'board_build.ldscript' option in your 'platformio.ini' file.

I've looked a bit on the PIO website for something that explains how to convert from the existing build flag -Wl,-Teagle.flash.4m1m.ld to the equivalent with board_build, but I can't figure it out.

I'm afraid if we don't address this, we're going to get a breaking update to PIO one of these days.

DigitalInputCounter(), VoltageDividerR2() need load_configuration()

While investigating a bug with one of the error messages in Configurable::load_configuration(), I discovered two configurable classes that were missing load_configuration() from their constructors: DigitalInputCounter and VoltageDividerR2. The result being that any changes made to the configuration at runtime would be written to the file system, but not loaded the next time the program was restarted.

Various compiler warnings that should be dealt with

  1. Library Manager: Warning! More than one package has been found by OneWire requirements:
  • It lists a bunch, but defaults to the first one, by "paulstoffregen". It works, and is the one we've always used, so we should specify this one: paulstoffregen/OneWire will always use the latest version of that library, which is what we should probably use.
  1. bool HTTPClient::begin(String) is deprecated.
  • This refers to the several lines in ws_client.cpp that call the above, with http.begin(url). We need to figure out what the current signature is for begin() and use it instead.
  1. 'SPIFFS' is deprecated: SPIFFS has been deprecated. Please consider moving to LittleFS or other filesystems.
  • In sensesp_app.cpp, configurable.cpp, spiffs_storage.cpp.

Work with multi-channel ADC (was: Multiple analog inputs)

Hello, me again! :)

Sorry for disturbing but it seems to be difficult for me to figure out how how to configure SensESP for reading multiple analog inputs/sensors.
As far as I understand the easiest way is to useESP8266 and ADS1115 boards but I don;t have idea how to do it with SensESP.
With SigkSens it is clear but not with SensESP.
Can you provide an example?

Thank you,
Seb

LedBlinker should follow the Observer pattern

The Observer pattern is used throughout SensESP: an object inheriting from Observable allows Observers to be attached to it. Whenever the Observable changes, it notifies the Observers which then act accordingly. In contrast, LedBlinker provides an explicit callback to WSClient, which is clunky and unnecessarily verbose.

To simplify and harmonize the setup, LedBlinker should be an Observer attached to a WSClient Observable.

Additionally, the current LedBlinker implementation leaves a lot to be desired. Failing to find something suitably generic, I wrote a new blinker for sailor-hat-firmware. That could be ported to the ReactESP framework.

Can't set hostname in main.cpp w/o also setting ssid and pw

The new SensespAppOptions feature that allows various options to be set in main.cpp has a problem if you try to set the SSID and password in main.cpp, but DON'T set the hostname in main.cpp. This is most likely due to the fact that WifiManager saves the hostname as a custom parameter, so when you don't use WifiManager to set SSID and pw, you don't get access to hostname, because WifiManager isn't involved.
I think an acceptable solution would be to bundle these three options: either set all three in main.cpp, or set none of them in main.cpp. But that's up for discussion.

Remove all references to "sensors" in SK Paths

From a Slack discussion with @tkurki and @sbender, "sensors" in the SK Specification is supposed to be for information ABOUT sensors, NOT data coming from sensors. SensESP has "sensors" in the paths for all the "standard sensors" (systemHz, freemem, uptime, ipaddress), and in a couple of the examples (analog_input.cpp, and in wiring_helpers.h/cpp for the fuel_flow_meter.cpp example).

Allow an individual configurable value to be reset to its default value

From a conversation on Slack:
The reset_device call ends up calling SenseESPApp::reset() in sensesp_app.cpp, which resets the network settings and formats the file system -- in effect, returning the device to factory defaults.

And this is related to your previous question about the value changes. The current behavior is indeed as you observed: if any values have been changed and written to the SPIFFS, those have priority over the default values set in code. Calling reset_device allows you to erase the locally configured values but I admit it's a bit of a heavy hammer for the purpose.

One option would be to add a button next to each config value (in the web interface, that is) to revert that particular config value to the default set in main.cpp.

fix: doesn't reconnect to wifi if wifi goes off and comes back on - not saving the wifi config?

I thought this was happening, so I just restarted my wifi to test it, and it is.

Turned wifi on, turned D1 Mini on, SensESP connected and started sending data. Was sending data for a few hours. I turned off the wifi, and SensESP immediately detected that, and restarted. When it came up, it didn't find my wifi (it was still off), so it went into AP mode as it's supposed to. But then, after I turned the wifi on, and SensESP was seeing the wifi, it still didn't connect to it. I had to go to Unconfigured Sensor and re-select my wifi and re-enter the password, and then it was OK. Here's the serial output of the whole test, starting with me turning the wifi off.

␛[0m(E) (check_connection) Wifi disconnected: restarting...
␛[0m
 ets Jan  8 2013,rst cause:2, boot mode:(3,6)

load 0x4010f000, len 1384, room 16
tail 8
chksum 0x2d
csum 0x2d
v8b899c12
~ld
(I) (enable) Connecting SignalK source sensors.WemosD1miniTest.systemhz
␛[0m(I) (enable) Connecting SignalK source sensors.WemosD1miniTest.freemem
␛[0m(I) (enable) Connecting SignalK source sensors.WemosD1miniTest.uptime
␛[0m(I) (enable) Connecting SignalK source sensors.WemosD1miniTest.ipaddr
␛[0m(I) (enable) Connecting SignalK source propulsion.left.revolutions
␛[0m(I) (enable) Enabling subsystems
␛[0m(I) (enable) Subsystem: networking->setup()
␛[0m*WM: Adding parameter
*WM: hostname
*WM:
*WM: AutoConnect Try No.:
*WM: 0
*WM: Connecting as wifi client...
*WM: Using last saved values, should be faster
*WM: Connection result:
*WM: 1
*WM: SET AP STA
*WM:
*WM: Configuring access point...
*WM: Unconfigured Sensor
*WM: AP IP address:
*WM: 192.168.4.1
*WM: HTTP server started
*WM: About to scan()
*WM: About to scan()
*WM: Scan done 
// it does this about 20 times.
// I turned my router back on about here....
*WM: About to scan()
*WM: About to scan()
*WM: Scan done
(E) (setup) Failed to connect to wifi and config timed out. Restarting...
␛[0m
 ets Jan  8 2013,rst cause:2, boot mode:(3,6)

load 0x4010f000, len 1384, room 16
tail 8
chksum 0x2d
csum 0x2d
v8b899c12
~ld
(I) (enable) Connecting SignalK source sensors.WemosD1miniTest.systemhz
␛[0m(I) (enable) Connecting SignalK source sensors.WemosD1miniTest.freemem
␛[0m(I) (enable) Connecting SignalK source sensors.WemosD1miniTest.uptime
␛[0m(I) (enable) Connecting SignalK source sensors.WemosD1miniTest.ipaddr
␛[0m(I) (enable) Connecting SignalK source propulsion.left.revolutions
␛[0m(I) (enable) Enabling subsystems
␛[0m(I) (enable) Subsystem: networking->setup()
␛[0m*WM: Adding parameter
*WM: hostname
*WM:
*WM: AutoConnect Try No.:
*WM: 0
*WM: Connecting as wifi client...
*WM: Try to connect with saved credentials
*WM: Connection result:
*WM: 0
*WM: SET AP STA
*WM:
*WM: Configuring access point...
*WM: Unconfigured Sensor
*WM: AP IP address:
*WM: 192.168.4.1
*WM: HTTP server started
*WM: About to scan()
*WM: About to scan()
*WM: Scan done
*WM: DUP AP: theturtle_IoT
*WM: DUP AP: theturtle
*WM: DUP AP: fos_guest
*WM: About to scan()
*WM: About to scan()
*WM: Scan done
*WM: DUP AP: fos_guest
*WM: DUP AP: theturtle
*WM: DUP AP: theturtle_IoT
// So it's obviously seeing the network, but won't connect to it.

It's now more than an hour after I pasted the above in, and I'm just finishing this. It's still doing what it was doing above: scanning, finding the networks, but not connecting to them. So I just restarted the Wemos, and it's doing the same thing. I have to go into Unconfigured Sensor and tell it my wifi info again, and then it's OK.

DigitalInputValue doesn't work

I connected a bilge pump wire to the D1 pin (stepped down to 2.5v) and confirmed that when the pump is on, the pin has 2.5v and when the pump is off the pin has 0v. I added the debug messages to show if the interrupt is being triggered on any CHANGE, and it is, and the value of output is what it's supposed to be: 0 or 1. But no delta ever showed up in the serial monitor, even though uptime did. So the app.onTick wasn't working. It looks correct, but it's not ever reporting the value of output as a delta.

Another problem (I think) is that Instrument Panel doesn't know what to do with a Boolean value - it doesn't have a dedicated gauge, so it just shows the words "false" or "true" when you select Digital Gauge, and doesn't show any difference (the needle never moves) if you select Analog Gauge.

I changed the base class from BooleanProducer to IntegerProducer, and then it would output a 0 or 1 as expected... almost. It would often leave a 1 showing in Instrument Panel after the pump was off. (Yes, I have a pulldown resistor, and as noted above, the value on the pin is 0v when the pump is off.) So I threw out the whole app.onInterrupt and app.onTick approach (commented out below) and changed it to app.onRepeat and report the value every 1000ms, and now it works as expected.

A side benefit of this approach is that in Grafana, there is data to be graphed every second, so it's easy to see the history of the pump's on/off cycle, which you don't get if it only ever reports a change in the state.

I don't want to make this change until someone who understands what might be the problem with app.onTick has a look at the problem. I'll just use this simpler approach in my boat to test it for the time being.

void DigitalInputValue::enable() {
 app.onRepeat(1000, [this](){
    output = digitalRead(pin);
        notify();
 //app.onInterrupt(
  //  pin, interrupt_type,
  //  [this](){
  //    debugI("Interrupt triggered");
  //    output = digitalRead(pin);
  //    debugI("output is now %d", output);
  //    triggered = true;
  //    //notify();
  //  });
// });
  //app.onTick(
  //  [this](){
  //    if (triggered) {
  //      triggered = false;
  //      notify();
  //    }
  //  }
  //);  
}

Update to ArduinoJson ver 6

SensESP uses ver 5, and 6 is not backwards-compatible with 5. Until we update to 6, everyone will always have to uninstall 6 if (when) it's installed automatically by PlatformIO.

I will take an initial stab at it.

feature: AnalogVoltage() transport needs max_voltage variable


    public:
       AnalogVoltage(String config_path = "") : 
          Linear(1.0 / 1024.0 * 3.3, 0, config_path) {}
};```
A small number of ESP microcontrollers allow only 0.0V - 1.0V on AnalogIn pin. So need to replace 3.3 with max_voltage, and make it configurable.
It was decided to make AnalogVoltage not inherit from Linear, but rather to make it a copy of Linear, with the necessary changes to make it output do what AnalogVoltage does.

(@joelkoz): Note that it is "configurable", but unless you redefine get_configuration() and set_configuration(), the values you can configure will be only those of Linear()
...which is "multiplier and offset"
If you want to be able to change just "max_voltage", you need to re-define get/set_configuration(), as well as get_json_schema() to add max_voltage
you'd also need to re-calculate the multiplier of Linear

For this reason - if we want it to be configurable, it may be best to NOT make it inherit from Linear
Instead, just copy the source code of Linear, then make the appropriate adjustments

ESP32

Do you have an example that compiles with ESP32? I can't get any of the examples to compile, even after changing platformio.ini.

Timeout in Data Transmission

hello,
trying sensesp with signalk (1.34.0) i observed an interruption of data transmission approx. every 20 seconds (the data in signalk remains for some time (~10sec) constant). i use only the internal uptime as sensor. any idea how to solve?

ESP32 only: Guru Meditation Error: Core 1 panic'ed (LoadProhibited).

This happens only when using ESP32, and only when the SK Server isn't responding to the mDNS service request, or when the ESP doesn't yet have security authorization from the SK Server.

Stopping/starting the SK Server solves the first problem.
Authorizing the security request on the SK Server solves the second problem.

But it would be good to have these exceptions handled properly. Now, the ESP restarts, and just keeps coming back to the same spot, where it errors out again, and again, and again, until you stop/start the Server, or authorize the security request.

"Unconfigured SensESP Device" SSID s/b unique

If you happen to have two unconfigured SensESP devices, they both get the same the SSID ("Unconfigured SensESP Device"), and the same IP address. It would be better if the name were unique to the device, using some part of the device's Hostname to make it unique. It would be best if each had a unique name AND a unique IP address.

This problem is made worse by the fact that some ESP's will broadcast their SSID (with the name "Unconfigured SensESP Device") even after they have successfully connected to the network. (That's another issue, of course. Issue # 87, in fact. )

Time to update version to 1.0?

@mairas - should we decide on anything else that's necessary prior to changing the version to 1.0, then do that?

  • Update the README
  • Update the Wiki
  • Generate new class documentation
  • Update all current examples to use Builder
  • what else?

Need ESP32-specific specific code in analogvoltage.cpp to make it accurate

Poor support for ESP32 Analog input.

Line 14 in analogvoltage.cpp assumes an ADC resolution of 1024 (as do comments in the temperature_sender example) whereas the ESP32 ADC's have a resolution of 4095. The ESP 8266 ADC does have a resolution of 1024.

But the problem with ESP32 support is more fundamental. The code does not seem to make use of the factory calibration data and results are inaccurate.

See this link for code with stable and accurate ADC results
https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-reference/peripherals/adc.html

feature: create ConfigurableParameter() class

From a Slack conversation:
jkoz [1:41 PM]
Re: configurable value: Matti - you have this "ObservableValue" object you used for the individual GPS values (and some other things IIRC). That concept - have the value wrapped by a class, is very close to an idea I had: We could make a "ConfigurableParameter" class that is much like ObservableValue, but it could also supply itself as json, its own title etc. If we did that, then we could probably get away with just declaring the values you want to use in a Transform as a "ConfigurableParameter", and then all the other code (get_configuration(), set_configuration(), get_json_schema()) would work with that. That would prevent having to write the marshalling code over and over again.

Set a configurable interval for sending data to SK

Hello again,

There is some way to set the interval of time to send data to SK? Will be nice if is possible to set this for each used sk_path.

Also, to disable sending SystemHZ, Uptime, Freemem and so on, there is any other way to do it?
I did it by commenting the specific lines in sensesp_app.cpp but I don;t know if this is the best way to do it.

Thank you,
Seb

Erroneous error message in Configurable::load_configuration()

As a result of doing PR #79, I think I have found a bug. In Configurable::load_configuration(), the error message that displays because of if (!SPIFFS.exists(config_path)) is displaying when it shouldn't in some cases (for some sensors and transforms, but not all). What's puzzling is that when this error is encountered, there's a return; after the error message, so that the rest of load_configuration() should not be called. However, everything having to do with the configuration works just fine - all appropriate configurable values appear in the web UI, and all configuration changes made there end up being written to SPIFFS.

Need a better approach to maintain the platformio.ini file

platformio.ini defines the build environment settings for the project. Whenever anyone wants to develop SensESP itself, they usually need to modify the file. This is not ideal because maintaining the local modications of a file tracked by Git always requires some extra effort. Ideally, we should have a way to keep a default platformio.ini file in the repository while allowing developers to have their own local versions for their own use.

Proposal: We should rename platformio.ini to platformio.ini.default. Anyone who wants to poke at SensESP then needs to make their own copy of platformio.ini but once done, they wouldn't need to worry about changing the global defaults. Downside of the approach would be the new setup chore before a person unfamiliar to the project can get up to speed.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.