-
-
Notifications
You must be signed in to change notification settings - Fork 14
I2C
Gateway can be extended using Addons
Originally published at:
- https://web.archive.org/web/20181208022842/https://s-opensource.org/2018/04/25/mozilla-iot-generic-sensors/
- https://github.com/rzr/webthing-iotjs/wiki/Addons
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 pi@gateway.local # 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
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 pi@gateway.local #
#| pi@gateway.local'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,
- https://web.archive.org/web/20180928033135/https://s-opensource.org/category/internet-of-things/
- https://web.archive.org/web/20180928033135/https://s-opensource.org/tag/artik
- https://web.archive.org/web/20180928033135/https://s-opensource.org/tag/raspbian
- https://web.archive.org/web/20180928033135/https://s-opensource.org/tag/pi
- https://web.archive.org/web/20180928033135/https://s-opensource.org/tag/iotjs
Check Concept page for overview, Gateway to get started, IotJs page to install runtime to build webthing as explained in Home page.
For further experiments check Social and Sensor, or Extra parts like WebApp (for Tizen or PWA) or MCU info about running on other microcontrollers not supported by TizenRT.
While Home focus mostly on using iotjs to build webthings (on GNU/Linux or TizenRT for ARTIK05X devices).
This document is still in draft state, but reviews are always welcome, if you try to replicate it and stuck on missing instructions I would appreciate that you file issues or even better make pull request (just edit in github) that insert "TODO marks" in following chapters, like:
- TODO: please explain more this chapter and then remove this TODO line
Community contributions are welcome at:
Support is also possible, ask in:
- https://github.com/rzr/webthing-iotjs
- irc://irc.mozilla.org/#iot
WARNING: Developement branches could break over time.
Instead of maintaining "quick and dirty" demo code, I decided to split demo in smaller independents parts (which can reused) and I am upstreaming the most I can.
Then support can be done on mainline branches (or released versions).
Note that, Upstreaming can be a slow process, so snapshots links will remain until 100% of code is upstreamed.
Licence:
Reference documentation is at:
-
Concept:
- Demo Concept and Architecture
-
Gateway:
- Getting started with Mozilla IoT gateway
-
IotJs:
- Install IoT.js needed to run webthings
-
Home:
- Welcome page to build WebThings using IotJs
-
Social:
- Notification service using Mastodon FLOSS
-
TizenRT:
- webthing-iotjs on ARTIK05x
-
Sensor: and Actuator
- Physical interactions
-
Extra hints:
- Docker: About running in container
- MCU: About microcontrollers (not supported by TizenRT)
- WebApp: Alternate browser (Tizen and PWA)
- GnuLinux: Article about Edison and other
- Raspbian: Article about RaspberryPi
- Arduino: Alt For atmel or Esprissif boards
- DigitalTwins : WiP experiments
- TODO: Work in progress