enabling temperature sensor

Connection

Beaglebone DHT11

Connect 3 Pins of DH11 3.3V,  ground and P8_11 headers, for DHT11 sensor initialization by reference of BeagleBone Black’s cape expansion headers information

DH11 specifications

Download Python Library for DHT

Adafruit Python DHT Sensor Library

Python3
$sudo apt-get update 
$sudo apt-get install python3-pip 
$sudo python3 -m pip install --upgrade pip setuptools wheel

Setup Library
$sudo pip3 install Adafruit_DHT

Examine CODES

$sudo python3 ./AdafruitDHT.py 11 P8_11
Temp=21.0* Humidity=39.0%

#!/usr/bin/python
import sys
import Adafruit_DHT

sensor=11
pin="P8_11"

while True:
    humidity, temperature = Adafruit_DHT.read_retry(sensor, pin)
    print('Temp={0:0.1f}*  Humidity={1:0.1f}%'.format(temperature, humidity))

Displaying on LED 7 Segments

Installing Crossbuild tools

A cross compiler is a compiler capable of creating executable code for a platform other than the one on which the compiler is running. For example, a compiler that runs on a Windows 7PC but generates code that runs on Android smartphone is a cross compiler (Wikipedia)

Dependency check on crossbuild-essential-armhf

We should install three pre-requisite packages (actually, two packages)
dpkg-cross, g++arm-linux-gnueabihf and gcc-arm-linux-gnueabihf
$sudo apt-get install dpkg-cross g++arm-linux-gnuabihf

Then, finally crossbuild-essential-armhf can be installed.
$sudo apt-get install crossbuild-essential-armhf

Simple Code Compile/Execution

Hostmachine :Ubuntu 18.04.3 LTS, Architecturer: x86-64

Hostmachine: Debian 9, Architecturer: arm

give BBB an internet access

Tried many things to make BBB connected to internet. There’re few different ways such as by enabling ethernet port or adding USB Wi-Fi dongle. But it won’t work stable when we move BBB to difference environment. Thus, I think sharing host internet is easiest way to give BBB an internet access. To make this we should route all outbound packets to this device from the BBB to the Internet via the Internet access interface.

First thing first, make USB connection between BBB and host machine.
Then check the IP address on USB port.

USB0 has 192.168.7.1 and it is a default gateway for BBB’s usb0 interface.

Host Setting

#Enabling traffic re-routing to Internet Access interface on host machine
#In this case, Internet traffic fro BBB’s USB0 enx4c3fd3c18fa6 will be routed to host’s Wi-Fi interface wlp10
$sudo sysctl net.ipv4.ip_forward=1
$sudo iptables --table nat --append POSTROUTING --out-interface wlp1s0 -j MASQUERADE
$sudo iptables --append FORWARD --in-interface enx4c3fd3c18fa6 -j ACCEPT

BBB Setting

#as a root
[email protected]:/#route add default gw 192.168.7.1
[email protected]:/#echo "nameserver 8.8.8.8" >> /etc/resolv.conf