Jump to content

DS18B20 temperature sensor in Lamobo R1


Rui Ribeiro

Recommended Posts

Been trying to use a DS18B20 with the Lamobo R1 and the last ArmBian, without success.

 

As I have already an RTC in the first pins, connected it as follows:

 

PIN 16=GPI04 / DATA

PIN 17=3.3V

PIN 20=GND

 

I also added the required resistor between 3.3V and GPI04.

 

Add to /etc/modules

 

w1_sunxi

w1_gpio

w1_therm

 

Added to my fex file:

 

[w1_para]

w1_used = 1

gpio = 16

 

Modified my dts:

 

 pinctrl@01c20800 {

....

                       my_w1_pin@0 {

                                allwinner,pins = "PH16";

                                allwinner,function = "gpio_in";

                                allwinner,drive = <0x0>;

                                allwinner,pull = <0x1>;

                                linux,phandle = <0x44>;

                                phandle = <0x44>;

                        };

                };

 

       onewire_device {

                compatible = "w1-gpio";

                gpios = <0x1f 0x8 0x14 0x0>;

                pinctrl-names = "default";

                pinctrl-0 = <0x44>;

                status = "okay";

        }; 

 

I also disabled the UART associated with pin 16.

 

After rebooting, no sign of it:

 

root@ruir:/sys/bus/w1/devices# ls -la

total 0

drwxr-xr-x 2 root root 0 Apr 11 17:56 .

drwxr-xr-x 4 root root 0 Apr 11 17:55 ..

root@ruir:/sys/bus/w1/devices#

 

So what do you think I am actually missing?

 

P.S. I am reading about raspberry folds adding 

dtoverlay=w1-gpio,gpiopin=16

To their configurations, no idea if it applies or what to do about that.

Link to comment
Share on other sites

Thanks for the link. The syntax is nowhere near the one I am seeing, do not have no idea how to use it. Or rather, I tried, with compilation errors.

 

The file is /boot/dtb/sun7i-a20-bananapi-r1.dtb

 

 

cat /proc/device-tree/model

Lamobo R1

 

 

I already found the sources in github, will have a look at all this later on.

Link to comment
Share on other sites

I think patch would look like this

diff --git a/arch/arm/boot/dts/sun7i-a20-lamobo-r1.dts b/arch/arm/boot/dts/sun7i-a20-lamobo-r1.dts
index 69b11dc..1a7890a 100644
--- a/arch/arm/boot/dts/sun7i-a20-lamobo-r1.dts
+++ b/arch/arm/boot/dts/sun7i-a20-lamobo-r1.dts
@@ -136,9 +136,22 @@
 				allwinner,drive = <0>;
 				allwinner,pull = <0>;
 			};
-			
+
+			w1_pin: w1_pin@0 {
+				allwinner,pins = "PH2";
+				allwinner,function = "gpio_in";
+				allwinner,drive = <SUN4I_PINCTRL_10_MA>;
+				allwinner,pull = <SUN4I_PINCTRL_PULL_UP>;
+			};
 		};
 
+		onewire_device {
+			compatible = "w1-gpio";
+			gpios = <&pio 7 2 GPIO_ACTIVE_HIGH>; /* PH2 */
+			pinctrl-names = "default";
+			pinctrl-0 = <&w1_pin>;
+};
+
 		uart0: serial@01c28000 {
 			pinctrl-names = "default";
 			pinctrl-0 = <&uart0_pins_a>;

You may try this precompiled DTB: https://dl.dropboxusercontent.com/u/5385968/sun7i-a20-lamobo-r1.dtb

 

This is for 1-wire pin PH2 (it is GPIO 1 I believe)

 

Edit: Since you are using external pull-up resistor then it's better to disable internal pull-up, but it shouldn't affect test results.

Link to comment
Share on other sites

I think I already understood the notation, thank you.

 

From here: http://www.open-electronics.org/discover-banana-pi-another-linux-board-for-you-to-experiment-with/

 

 

CON3-P12 IO-1 PH2 --- Pin 12, and Lamobo R1 bus image http://www.bananapi.com/images/R1/xGPIO-1.png.pagespeed.ic.0wsn5qmxof.png

 

Aparently from A20 manual - 2 PH2 GPIO-3 pin 7

 

. Thanks Zador. I already took out the file.

Link to comment
Share on other sites

Hello

I'm trying to use the same DS18B20 with my Lamobo-R1 GPIO pins... I just can't seem to figure it out how to do it by using the guide above. I'm using 5.16 builds since 5.20 doesn't have the swconfig tool integrated ... I tried to use pin 7 form con3 as it is the default so called gpio = 4 (w1_para) and also tried pins 12, 16 and 18... can't seem to find anything...

Modifying the dts for lamobo r1 isn't the same as above.... (I would like to understand what I'm supposed to modify)

Thank you in advance

Link to comment
Share on other sites

Hello

I'm trying to use the same DS18B20 with my Lamobo-R1 GPIO pins... I just can't seem to figure it out how to do it by using the guide above. I'm using 5.16 builds since 5.20 doesn't have the swconfig tool integrated ... I tried to use pin 7 form con3 as it is the default so called gpio = 4 (w1_para) and also tried pins 12, 16 and 18... can't seem to find anything...

Modifying the dts for lamobo r1 isn't the same as above.... (I would like to understand what I'm supposed to modify)

Thank you in advance

 

Hi bad,

 

Just keep in mind the R1 bus is inverted compared to the raspberry; and that each upgrade do the kernel places there again the new dtb. I am beginning the day here, later at home I can send you photos and place here the dtb that zador posted for me (and that I am still using)

Link to comment
Share on other sites

Hi bad,

 

Just keep in mind the R1 bus is inverted compared to the raspberry; and that each upgrade do the kernel places there again the new dtb. I am beginning the day here, later at home I can send you photos and place here the dtb that zador posted for me (and that I am still using)

Thank you very much ... in this way I can analyze it to see what I must change in the 5.16 armbian's dtb.

Link to comment
Share on other sites

OK

So here's what I did:

- used a 4,7k resistor between data pin and +3,3v pin on the DS18B20.

- used the same pin (12) in /boot/bin/lamobo-r1.bin (bin2fex, edit, fex2bin):

[w1_para]
gpio = 12

- converted the /boot/dtb/sun7i-a20-lamobo-r1.dtb for editing

dtc -I dtb -O dts -o sun7i-a20-lamobo-r1.dts sun7i-a20-lamobo-r1.dtb

- search for the next section to add the lines below (no need for comments):

			led_pins@0 {
				allwinner,pins = "PH24";
				allwinner,function = "gpio_out";
				allwinner,drive = <0x0>;
				allwinner,pull = <0x0>;
				linux,phandle = <0x46>;
				phandle = <0x46>;
			};
+
+			w1_pin@0 {
+				allwinner,pins = "PH2";
+				allwinner,function = "gpio_in";
+				allwinner,drive = <0x0>;
+				allwinner,pull = <1>;
+				linux,phandle = <0x48>; /# X = incremented (hex) by searching the hole dts file for phandles #/
+				phandle = <0x48>;       /# X = same incremented value #/
+			};
		};

		timer@01c20c00 {
			compatible = "allwinner,sun4i-a10-timer";
			reg = <0x1c20c00 0x90>;
			interrupts = <0x0 0x16 0x4 0x0 0x17 0x4 0x0 0x18 0x4 0x0 0x19 0x4 0x0 0x43 0x4 0x0 0x44 0x4>;
			clocks = <0xa>;
		};
 

- go to next section and add the next lines (no need for comments):

		ps2@01c2a400 {
			compatible = "allwinner,sun4i-a10-ps2";
			reg = <0x1c2a400 0x400>;
			interrupts = <0x0 0x3f 0x4>;
			clocks = <0x37 0x7>;
			status = "disabled";
		};
+
+		onewire_device {
+			compatible = "w1-gpio";
+			gpios = <0x22 0x7 0x2 0x0>; /# 0x22 value is taken from below, similar to the initial uploaded dtb (zador's); #/
                                                    /# the rest are the same as the initial uploaded dtb (zador's) #/
+			pinctrl-names = "default";
+			pinctrl-0 = <0x48>;         /# X = same incremented value #/
+			status = "okay";
+		};
	};

	ahci-5v {
		compatible = "regulator-fixed";
		pinctrl-names = "default";
		pinctrl-0 = <0x42>;
		regulator-name = "ahci-5v";
		regulator-min-microvolt = <0x4c4b40>;
		regulator-max-microvolt = <0x4c4b40>;
		regulator-boot-on;
		enable-active-high;
		gpio = <0x22 0x1 0x3 0x0>;
		status = "okay";
		linux,phandle = <0x30>;
		phandle = <0x30>;
	};

	usb0-vbus {
		compatible = "regulator-fixed";
		pinctrl-names = "default";
		pinctrl-0 = <0x43>;
		regulator-name = "usb0-vbus";
		regulator-min-microvolt = <0x4c4b40>;
		regulator-max-microvolt = <0x4c4b40>;
		enable-active-high;
		gpio = <0x22 0x1 0x9 0x0>;
		status = "okay";
		linux,phandle = <0x2b>;
		phandle = <0x2b>;
	};

- reconverted the new /boot/dtb/sun7i-a20-lamobo-r1.dts

dtc -I dts -O dtb -o sun7i-a20-lamobo-r1.dtb sun7i-a20-lamobo-r1.dts

- in /etc/modules added:

w1-therm
w1-gpio 

- now finnaly something appears in /sys/bus/w1/devices

 

Thanks for the dtb... very usefull

 

 

---

A patch I made to speed up the dtb patching of the new 5.25 jessie mainline armbian : https://www.dropbox.com/sh/ciiun8n56c46q2n/AACUw3qe981xrnoCWR7vgJ0ga/w1-temp.tar.gz?dl=0

---

Link to comment
Share on other sites

I also have the resistor there. However with my humidity sensors I did away with it. It *seems* it is not needed with the Lamobo R1. I think I  have read something about that, I might be wrong. Congratulations. As I said, save that dtb file, and do not forget after each kernel upgrade from Armbian to copy it over again.

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • Create New...

Important Information

Terms of Use - Privacy Policy - Guidelines