Code Monkey home page Code Monkey logo

nonblockingdallas's People

Contributors

dzsoni avatar gbertaz avatar oopen avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

nonblockingdallas's Issues

85C issue?

I'm hitting the "always returns 85C" issue myself, and I'm curious what I'm doing wrong - the DallasTemperature library (blocking) is working as intended, in fact if I call it RIGHT before my non blocking setup, it returns correctly, but my callbacks return nothing but 85C after following the guide here.

update() function stopped working

Hello there !

I've configured time interval parameter in begin() function to 1500 ms and I've noticed that every time my sensor after some time stopped responding.

I did some investigation with debug messages and I've discovered that this line has to be changed, otherwise the state machine of yours inside update() function never escapes state "waitingNextReading".

I've initialized your wrapper like this:

// DS18B20
//Initialize the sensor passing the resolution, unit of measure and reading interval [milliseconds]
sensorDs18b20.begin(NonBlockingDallas::resolution_12, NonBlockingDallas::unit_C, TIME_INTERVAL);
//Callbacks
sensorDs18b20.onIntervalElapsed(handleIntervalElapsed);
sensorDs18b20.onTemperatureChange(handleTemperatureChange);

And I'm using sensorDs18b20.update(); function inside in my main.

I believe that this check is not correct:

if(_lastReadingMillis != 0 && (millis() - _lastReadingMillis < _tempInterval - _conversionMillis)) return;

Correct me if I'm wrong but at some point I end up having this message at the debug (I've added some custom Serial.prints):

_lastReadingMillis= 2315064
_conversionMillis= 20024
_tempInterval - _conversionMillis= 4294948772
if case: (_lastReadingMillis != 0 && (millis() - _lastReadingMillis < _tempInterval - _conversionMillis))= 1
if case: (_lastReadingMillis != 0)= 1
if case: (boolean)(millis() - _lastReadingMillis < _tempInterval - _conversionMillis)= 1

sensor state 1

This led me to think that you should simply check if time interval has passed and not to check all the above sections. I found no guard that guaranties that _conversionMillis wont get higher value of _tempInterval. Probably there is some blocking code in my program that causes the problem. I can't imagine how else this could end up wrong.

In order to fix this I've changed your if case to this:

if(millis() - _lastReadingMillis < _tempInterval) return;
_lastReadingMillis= millis();
requestTemperature();

And I've commended out _lastReadingMillis = millis(); inside function readSensors()

I will try this tonight and see tomorrow if the error persists.

Kind regards,
kif

error in platform.io

I'm new to this, and not sure if its a board issue, or something else,

src/main.cpp:22:35: error: 'handleIntervalElapsed' was not declared in this scope

src/main.cpp:23:37: error: 'handleTemperatureChange' was not declared in this scope

How to make a fixed relationship between device index and the real device?

Hi,
great work and it works fine ( ESP32 S3 ).
I have a bunch of temp sensors on specific places around a engine ( oil, water on different places ).
I want to give each sensor a specific (fixed) name ( e.g. oil ) to index mapping ..... should be valid after reboot / power of-on.
So I have to save the mapping in EEProm, SD card or LittleFS.
But ... index is not always the same for each sensor.
So currently it mixed up a little bit.

Question is, what is the easiest way to make that happen?
Need some kind of first time learn procedure I think.
Thinking about the following:

only ones ( learning phase )
remove all sensors from bus
for each temp sensor
     output sensor position on engine
     connect that sensor to the bus
     map sensor name / position / id  to the device address we have got
     save on EEProm , SD card or LittleFS

For the normal use afterwards:

load the saved data ( name / position /index to device address mapping )
use the saved data, report missing and new devices ( request new learn procedure in that case )

At the moment I'm struggling with that, think I'm not alone ...... :-)

How to make it simple with given functionality ...... at the moment I'm thinking too complex I think ....

how to define the call back function in a class scenario

Hello i am trying to use your library via a class but can't figure out how to write callback function
in my class i separate the .h with the .cpp
in the h file i specify these

class Context{
public:
Context();
void setup()
OneWire oneWire = OneWire(4);
DallasTemperature dallasTemp = DallasTemperature(&oneWire);
NonBlockingDallas sensorDs18b20 = NonBlockingDallas(&dallasTemp);
void handleIntervalElapsed(float temperature, bool valid, int deviceIndex);
...

in the cpp file I specify

void Context::handleIntervalElapsed(float temperature, bool valid, int deviceIndex){
if(valid)
temperatures[deviceIndex] = temperature;
}
void Context::setup(){
sensorDs18b20.begin(NonBlockingDallas::resolution_12, NonBlockingDallas::unit_C, 1500);
sensorDs18b20.onIntervalElapsed(handleIntervalElapsed);
}
on line
sensorDs18b20.onIntervalElapsed(handleIntervalElapsed);

it says error: invalid use of non-static member function 'void Context::handleIntervalElapsed(float, bool, int)

I understand that this is probably a c++ know how but would appreciate letting me know how to properly pass the function in a class scenario. Thanks in advance

Equality comparison with Float !

`void NonBlockingDallas::readTemperatures(int deviceIndex){

bool validReadout = (temp != 85.0 && temp != (-127.0));

}`

You cannot do this type of comparison with floats because, due to the approximations, you have a very high probability of having a result that is always true.

You must use (temp <= 84.95 && temp >= -126.95)

conversion time and intervals

Nice work, just what i needed but ran into an issue.
I tried a conversion time of 1000 millis but i only get 1 reading, the 1500 millis as in the example works until....
If _conversionMillis is higher than the set interval, requestTemperature is never called, should not be a problem if the interval is higher than 750 millis for 12 bit but there is a catch..
_conversionMillis is adaptive to the actual conversion time but that is where the problem is, the time calculated for the new _conversionMillis includes the overhead in my main loop, not the actual convertion time of the sensor so in my main loop i interact with a rotary encoder, switchs menus, rebuild a screen etc, the time this takes is included in the new _conversionMillis and once this is higher than the set interval, no more readings.
This is also why it does not work with a setting of 1000 millis because i build my screen at the start and that takes a little bit more time than the interval.

Compatibility with rosserial

In project with stepper motor, sensors and rosserial, rosserial don't work when I use NonBlockingDallas, but without it motor wont run constantly
When trying to start node, i get this: "Unable to sync with device; possible link problem or link software version mismatch such as hydro rosserial_python with groovy Arduino"
(not problem with arduino or ubuntu, it works without this library)

Missing examples from Library

Missing example for how to read multiple sensors from a single wire AND...
HOW to assign addresses in the array so that a specific sensor can be associated with a particular index.

Measure 5 sensors

I have 6 DS18B20 sensors, how do I get the temperature read from each sensor to be assigned to a different variable.
Semzors:
Sensor1 0x28, 0xB5, 0x3B, 0x49, 0xF6, 0x73, 0x3C, 0xD7
Sensor2 0x28, 0x17, 0xC4, 0x49, 0xF6, 0xA1, 0x3C, 0xE5
Sensor3 0x28, 0x4C, 0xF4, 0x49, 0xF6, 0xA8, 0x3C, 0x05
Sensor4 0x28, 0xF2, 0x28, 0x49, 0xF6, 0x39, 0x3C, 0x69
Sensor5 0x28, 0xDD, 0xB2, 0x49, 0xF6, 0x17, 0x3C, 0xEC
Sensor6 0x28, 0x84, 0xD7, 0x96, 0xF0, 0x01, 0x3C, 0x9B
Variables:
float temp1
float temp2
float temp3
float temp4
float temp5
float temp6

I need each sensor to always write the temperature in its variable.

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.