Introduction
This page will show you step-by-step how to interface a i2c Temperature module to the DE0-Nano-SoC.
Hardware Requirements
DE0-Nano-SoC Kit at Digi-Key
TH02 Humidity, Temperature Sensor at Digi-Key
USB WIRELESS ADAPTER 150MB 802.11/B/G/N at Digi-Key
USB OTG HOST CABLE at Digi-Key
Software Requirements
-
DE0-Nano-SoC running Debian Jessie:
- Grab the Latest from: https://eewiki.net/display/linuxonarm/DE0-Nano-SoC+Kit using the v4.6.x based kernel
-
Exosite Portals:
Disable eth0 and Setup WiFi access with connman
Start connmanctl
debian@arm:~$ connmanctl
Disable eth0, as we are connecting via WiFi
connmanctl> disable ethernet
Disabled ethernet
Enable WiFi
connmanctl> enable wifi
Enabled wifi
Scan WiFi
connmanctl> scan wifi
Scan completed for wifi
List found services
connmanctl> services
BeagleBone wifi_00e1b0127538_426561676c65426f6e65_managed_psk
Enable agent
connmanctl> agent on
Agent registered
Connect to open “BeagleBone” Access Point
connmanctl> connect wifi_00e1b0127538_426561676c65426f6e65_managed_psk
Agent RequestInput wifi_00e1b0127538_426561676c65426f6e65_managed_psk
Passphrase = [ Type=psk, Requirement=mandatory, Alternates=[ WPS ] ]
WPS = [ Type=wpspin, Requirement=alternate ]
Passphrase? BeagleBone`
exit connmanctl
connmanctl> quit
Check Network:
debian@arm:~$ sudo ifconfig -a
eth0 Link encap:Ethernet HWaddr 4a:9f:40:e1:c8:5e
BROADCAST MULTICAST DYNAMIC MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
Interrupt:27 Base address:0xc000
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:65536 Metric:1
RX packets:3840 errors:0 dropped:0 overruns:0 frame:0
TX packets:3840 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1
RX bytes:296320 (289.3 KiB) TX bytes:296320 (289.3 KiB)
wlx00e1b0127538 Link encap:Ethernet HWaddr 00:e1:b0:12:75:38
inet addr:192.168.1.3 Bcast:192.168.1.255 Mask:255.255.255.0
inet6 addr: fe80::2e1:b0ff:fe12:7538/64 Scope:Link
UP BROADCAST RUNNING MULTICAST DYNAMIC MTU:1500 Metric:1
RX packets:17 errors:0 dropped:0 overruns:0 frame:0
TX packets:53 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:2772 (2.7 KiB) TX bytes:10507 (10.2 KiB)
Temperature Sensor
Add device:
debian@arm:~$ sudo sh -c "echo si7005 0x40 > /sys/bus/i2c/devices/i2c-1/new_device"
debian@arm:~$ dmesg | grep i2c-1
[ 49.755377] i2c i2c-1: new_device: Instantiated device si7005 at 0x40
Look at the iio device:
debian@arm:~$ ls /sys/bus/iio/devices/iio\:device0/in_temp*
/sys/bus/iio/devices/iio:device0/in_temp_offset
/sys/bus/iio/devices/iio:device0/in_temp_raw
/sys/bus/iio/devices/iio:device0/in_temp_scale
debian@arm:~$ cat /sys/bus/iio/devices/iio:device0/in_temp*
-6400
9452
7.812500
Conversion:
T = ((in_temp0_raw + in_temp0_offset) * in_temp0_scale) / 1000
T = ((9452 + -6400) * 7.812500) / 1000
T = (3052 * 7.812500) / 1000
T = 23843.75 / 1000
T = 23.84375 (C) -> 74.91875 (F)
Script the conversion using bc:
#!/bin/bash -e
in_temp_raw=$(cat /sys/bus/iio/devices/iio:device0/in_temp_raw || true)
in_temp_offset=$(cat /sys/bus/iio/devices/iio:device0/in_temp_offset || true)
in_temp_scale=$(cat /sys/bus/iio/devices/iio:device0/in_temp_scale || true)
if [ ! "x${in_temp_raw}" = "x" ] && [ ! "x${in_temp_offset}" = "x" ] && [ ! "x${in_temp_scale}" = "x" ] ; then
temp=$(echo "${in_temp_raw} + ${in_temp_offset}" | bc)
temp=$(echo "scale=5; ${temp} * ${in_temp_scale}" | bc)
temp=$(echo "scale=3; ${temp} / 1000" | bc)
echo "${temp}"
fi
Setup Exosite Portals
For this project we are going to use Exosite Portals to store the IOT data.
sudo apt-get update
sudo apt-get install bc build-essential python-dev python-setuptools`
Install Exoline
git clone https://github.com/exosite/exoline --depth=1
cd ./exoline
sudo python setup.py install
cd ~/
Digi-Key Demo
Demo:
git clone https:` `//github.com/RobertCNelson/demos --depth=1
cron:
* * * * * root /bin/bash /home/debian/demos/intel-soc-fpga-forum-2016/example.sh &> /dev/null &