DS18B20 not reading every time

For general Flowcode discussion that does not belong in the other sections.
BenR
Matrix Staff
Posts: 1926
http://meble-kuchenne.info.pl
Joined: Mon Dec 07, 2020 10:06 am
Has thanked: 503 times
Been thanked: 686 times

Re: DS18B20 not reading every time

Post by BenR »

Hello,

Ok the problem is occurring as the WIFI comunications will be generating interrupts which will be lengthening the delays for the 1-wire communications. I've had a bit of a dig and it looks like there may be a way to use the onboard peripheral to do the 1-wire timings but before we go down that route we can try temporarily disabling the interrupts and see if that helps at all or creates more issues.

So before you start the 1-wire comms try calling this via a C-code icon.

Code: Select all

portDISABLE_INTERRUPTS();
Then immediatley after the 1-wire comms is complete re-enable the interrupts.

Code: Select all

portENABLE_INTERRUPTS();
fingers crossed.

I would try something like this
1-wire_ESP.jpg
1-wire_ESP.jpg (53.04 KiB) Viewed 3283 times

jollybv
Posts: 136
Joined: Mon Mar 08, 2021 11:25 am
Location: Cape Town South Africa
Has thanked: 41 times
Been thanked: 12 times

Re: DS18B20 not reading every time

Post by jollybv »

Hi Ben

Thanks i will give this a try and let you know.

jollybv
Posts: 136
Joined: Mon Mar 08, 2021 11:25 am
Location: Cape Town South Africa
Has thanked: 41 times
Been thanked: 12 times

Re: DS18B20 not reading every time

Post by jollybv »

Hi Ben

That work around worked. I tested it all night with WIFI connected and the system was stable it never once dropped a temp reading.

BenR
Matrix Staff
Posts: 1926
Joined: Mon Dec 07, 2020 10:06 am
Has thanked: 503 times
Been thanked: 686 times

Re: DS18B20 not reading every time

Post by BenR »

Hello,

Excellent that's great thanks for letting me know. Really pleased it's now working reliably again.

I'll now build the workaround into the base OneWire component so you don't have to manually add it into your projects.

BenR
Matrix Staff
Posts: 1926
Joined: Mon Dec 07, 2020 10:06 am
Has thanked: 503 times
Been thanked: 686 times

Re: DS18B20 not reading every time

Post by BenR »

Right, I've now added the code into the one wire component on the update system so you can now try disabling the C code icons and fingers crossed everything will keep working.

jollybv
Posts: 136
Joined: Mon Mar 08, 2021 11:25 am
Location: Cape Town South Africa
Has thanked: 41 times
Been thanked: 12 times

Re: DS18B20 not reading every time

Post by jollybv »

Hi Ben

Thanks its working like a dream :D I have changed the sampling rate of the prob from 350ms (where it missed a beat every now and then) to 500ms and now it dose not miss a beat at all.

Post Reply