Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Support for DS18B20 Temperature Sensor for Ambient Temperature #525

Merged
merged 7 commits into from
Jun 19, 2023

Conversation

jgiebler
Copy link
Contributor

@jgiebler jgiebler commented Jun 1, 2023

Extended project to support a single DS18B20 temperature sensor to detect ambient temperature. This will set the ambient temperature from the temperature sensor each time the periodicTimerFlag is true (defaulted to 60 seconds in main.h).

If the sensor is not enabled, the system will not attempt to update the ambient temperature.

A digital pin must be set to use the temperature sensor. When using the Wemos D1 Mini, pin D1 has been verified to work well.

This is my first GitHub commit to a project that is not my own. Please feel free to modify or reject. If you would like me to make changes, let me know.

visualapproach and others added 7 commits March 20, 2023 17:10
Extended project to support a single DS18B20 temperature sensor to detect ambient temperature. This will set the ambient temperature from the temperature sensor each time the the periodicTimerFlag is true (defaults to 60 seconds).

If the sensor is not enabled, the system will not attempt to update the ambient temperature.

A digital pin must be set to use the temperature sensor. When using the Wemos D1 Mini, pin D1 has been verified to work well.
@visualapproach
Copy link
Owner

Thanks I'll look at it when I have the time. I was checking out this thing some time ago and found it not doable for 6 wire pumps since there is only D0 and D8 free and they are not good for the purpose. Maybe you have found a solution or it will only work with 4-wire pumps but maybe that's okay. Thanks for your PR!

@visualapproach
Copy link
Owner

I'm impressed, you seem to know what you're doing. I have a request that you make the PR to the development branch please. And if I remember correctly, only some of the GPIO pins are suitable for this. Could you also add a filter to the input box, so only valid pins will be possible. And add a help text that explains that 6-wire systems don't have this possibility. If that's true as I think it is. Would be fair to the 4-wire users though, since they can't play my awesome music and display text 😁 I could ofc do it myself, but if you would be so kind, I'll have more time to think about other feature requests.

@jgiebler
Copy link
Contributor Author

jgiebler commented Jun 6, 2023

Thanks so much for the quick review and response! I apologize it took me so long to review and get back to this PR. I will re-make the PR to the dev branch instead.

Regarding the pins.. unfortunately, I am just using the Wemos D1 Mini with the pins soldered directly, so I'm unsure how this will interact with the NodeMCU and PCB versions. In my environment, I'm using the "6 wire 2021" setup. I have pins 0 and 2 - 7 used for the pump. As you mentioned, due to the DS18B20 having a pull-up resistor wired for proper function, D8 cannot be used. The Wemos will not boot if D8 is pulled up. Fortunately, D1 was also available. So far, I have had no issue having it connected to D1.

As a side note... I tried for 2 days to get a TMP36 Analog Temperature sensor to work instead via A0. It read fine on an Arduino Uno but was all over the place on the Wemos. I was guessing it was related to the voltage divider for the analog input, but even after bypassing the voltage divider, the readings were still inconsistent. They went up and down with temperature and taking multiple readings and averaging technically "worked", however, they never read the proper temperature. If someone has advice on an Analog sensor working with the Wemos/NodeMCU, that is the "sure-fire" solution for compatibility.

For the Wemos D1 Mini on my 6-wire pump, the pins I'm currently using are below. Is this similar to the 6-wire PCB or is D1 used for something else on there? If I need to test on D0, I can swap Audio (D0) and my DS18B20 (D1) to see if D0 will function.

CIO

  • data/td/rx = D4
  • clk/tx = D3
  • cs/ld = D2

DSP

  • data/td/rx = D7
  • clk/tx = D6
  • cs/ld = D5
  • audio = D0

Temp Sensor

  • D1

I found the below information online. I haven't validated it, but if it is accurate, D0 - D7 should support the DS18B20. D8 will not. I have only tested on D1 and D8. I can verify that D8 prevents boot.

ESP2866 Pin use

@jgiebler jgiebler changed the base branch from master to development_v4 June 6, 2023 03:33
@visualapproach
Copy link
Owner

If I need to test on D0, I can swap Audio (D0) and my DS18B20 (D1) to see if D0 will function.

That would be nice since the PCB uses D1-D7. I'm surprised that the audio works on D0. I thought the tone() function used PWM. Although I think I read there is no hardware PWM on the 8266. It's made by software. But in that case it is strange to put the "no PWM" note in the table...
As a side note - the later versions has DSP RX and TX in reverse order on the config page. It was due to hardware test not functioning properly on 4 wire systems. It should not matter in this case unless you edit it back.

@jgiebler
Copy link
Contributor Author

jgiebler commented Jun 7, 2023

I did some testing tonight. I was not able to get the DS18B20 working on D0. You were correct. D0 and D8 do not appear to be an option. For non-custom layouts, only 4-wire or non-audio 6-wire setups would be supported.

I'll look at adding some filters to the HTML to keep from setting a non-valid pin (already used, D0, D8).

Thanks again for the guidance and such a great project!

@visualapproach
Copy link
Owner

Thanks for testing! Well maybe skip the filtering of inputs and just make a note that D0 and D8 is not suitable for sensor and have to be switched with the audio or something.

@visualapproach visualapproach merged commit 9d9bc6c into visualapproach:development_v4 Jun 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants