Driver for 1-Wire sensor bus



  • @Omega303 what did you do to read with kmod-w1-gpio-custom?



  • Started to follow http://squidge.sourceforge.net/w1/ but I don't see a file named /etc/modules.d/<load sequence>-w1-gpio-custom to configure which pin is being used?

    Also, tried reading with fast-gpio but I'm just getting a reading on 0 - should I expect a reading from this?



  • āœ… SUCCESS Thanks @Lazar-Demin - for getting the packages for 1-Wire interface into the Omega firmware. šŸ˜ƒ 21.875Ā°C is the first temperature I read from a DS18B20 via Onion Omega. I am putting together a tutorial to document the steps needed to get the 1-Wire interface up and running. What is your preferred format? Is markdown sufficient?

    @Nathan-Bertram : You need the kmod-w1-gpio-custom to tell the 1-Wire interface to which GPIO pin you connect your data wire. Thats done by creating a file at

    • /etc/modules.d/55-w1-gpio-custom

    containing only one line:

      w1-gpio-custom bus0=0,19,0
    

    where 19 is GPIO pin (replace that number by the pin your sensor is connect to)



  • @Nathan-Bertram If the 1-Wire interface is set up and a device connected you can read by

     cat /sys/devices/w1_bus_master1/28-01234567890a/w1_slave
    

    where 28-01234567890a is the sensor id. This file only exists if all modules loaded correctly and an device is connected.



  • @Omega303 ok sweet - I got the w1 running it seems thank you! The sensor id folders keep changing with no w1_slave file present (which I assume means it keeps trying to detect my sensor but isn't getting data from pin 0 as I configured it. Do I need to put a resistor or does my current setup look correct (5V red, GND black and yellow pin 0) http://monosnap.com/image/HSxZm5p6mUS8iF5uvhtqgJxtScR7te ? (I checked the current I'm getting 5v which means I didn't totally botch the soldering job)

    root@Omega-088F:/sys/devices/w1_bus_master1# cat /etc/modules.d/55-w1-gpio-custom
    w1-gpio-custom bus0=0,0,0
    
    root@Omega-088F:/sys/devices/w1_bus_master1# ls -la /sys/devices/w1_bus_master1
    drwxr-xr-x    4 root     root             0 Jan 27 03:47 .
    drwxr-xr-x    6 root     root             0 Jan  1  1970 ..
    drwxr-xr-x    2 root     root             0 Jan 27 04:03 00-280000000000
    drwxr-xr-x    2 root     root             0 Jan 27 04:03 00-c80000000000
    lrwxrwxrwx    1 root     root             0 Jan 27 03:47 driver -> ../../bus/w1/drivers/w1_master_driver
    lrwxrwxrwx    1 root     root             0 Jan 27 03:47 subsystem -> ../../bus/w1
    -rw-r--r--    1 root     root          4096 Jan 27 03:47 uevent
    -rw-rw-r--    1 root     root          4096 Jan 27 03:47 w1_master_add
    -r--r--r--    1 root     root          4096 Jan 27 03:47 w1_master_attempts
    -rw-rw-r--    1 root     root          4096 Jan 27 03:47 w1_master_max_slave_count
    -r--r--r--    1 root     root          4096 Jan 27 03:47 w1_master_name
    -r--r--r--    1 root     root          4096 Jan 27 03:47 w1_master_pointer
    -rw-rw-r--    1 root     root          4096 Jan 27 03:47 w1_master_pullup
    -rw-rw-r--    1 root     root          4096 Jan 27 03:47 w1_master_remove
    -rw-rw-r--    1 root     root          4096 Jan 27 03:47 w1_master_search
    -r--r--r--    1 root     root          4096 Jan 27 03:47 w1_master_slave_count
    -r--r--r--    1 root     root          4096 Jan 27 03:47 w1_master_slaves
    -r--r--r--    1 root     root          4096 Jan 27 03:47 w1_master_timeout

  • administrators

    @Omega303 that's awesome! yeah, markdown would be great. let me know when it's ready and we can throw it into the Onion wiki.

    Or you can make a push request to the wiki repo directly: https://github.com/OnionIoT/wiki



  • @Lazar-Demin said:

    https://github.com/OnionIoT/wiki

    Hello,
    Is there a way how to check this ? I mean using a temperature sensor.
    I've been reading this post, and none of the folders / file exists on my Onion.
    Just updated to the latest version.
    Thanks,
    Miguel



  • Hi for example I've this:

    root@Omega-276D:/etc/modules.d# ls gpio

    30-gpio-button-hotplug 58-i2c-gpio-custom spi-gpio
    30-gpio-irq 59-i2c-gpio w1-master-gpio
    50-ledtrig-gpio 60-leds-gpio

    Which one should I use ?
    Thanks,
    Miguel



  • @Miguel-Peredo it looks like @Omega303 is still in the process of putting together a guide šŸ˜‰

    What @Omega303 mentioned above is you do following steps to get the 1 wire running:

    1. Upgrade your firmwire to the latest (via the gui under settings is easiest)

    touch /etc/modules.d/55-w1-gpio-custom
    vi /etc/modules.d/55-w1-gpio-custom

    Then add this one line (replace 19 with the pin # you want to use):
    w1-gpio-custom bus0=0,19,0

    1. Restart your onion. Then you should see contents in /sys/devices/w1_bus_master1/* now ... if your device is plugged in then there should be a file reading /sys/devices/w1_bus_master1/28-DEVICEID/w1_slave (28-DEVICEID where * is the id of your device)

    I'm currently not getting a read from #3 - so that's where I'm stumped (any advice with the comments above?) šŸ˜ž but at least I know w1 is running.



  • @Nathan-Bertram Although I found a DS18B20 spec telling the sensor can be driven from 3.0 to 5.5 Volts, I recommend the 3.3 V instead of 5V. But more important is to insert a 4.7 kOhm resistor between data pin and GPIO. I think the missing resistor disables proper communication. The sensor id needs to remain the same - it is the hardware address for the 1-wire master to request data. Here is how I connected the sensor: DS18B20_small.png



  • @Omega303 ah... I tried hooking up a a 4.7k resistor last night but obviously read the diagram incorrectly: http://monosnap.com/image/ideZC9zI136vSFrAo9LC2747TTcqio not sure what i was thinking LOL -- I'll try again tonight and let you know how it goes. Thank you!



  • Hi,
    The electronics (diagram) in my case is OK. The issue is that I do not have /etc/modules.d/55 p.....

    I have listed in a previous post all modules I have with gpio.

    Any suggestions ?
    Thx,



  • @Miguel-Corteguera you'll need to create the file (touch) then insert the line with the correct pin # as instructed above



  • @Nathan-Bertram Hi, thanks for the tip. Created the file, restarted the Onion, folder /etc/devices/w1_master_driver now exists, but nothing with DEVICE to be found there.
    Any ideas ?



  • Now it's working, using +5V and GND and PIN 26. Before I was using + 3.3V. My sensor is a 18B20 with 10K resistor.



  • This is how it looks: šŸ˜„

    root@Omega-276D:/sys/devices/w1_bus_master1/28-0415a810c3ff# cat w1_slave
    7b 01 4b 46 7f ff 0c 10 af : crc=af YES
    7b 01 4b 46 7f ff 0c 10 af t=23687


  • administrators

    A big thank you to @Omega303, his awesome 1-Wire tutorial is now up on the Onion Wiki: https://wiki.onion.io/Tutorials/Reading-1Wire-Sensor-Data
    šŸ˜„ šŸ˜„



  • SUCCESS - thanks @Omega303 guide looks awesome - finally got it to work after hooking up my resistor correctly this time (using the 5v power source though -- I changed my pin # to 19 instead of 0 and it worked):

    awk -F= '/t=/ {printf "%.03f\n", $2/1000}' /sys/devices/w1_bus_master1/28-0215718f9dff/w1_slave
    21.500

    Yeah!



  • Using firmware 0.0.6 b275, the temperature DS18B20 works using a 3.3V connection with a 4.7K pull-up resistor on the Data out line. A DS18B20 PAR (PARASITIC version) also works. I connected it using GPIO 26 and I have an OLED to display the time and temperature using some python code.
    IanOscarOmegaOnion_temperature.jpg



  • I finally got a chance to try the tutorial, and it worked right away! Thanks Omega303!


Log in to reply
 

Looks like your connection to Community was lost, please wait while we try to reconnect.