Skip to content
Philippe Coval edited this page Apr 18, 2019 · 2 revisions

I2C

Gateway can be extended using Addons

Originally published at:

EXTRA / MORE

TODO: (but 1st version adapter was supporting 0.4.0 and later)

A GPIO adapter can be also used for actuators, as shown in this demo video.

Extra tip, If you only want to use the gateway and not hack on it, you can skip this next part which enables a developer shell though SSH. However, if you do want access to a developer shell, mount the 1st partition called "boot" (you may need to replug your SD card adapter) and add a file to enable SSH:

sudo touch /media/$USER/boot/ssh
sudo umount /media/$USER/*
ping gateway.local
ssh [email protected] # Raspbian default password for pi user is "raspberry"
ssh: connect to host gateway.local port 22: Connection refused # TODO

Let’s also track local changes to /etc by installing etckeeper, and change the default password.

sudo apt-get update
sudo apt-get install etckeeper
sudo passwd pi
sudo passwd 
sudo apt-get install zile jq screen

Then install IoTjs and start implementing some webthings

https://web.archive.org/web/20181129131920/https://s-opensource.org/wp-content/uploads/2018/04/mozilla-iot-gateway-sensors-20180406rzr-1024x576.png

https://vimeo.com/273037442

TODO:

Before using the mozilla-iot-generic-sensors-adapter, you need to enable the I2C bus on the gateway (version 0.4.0, master has I2C enabled by default).

TODO: ssh

Settings / Developper / Enable SSH
ssh [email protected] #
#| [email protected]'s password: 

sudo raspi-config
#| Raspberry Pi Software Configuration Tool (raspi-config)
#| 5 Interfacing Options Configure connections to peripherals
#| P5 I2C Enable/Disable automatic loading of I2C kernel module
#| Would you like the ARM I2C interface to be enabled?
#| Yes
#| The ARM I2C interface is enabled
ls -l /dev/i2c-1
lsmod | grep i2c
#| i2c_dev 16384 0
#| i2c_bcm2835 16384 0

You can double check if addresses are present on I2C the bus:

sudo apt-get install i2c-tools # TODO
/usr/sbin/i2cdetect -y 1
#|      0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
#| 00: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
#| 10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
#| 20: -- -- -- 23 -- -- -- -- -- 29 -- -- -- -- -- --
#| 30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
#| 40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
#| 50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
#| 60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
#| 70: -- -- -- -- -- -- -- 77

Until sensors adapter is officially supported by the mozilla iot gateway, you’ll need to install it on the device (and rebuild dependencies on the target) using:

https://github.com/mozilla-iot/addon-list/pull/54

url=https://github.com/rzr/mozilla-iot-generic-sensors-adapter
dir=~/.mozilla-iot/addons/generic-sensors-adapter
git clone --depth 1 -b 0.0.1 $url $dir
cd $dir
npm install

Restart gateway (or reboot)

sudo systemctl restart mozilla-iot-gateway.service
tail -F /home/pi/.mozilla-iot/log/run-app.log

Then the sensors addon can be enabled by pressing the "enable" button on the addons page:

URL: http://gateway.local:8080/settings/addons generic-sensors-adapter 0.0.1 Generic Sensors for Mozilla IoT Gateway

It will appear on the adapters page too:

URL: https://gateway.local/settings/adapters
VirtualThingsAdapter
virtual-things
ThingURLAdapter
thing-url-adapter
GenericSensorsAdapter
generic-sensors-adapter

Now we can add those sensors as new things (Save and done buttons):

(try again if you find a big, and file tickets I will forward to drivers authors).

check if the community has shared a JS driver,

RESOURCES:

INDEX

Clone this wiki locally