Raspberry Pi Ds18b20 Temperature Sensor logger with Sixfab Xbee Shield

You can connect to other nodes easily. Connect Xbee shield to Raspberry Pi and use ds18b20 sensor to log temperature information.

  1. Firstly, Connect your Raspberry Pi to the internet and run sudo apt-get update to update your Raspberry Pi
  2. We should stop the getty service on Raspbian.
    1. For non Raspberry Pi 3 machines, remember it’s /dev/ttyAMA0 that is linked to the getty (console) service. So you need to perform this command from a terminal window:
    2. For Raspberry Pi 3’s the command is similar but referencing /dev/ttyS0:
    3. You also need to remove the console from the cmdline.txt. If you edit this with:
      • sudo nano /boot/cmdline.txt
        dwc_otg.lpm_enable=0 console=serial0,115200 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait quiet splash plymouth.ignore-serial-consoles
        remove the line: console=serial0,115200  and save and reboot  for changes to take effect.
    4. You also need to enable uart with edit /boot/config.txt file
      • sudo nano /boot/config.txt and add enable_uart=1 to bottom of file then save and reboot for changes to take effect.
  3. Edit /boot/config.txt file with nano by running sudo nano /boot/config.txt and add dtoverlay=w1-gpio , save and exit.
  4. Edit /etc/modules file with nano by running sudo nano /etc/modules and add following text, save and exit.
  5. Download source code
    • wget https://raw.githubusercontent.com/sixfab/Sixfab_RPi_XBee_Shield/master/sample/XbeeTemp.py
  6. Make it executable
    • sudo chmod +x XbeeTemp.py
  7. Run it
    • sudo python XbeeTemp.py


About hardware:

As you can see from the picture below, the 4.7Kohm resistor required for 1-wire is not installed during electronic assembly. This pin can be used for other purposes or you may want to use it with another shield. We have not been assembled to avoid problems in these situations. If you only plug in a DS18B20  sensor without this resistor, a 4.7 kohm resistor is required. But on some breakout cards with 1-wire communication this resistance is already installed. It is not necessary for breakout.


10 thoughts

  1. Hello,
    I have follow the different steps to run the final script.
    But there is an error when I run the script :
    “Traceback (most recent call last):
    File “XbeeTemp.py”, line 5, in
    device_folder = glob.glob(base_dir + ’10*’)[1]
    IndexError: list index out of range”
    Have you an answer to this issue?
    Best regards,

  2. Hello,
    Your sensor (DS 18B20) is wired and you are connecting it like connecting with GPIO pins. What if we must use wireless sensors or lamps? Do you have a sensor recommendation to use and can you describe how to use with raspberry pi and Xbee?

  3. It might sound stupid, but I really struggled with this. I wasn’t able to get 28- at the beginning. I tried everything was was pulling my hairs off. I tried multiple sensors, multiple wiring, multiple software settings. Then I discovered I was using transistors bc547. Somewhat it get mixed with my dallas sensors and it looks the same! So it works for me with the proper sensors 🙂

Leave a Reply

Your email address will not be published. Required fields are marked *