top of page
Search

OneWire devices on an Azure Sphere via UART

Writer's picture: Derek JamisonDerek Jamison

Last summer we had a few interns that were working on the Azure Sphere IoT device. One of the sensors they integrated with the Azure Sphere was a temperature sensor using I2C interface. We slowed down the data transfer rate and found that we were able to run the sensors about 6 feet from the Azure Sphere without any issue. One of the other sensors we looked at but never got around to trying to implement was the DS18B20 OneWire temperature sensor. OneWire is different than I2C because it only requires 1 wire (plus ground).


Since I was still waiting for my PCB, I decided to implement a OneWire library for the Azure Sphere and write a file for the DS18B20 in particular. I also had an old "Java ring" from a conference 20+ years ago with the embedded iButton that I was curious to see if it still worked. Maxim Integrated had a few articles that really helped out -- one was about how to implement OneWire using UART, which is the basis of my project. I modified the design slightly to add another GPIO that is normally high impedance but can help drive the OneWire bus to VCC to allow for parasitic charging. By sending serial data at different baud rates, we can create a pulse that pulls the OneWire bus low for a given duration (a "0" start bit, then least significant bit first, then a "1" stop bit). If other devices on the OneWire bus also pull the line low, then additional bits will be read as 0 when we read what we sent. The timing of each pulse for a bit needs to be fairly accurate, but you can have plenty of gap between bits. The time between the bits charges the devices on the OneWire bus. I posted the sample code on GitHub. This implementation ends up using 5 wires from the Azure Sphere, but then it only needs two wires for the OneWire bus (one for ground and the other one for send/receive/power). I was super excited when I connected my Java ring and it still returned the 64 bit unique address! If I have time in January I'll work on a bare metal example that will only use ground pin and one GPIO pin -- probably something based on the examples from CodethinkLabs.


Clearly taking video with my cell phone isn't the best way to demo this stuff, but for now it will have to do:




25 views0 comments

Recent Posts

See All

Comments


Post: Blog2_Post

Subscribe Form

Thanks for submitting!

©2020 by Derek Jamison. Proudly created with Wix.com

bottom of page