Multiple DS18B20 Sensors

by KodyR in Circuits > Arduino

687 Views, 1 Favorites, 0 Comments

Multiple DS18B20 Sensors

IMG_20210319_165621859.jpg
IMG_20210319_165631250.jpg

I wrote this inscrutable as a reference for myself as I continue to improve my grain sensor project that can be found here https://hackaday.io/project/166702-bin-temperature-monitoring-system and here https://github.com/PhysicsUofRAUI/binTempSensor.

These sensors are expected to give two advantages over the AM2302 sensors currently being used:

  1. They are waterproof.
  2. Multiple can be hooked up to one digital pin.

Being waterproof might be important since my sensors will be placed outside. Having multiple hooked to one pin will allow more bins to be monitored.

Supplies

Get the Adresses of Each Sensor

To select each sensor individually we need to know the address of each sensor so that it can be selected and assigned a particular variable name.

To do this I wired up one sensor and then uploaded the code here:

https://github.com/milesburton/Arduino-Temperature-Control-Library/blob/master/examples/oneWireSearch/oneWireSearch.ino.

To run the code that library will have to be previously installed so you should be able to open that example from your Arduino editor.

Wire the Main Circuit

I have attached the circuit in a pdf to this step. All the sensors are attached to one pin (digital 1 aka PA23), and then a resistor connects the data pin to the power.

The symbol used for the schematic is the MKR Zero which for the most part is identical to the MKR 1400. There are two changes I would like to change:

  1. In the power is 3V3 and I would change it VCC.
  2. The pins do not list which digital pin is which so I would change that too. The pinout diagram can be used to correlate the listed pins to the correct digital pin here:

    https://content.arduino.cc/assets/Pinout-MKRsgm1400_latest.pdf.

Downloads

Create a Thing

dashboard.jpg

This code was designed so that it would transmit data to the cloud so you first need to configure a 'thing' on the Arduino cloud. I would recommend reading through this walkthrough https://www.arduino.cc/en/IoT/HomePage.

Basics for setting up this thing is:

  1. Configure an internet-ready device (I used the MKR1010) and attach it to your thing.
  2. Add three float variables that will hold the temperatures.
  3. Create a dashboard similar to the one above so that you can monitor the temperatures coming from the device.
  4. Next step is to upload the code but we will cover that in the next step.

Upload the Code

https://create.arduino.cc/editor/PhysicsUofRAUI/fa...

Above the code that I used is linked. I edited the thingProperties.h so that it passed a blank to the connection handler. I did that because the Secret tab would not let me upload a blank field. The secret tab will have different fields to be filled if you are using a different board. Your thing_id will be different from mine.

For a final remark, I would recommend letting Arduino cloud generate the code first and then going to my .ino file and fill in the missing pieces. I would not change the thingProperties.h file unless I had to.