One wire setup on BeagleBone Black

Here is the DTS file that I used to compile to setup One-Wire connection on Beaglebone Black.
I have used P9.22 for one wire connection and in parasitic mode.

/dts-v1/;
/plugin/;
/ {
    compatible = "ti,beaglebone", "ti,beaglebone-black";
    part-number = "BB-W1";
    version = "00A0";
    /* state the resources this cape uses */
    exclusive-use =
    /* the pin header uses */
    "P9.22",
    /* the hardware IP uses */
    "gpio0_2";
    fragment@0 {
      target = <&am33xx_pinmux>;
      __overlay__ {
        dallas_w1_pins: pinmux_dallas_w1_pins {
          pinctrl-single,pins = < 0x150 0x37 >;
        };
      };
    };
    fragment@1 {
    target = <&ocp>;
    __overlay__ {
        onewire@0 {
          compatible      = "w1-gpio";
          pinctrl-names   = "default";
          pinctrl-0       = <&dallas_w1_pins>;
          status          = "okay";
          gpios = <&gpio1 2 0>;
          };
        };
    };
};

Here DS18B20 or DS18S20 sensors are connected in parasitic mode, consuming only 2 wires for connection. VDD pin must be connected to GND pin of each sensors. 47 Ohms resistors are added to GND and 1wire terminal on BBB to limit current in case lines are short circuited. BBB specify that pins are at 3.3V logic and not 5V tolerant, so for more safer side you may connect to 3.3V VDD and reduce the value of R1 (say around 1.5k)

ds18b20BBB.png

Setup NetBeans to develop php application in Beaglebone Black / Raspberry Pi ( Setup remote connection)

  1. Project propertiesconnectionproperties-runas

2)  connectionproperties-runas_ink_li

connectionproperties

If remote connection not setup already, then click add to create a new one.

createnewconnection

Note Initial directory, it will be root directory to upload project files by NetBeans.

Setup pins on Beaglebone Black

 


debian@beaglebone:~$ nano /etc/rc.local

#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.

#export gpio, configure pin for output and set permissions to allow all users

#GPIO PIN SETUP
echo 66 > /sys/class/gpio/export
chmod 666 /sys/class/gpio/gpio66/value
chmod 666 /sys/class/gpio/gpio66/direction
echo out > /sys/class/gpio/gpio66/direction

echo 67 > /sys/class/gpio/export
chmod 666 /sys/class/gpio/gpio67/value
chmod 666 /sys/class/gpio/gpio67/direction
echo out > /sys/class/gpio/gpio67/direction
echo 68 > /sys/class/gpio/export
chmod 666 /sys/class/gpio/gpio68/value
chmod 666 /sys/class/gpio/gpio68/direction
echo out > /sys/class/gpio/gpio68/direction
#GPIO PIN SETUP END
#PWM PIN SETUP
chmod 666 /sys/devices/ocp.*/pwm_test_P9_14.*/duty
chmod 666 /sys/devices/ocp.*/pwm_test_P9_16.*/duty
chmod 666 /sys/devices/ocp.*/pwm_test_P9_29.*/duty
chmod 666 /sys/devices/ocp.*/pwm_test_P9_14.*/period
chmod 666 /sys/devices/ocp.*/pwm_test_P9_16.*/period
chmod 666 /sys/devices/ocp.*/pwm_test_P9_29.*/period

#PWN PIN SETUP END

exit 0

 

Remote connection to MySQL in BBB/Raspberry Pi/Linux

This post describes the required settings for MySQL in BBB/Raspberry/Linux so as to connect from a remote client in non root mode.

Connect to BBB/Raspberry/Linux shell using an SSH client such as PuTTY or direct connection.


sudo nano /etc/mysql/my.cnf

change

bind-address   = localhost

to 

bind-address   = 0.0.0.0

Login to root mysql


debian@beaglebone:~$ sudo mysql -p

<enter root password>

mysql> GRANT ALL PRIVILEGES ON *.* TO 'user1'@'%'
         IDENTIFIED BY 'user1password';

change privileges of the required user to allow
remote connection. Note % symbol, which mean it
will allow from any domain including localhost.
By default is localhost.

*.* specifies grant to all databases. You can restrict
to specific database using

yourdatabase.* instead of *.*

Restart MySQL using


sudo service mysql restart

Now you will be able to connect to MySQL using non root database accounts.

Read temperature from 1-wire in Beaglebone Black [BBB] / Raspberry Pi

debian@beaglebone:/$ cd /sys/bus/w1/devices
debian@beaglebone:/sys/bus/w1/devices$ ls
10-00080216a25a  10-00080216c818  28-031644d030ff  28-03164757c8ff  28-041651ca4dff  w1_bus_master1
debian@beaglebone:/sys/bus/w1/devices$ cat 10-00080216a25a/w1_slave
2d 00 4c 47 ff ff 02 10 51 : crc=51 YES
2d 00 4c 47 ff ff 02 10 51 t=22625
debian@beaglebone:/sys/bus/w1/devices$

cd to the folder /sys/bus/w1/devices
list files using ls
if any 1-wire sensors are connected it will appear here as below.
10-00080216a25a 10-00080216c818  28-031644d030ff  28-03164757c8ff  28-041651ca4dff 
Above are connected 1-wire temperature sensors.
DS18S20 [Starts with id 10-xxxx] and DS18B20  [Starts with id 28-xxxx] sensors
To read temperature read the file w1_slave of any sensor using command ‘cat’

Temperature is read as 22.625 ºC

Beaglebone http server lighttpd setup

debian@beaglebone:~$ sudo nano  /etc/lighttpd/lighttpd.conf

doc_root="/var/www/html"
server.modules = ( "mod_access",
                 "mod_alias",
                 "mod_compress",
                 "mod_redirect",
         #       "mod_rewrite", )
server.document-root        = "/var/www/html"
server.upload-dirs          = ( "/var/cache/lighttpd/uploads" )
server.errorlog             = "/var/log/lighttpd/error.log"
server.pid-file             = "/var/run/lighttpd.pid"
server.username             = "www-data"
server.groupname            = "www-data"
server.port                 = 80
index-file.names           =
("index.php", "index.html", "index.lighttpd.html" )
url.access-deny             = ( "~", ".inc" )
static-file.exclude-extensions = ( ".php", ".pl", ".fcgi" )
compress.cache-dir          = "/var/cache/lighttpd/compress/"
compress.filetype           = ( "application/javascript", "text/css", "text/html", "text/plain" )
# default listening port for IPv6 falls back to the IPv4 port
include_shell "/usr/share/lighttpd/use-ipv6.pl " + server.port
include_shell "/usr/share/lighttpd/create-mime.assign.pl"
include_shell "/usr/share/lighttpd/include-conf-enabled.pl"
.
.