mrestivill / webiopi

Automatically exported from code.google.com/p/webiopi
0 stars 0 forks source link

Add OneWire support (Patch attached) #11

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
ENHANCEMENT - Patch against Rev 605

Really like webiopi. I am planning to use it as the basis of a swimming pool 
control server. To do this I am using a Dallas 1-Wire temperature sensor. I 
decided I might as well add 1-Wire functionality to webiopi if I have to write 
it anyway.

The patch is based on the w1-gpio module. The first thing it does is detect if 
the module is loaded and if so turns GPIO pin 4 into ALT mode to stop it being 
used. It adds at the bottom of the table a list of all detected 1-Wire devices 
and lets you read from them. The raw data is displayed or by checkbox can have 
the temperature extracted.

I have updated the RESTAPI docs to show what you can do. 1-Wire can be enabled 
or disabled which loads or unloads the w1-gpio module. A list of devices can be 
requested and then the data for a deviceId can be taken. This is easily 
manipulated by Javascript like extracting the temperature.

The webiopi main page will show the 1-wire devices below the GPIOs only when it 
is enabled. The list is updated dynamically so new devices will appear when 
they have been connected with no user intervention. They will also be removed 
when disconnected.

I only have one device so have only tested with that but it should work with 
many. It will only work with devices that give data in the w1_slave file. It 
does not support writing to devices but it could be added easily.

Hope it is useful to others. Any comments welcome.

Original issue reported on code.google.com by stuartma...@gmail.com on 28 Nov 2012 at 8:37

Attachments:

GoogleCodeExporter commented 9 years ago
Will be added later at the same time as SPI, I2C

Original comment by tro...@trouch.com on 22 Dec 2012 at 7:26

GoogleCodeExporter commented 9 years ago

Original comment by tro...@trouch.com on 22 Dec 2012 at 7:26

GoogleCodeExporter commented 9 years ago
In progress, but I don't have any 1-Wire device to make some test...
is the w1-temp module mandatory for RAW and generic 1-Wire communication ?
I mean, is the device detected if you only load w1-gpio module ?

Original comment by tro...@trouch.com on 27 Jan 2013 at 10:16

GoogleCodeExporter commented 9 years ago
The device will still show up without the w1-temp module but it will not give 
any data. This is for 1 wire temp sensors. Which is all I have. I imagine that 
other devices may need other modules.

Original comment by stuartma...@gmail.com on 27 Jan 2013 at 1:25

GoogleCodeExporter commented 9 years ago
Okay... thanks for feedback
I think I'll need to hand on some 1-wire devices...
I've designed something generic that suits UART, I2C and SPI, and I'd like to 
use the same approach for 1-wire

Original comment by tro...@trouch.com on 27 Jan 2013 at 3:03

GoogleCodeExporter commented 9 years ago
I will be happy to test against my one wire devices if you have a test build. I 
might even get a few more types of one wire devices on eBay (they don't cost 
much).

Original comment by stuartma...@gmail.com on 27 Jan 2013 at 3:19

GoogleCodeExporter commented 9 years ago
For sure, but I will not be able to buy all devices.
What devices do you have ?

Original comment by tro...@trouch.com on 27 Jan 2013 at 3:52

GoogleCodeExporter commented 9 years ago
Good find : http://www.maximintegrated.com/samples/

Original comment by tro...@trouch.com on 27 Jan 2013 at 4:28

GoogleCodeExporter commented 9 years ago
DS18B20 samples received and tested.
I first checked differences with and without w1-therm, then looked in w1* 
modules sources.
Getting a raw access to the 1-wire interface seems to be hard from Python and 
use w1-therm is certainly the best choice.
So I need to adapt my current design to load extra modules keeping a 
generalization for OneWire bus that will just load w1-gpio.
Adding other 1-wire device family like IO expander will then be easier.

Original comment by tro...@trouch.com on 1 Feb 2013 at 3:51

GoogleCodeExporter commented 9 years ago
working in r817, closes this issue.
only device listing is missing from the patch, it will be added as a more 
generic device listing to get all kinds of devices.

Original comment by tro...@trouch.com on 2 Feb 2013 at 4:08

GoogleCodeExporter commented 9 years ago
Travelling at the moment so cannot try for a few days. Was looking at the code 
but cannot figure out where the onewire bit is. You have done a big refactor so 
maybe I am looking in the wrong place. Or is it possible you forgot to add the 
onewire file to version control? Thanks for adding onewire, I look forward to 
trying it.

Original comment by stuartma...@gmail.com on 2 Feb 2013 at 5:58

GoogleCodeExporter commented 9 years ago
oops, you totally right, i missed to add onewire.py before commiting others 
changes. now fixed.
you have to go in devices/sensor.py, for the starting point, wich then use 
classes in onewire.py

Original comment by tro...@trouch.com on 2 Feb 2013 at 6:26

GoogleCodeExporter commented 9 years ago
Sorry, but how do i use the patch ? is there a command to apply it ?

Original comment by sebastie...@gmail.com on 25 Mar 2013 at 6:13