Problem with the DS18B20 temperature sensor (NUCLEO-F401RE board ) #7186
Replies: 1 comment
-
Posted at 2017-08-20 by @allObjects I cannot see any issue with the code, and with the hardware connectivity things look right the way you describe. I do though not know how serial numbers should look like... (length seems though to be correct: 64 bits... but is there some crc or checksum bit(s) in it?) First, I would try with a different pin. You may also try to watch the data pin with another pin and use simple watch or Waveform class... (best is to use a separate board for that to have no interference... Another option is to replace the sensor... today's cheapos do not always as shiny as they look... (see this dud... fetched from the mechanical world). Both, watch and Waveform use buffers which allow the oneWire to finish his job and then deferred you code can do an analysis. Setup a setWatch (with no / 0 debounce) then fire one wire communication, or setup Waveform for input and then fire one wire communicaiton. Even though you may not capture all info - because the one wire is pretty fast - you may get something, and you may even get timing errors... at least indicator that something is going on with some issue... Posted at 2017-08-20 by Blizzard Hello allObjects, Moreover, the same sensor was also tested using an Arduino board and a sample sketch that use the oneWire protocol commands; I get (and convert) the temperature without problems and read the same serial number of the device as returned by Espruino. Based on these results I can not say that the sensor itself is damaged or not working... Unfortunately, using Espruino and Nucleo Board I can only read the sensor 64-bit serial code through the function OneWire.search() API.
Definitely I think I'm losing something when, after I get the device serial number (address), I try to pick the device, but, frankly I don't know what the problem is. It would be nice to know and deepen the root cause of the problem (otherwise, even by replacing the device, I would remain locked on the first sensor selection) Regards Posted at 2017-08-21 by @gfwilliams Could you call I seem to recall ST changed the crystal halfway through manufacture of their F401Nucleo boards, so some run at a completely different speed to others! espruino/Espruino#457 I imagine that could cause you some issues. I've used DS18B40 on the Espruino Wifi just a few days ago and it worked great, so it's not specifally a Espruino + STM32F4 issue. Posted at 2017-08-21 by Blizzard Hi Gordon,
The difference between the two presses of the USER button is about 60 sec confirming a good accuracy of the internal timer / oscillator of the board. Something strange happens when I pass from the device search (which returns the correct sensor serial) to the device selection on the 1-Wire line... Thanks in advance. PS: I also have a Nucleo F401RE Board C0-2 (still working), I try to repeat the experiments with the latter (to see if there are differences) Posted at 2017-08-21 by Blizzard Hi,
The average value of measurements is close to 10 s (the clock\Timer accuracy seems OK)
Regards Posted at 2017-08-21 by @gfwilliams To be honest we're looking for wildly different timings - like a factor of two. I'm sorry, but i'm not sure what to suggest, unless you're willing to get a storage oscilloscope out and see what's happening on the wire itself? Does this work on other types of board running Espruino, or with other sensors? I know you said the current one works with other software, but it could be Espruino's timings are out of spec, and some devices work and some don't? Just a guess though. Posted at 2017-08-21 by Blizzard Unfortunately I do not have another sensor (of the same type), nor the oscilloscope for electric measurements (sigh!). However, I agree with your hypothesis, it may be a tolerance problem of the device \ sensor respect to the low-level timings applied by Espruino (if I understand well). This leads me to ask a question (for purely cognitive purposes) about how low level operations are organized in Espruino (e.g. for the oneWire interface). The OneWire Class and the DS18B20 sensor module correctly hide these "electrical" aspects and only expose functions to send and receive bytes, initialize the line, get the temperature value etc, etc, ... Regards Posted at 2017-08-21 by @gfwilliams Your best bet is to find the function in the reference: http://www.espruino.com/Reference Then there's a ⇒ symbol next to the function's title. Click on that and you go to the implementation: https://github.com/espruino/Espruino/blob/master/src/jswrap_onewire.c#L111 If you want actual specifics of the OneWire protocol, it's best just to google it. Can you try adding this to the end of your code:
And see what it says? It'll ignore the CRC. Posted at 2017-08-21 by @gfwilliams One other option is that the sensor (or your wiring) doesn't have 3.3v connected. DS18B20 can work off just data+GND, but I'm not 100% sure the driver for it supports that. If your other code did support it, it'd still work. On Espruino it'd keep resetting, so the CRC would likely be wrong. Posted at 2017-08-21 by @allObjects With the resistor between data and 3.3V, running just on ground and data, should not be a concern of the module... 'Properly' hardwired and capacitor / diode supported sensor should do just as fine... with resistor related and parasitic power supply capacitor - capacitor of sufficient capacity. @gfwilliams, if 3.3V is not properly supported, why would @Blizzard get a proper sensor serial # (w/ correct calculated checksum)? EDIT:
I was wrong about this... module implementation matters: module has to apply 'strong pull up' within 10[us] for at least 10[ms] after sending Convert T [44h] or Copy Scratchpad [48h] command (with no other bus activity going on) to support at least 1.5[mA] current for the requested operation. Posted at 2017-08-21 by Blizzard Hi Gordon, allObjects, The fairly simple connections are made through a breadboard; explicitly removing the cable on the power line connected with 3.3V pin on the Nucleo board I can still read the serial number via Espruino (this is for me quite surprising since I had the same idea of @allObjects concerning power supply management) Posted at 2017-08-22 by @allObjects Driver module implementation matters... see Edit: towards the bottom of my previous post. Unfortunately this is not helpful in explaining what is going on... It just seems to me that no measurement / conversion / scratchpad writing takes place after powering up. Verifying the connectivity on the sensor's power line to 3.3V should be checked. I would try implement some 'self-monitoring',... for example - you be the judge if it is 'totally out of mind': Apply the following changes to
Upload the code (from within the edit pane) and invoke the function from console by entering
When the console shows 'watch fired', it is an indicator that power failed... due to a too weak supply... if not, you may weakening/increasingly limiting the supply by increasing the resistor in the powering path to 330R / 470R / 680R / 1K / 2.2K / 3.3K / 4.7k / ... At one point you should get the 'watch fired' message... caused by the sensor performing the power hungry convert / copy to scratch pad operation, tearing/pulling down the power line and getting not enough power anymore - especially when choosing the highest conversion resolution which takes about 3/4 of a second. The 180R in the powering path still allows 1.6[mA] and 3.0V for the sensor when supply - the 3.3V board pin - is 'exactly' 3.3V and able to provide 1.67[mA]. (Did you ever check this 3.3V board pin's properties/abilities/behavior?) Posted at 2017-08-22 by Blizzard Thank you very much for your suggestion!
I hope to give the first results as soon as possible ... Regards Posted at 2017-08-23 by Blizzard Hello all,
Note that also the "native application" continues to work properly, even when connecting the resistor between the sensor power pin and 3.3V power line supplied by the module, except when the connected resistor is 10K. Posted at 2017-08-24 by @allObjects @Blizzard, thanks for going thru the procedures... it is really puzzling why the circuitry is not working... I checked for the processor types and see that they are different. Even though there is not an obvious explanation, I have to conclude that something is just not the same. In other words, something with the 1-wire driver is not working on this processor chip but it works on all the other Espruino boards... I hope it is not one of the ST libs used in the Espruino builds... but I would have to go for that... Posted at 2017-08-24 by @gfwilliams
Did you ever try the code I posted above that doesn't check the CRC? It would imply that the 'native' code you have doesn't bother with it.
It won't be - it works fine for me on official ST boards. Plus, I wrote the libs and they're used in all the different Espruino boards, so you'd expect there to be more problems reported across the board if they actually had issues. Posted at 2017-08-24 by Wilberforce Try a 2.2k or 3.3k resistor. Or 2 or 3 1k in series if that is all you have. What length cable are you running? On a raspberry pi I recall that 4.7k didnt work (also 3.3v) so I think it was 3.3 I used in the end. Posted at 2017-08-24 by Blizzard Hello all, @wilberforce: the DS18B20 sensor I'm using is cabled with 1 m cable. Posted at 2017-08-25 by @gfwilliams This one: http://forum.espruino.com/conversations/309292/#13811723 Posted at 2017-08-25 by Blizzard Hi @gfwilliams, Could you please clarify which of the two "pieces" should I use? Thanks in advance for your feedback... Posted at 2017-08-25 by @gfwilliams You literally just insert it in-line and it'll overwrite the existing implementation:
Posted at 2017-08-26 by Blizzard Thanks a lot for the complete code.
The device returns a negative temp value that seems compatible with a scratchpad reading like FF ... FF. Posted at 2017-08-28 by Wilberforce I just had a similar situation with an ESP32 and 2 one wire devices using a breadboard. A search would show the codes:
however - the reads failed. It turns out the pins were not seated properly - enough to get the ROM code, but not enough for a reading.
|
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Posted at 2017-08-19 by Blizzard
Hello all,
I'm continuing my trip in the Espruino world and I'm experiencing a problem with the DS18B20 temperature sensor and my ST NUCLEO-F401RE board on which I uploaded the latest version of Espruino (1v93).
Using the first example shown on the DS18B20 sensor page (http://www.espruino.com/DS18B20) precisely:
I get the following result (instead of temperature value):
The DS18B20 "cabled sensor" type is that identified on the Espruino web page as "Sensor type 1" connected as follows:
Black wire -> GND
Red wire -> 3.3V
Yellow wire -> Data pin (A0)
I'm also using the 4.7k resistor between data and the 3.3v line as suggested.
Browsing in the forum before posting the question I noticed the following post:
http://forum.espruino.com/conversations/254655/#comment11813806
in which Gordon suggested to skip the DS18B20 module and search for the sensor through the OneWire protocol.
In the same configuration (board+sensor), described above, I get the following result:
It seems to recognize the serial number of the DS18B20 device...
Could you please help me to solve this issue?
Thanks in advance for your support.
Kind regards
Beta Was this translation helpful? Give feedback.
All reactions