DS18B20 and (BLE or anything else) #3675
Replies: 2 comments
-
Posted at 2021-02-26 by @gfwilliams
You're right - it's bluetooth jumping in and messing up the timings. It's a bit tricky in that the Bluetooth tasks are high enough priority that I don't believe I can interfere with them, and OneWire pretty much all has to be done in software. I did have a look a while back but didn't see much of a solution available. However what you're likely hitting is that when you have a BLE connection, normally if you've used it in the last minute it's in high-bandwidth mode. That means 7.5ms connection internal. If you force it to something slower with It's also worth noting that nothing stops you just calling If you don't have a connection open and just want to advertise, you could use
I think that'd all be fine - just depends how fast you want to do it! |
Beta Was this translation helpful? Give feedback.
-
Posted at 2021-02-26 by AkosLukacs Thanks Gordon! |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Posted at 2021-02-26 by AkosLukacs
Is there any way to get OneWire and BLE reliably work together?
Using a Pixl with 2v08.188, have three DS18B20 attached to A0. If Bluetooth is connected, mostly only 0 or 1 sensor are detected, and there are a bunch of
null
values returned when reading temperature.Tested with Pixl on serial, and with an Espruino Wifi, and all sensors are detected, and almost no
null
values returned.If I'm right, OneWire is done in software, and I assume BLE communication is interfering with that, right? Is there anything that could improve? Do the coding, and disconnect & disable BLE to run the code?
And other question: Assuming I'm not using BLE while running the code, what are my chances of reading multiple DS18B20 and reading accelerometer and writing to SD card together? Ok, let's just try it :D
Code is below:
Beta Was this translation helpful? Give feedback.
All reactions