Skip to content

Commit

Permalink
Updated Multiple Files
Browse files Browse the repository at this point in the history
  • Loading branch information
digicosmos86 committed Apr 24, 2018
1 parent a53c062 commit aa2e572
Show file tree
Hide file tree
Showing 43 changed files with 976 additions and 214 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
build/*
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"python.linting.pylintEnabled": false
}
Binary file modified build/doctrees/actuators.doctree
Binary file not shown.
Binary file modified build/doctrees/api.doctree
Binary file not shown.
Binary file modified build/doctrees/environment.pickle
Binary file not shown.
Binary file modified build/doctrees/guide.doctree
Binary file not shown.
Binary file modified build/doctrees/index.doctree
Binary file not shown.
Binary file modified build/doctrees/install.doctree
Binary file not shown.
Binary file modified build/doctrees/intro.doctree
Binary file not shown.
Binary file modified build/doctrees/iot.doctree
Binary file not shown.
Binary file modified build/doctrees/raspi.doctree
Binary file not shown.
Binary file modified build/doctrees/sensors.doctree
Binary file not shown.
Binary file modified build/doctrees/wiolink.doctree
Binary file not shown.
2 changes: 1 addition & 1 deletion build/html/.buildinfo
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Sphinx build info version 1
# This file hashes the configuration used when building these files. When it is not found, a full rebuild will be done.
config: 966fce7afb5ecd0f795d5d7b76d9b258
config: 1d3f67f76f08f5c99e0c6bad68651acc
tags: 645f666f9bcd5a90fca523b33c5a78b7
91 changes: 79 additions & 12 deletions build/html/_sources/actuators.rst.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
Actuators
==================================
:mod:`actuators` - Working with Actuators
=========================================

The :mod:`actuators` module provides a collection of classes to interact with actuators, such as servos, relays, and buttons.

.. _servo:

Servo
----------------------------------

.. image:: https://github.com/SeeedDocument/Grove-Servo/raw/master/img/Grove%E2%80%94Servo.jpg
:width: 200px
:height: 200px

.. class:: actuators.Servo(port[=2], position[=0])

Allows control of a Grove Servo. Default ``port`` for the servo is ``2``. The ``position`` parameter sets the initial position of the servo.
Expand All @@ -26,9 +34,15 @@ Example:
s = Servo(1, init_degree = 180) # defines a servo connected to port 1 with initial position at 180 degrees.
s.set_position(90) # rotate the servo by 90 degrees.
.. _relay:

Relay
----------------------------------

.. image:: https://raw.githubusercontent.com/SeeedDocument/Grove-Relay/master/img/Twig-Relay.jpg
:width: 200px
:height: 200px

.. class:: actuators.Relay(port[=1])

Allows control of a Grove Relay. The relay by default is normally open (NO) triggered by a ``high`` signal.
Expand All @@ -41,21 +55,74 @@ Relay

Deactivate the relay, open the circuit, and turn off whatever appliance that's connected to the relay.

Grow Light Strip
----------------------------------
.. method:: Relay.is_on()

Returns ``True`` if the relay is on, or ``False`` if the relay is off.

.. _button:

Button
-------------------------

.. image:: https://github.com/SeeedDocument/Grove_Button/raw/master/img/Button.jpg
:width: 200px
:height: 200px

.. class:: actuators.Button(port[=2], pullup[=True])

Allows control of a Grove Button. There are two ways to use a button. First, you can access ``Button.is_pressed`` property or ``Button.is_pressed()`` method to determine if the button is pressed. Alternatively, you can also set a callback function with ``Button.on_release()`` method use the interrupt mechanism. Please see example of how to use the callback.

.. method:: Button.is_pressed()

Returns ``True`` if the button is pressed, or ``False`` if it is not.

.. class:: GrowLight(port[=1], n[=60])
.. method:: Button.on_press(callback)

Allows control of a 5V LED strip based on the WS2812b (NeoPixel). ``n`` specifies the number of LEDs on the strip. Default is ``60``.
Executes the ``callback`` function provided to the method when the button is pressed.

.. method:: Button.on_release(callback)

Executes the ``callback`` function provided to the method when the button is released.

Example
^^^^^^^^^^^^^^^^^^^^^

Controlling the LED with the Button

.. code-block:: python
from actuators import Led, Button
led = Led(1) # Specifies an LED at Port 1
button = Button(2) # Specifies a button at Port 2
## Turns on the LED when the button is pressed
while True:
if button.is_pressed():
led.on()
else:
led.off()
Turns the LED on/off with a callback function

.. code-block:: python
.. method:: GrowLight.on()
from actuators import Button
from displays import Led
led = Led(1, on=False) # Specifies an LED at Port 1
button = Button(2) # Specifies a button at Port 2
Turns on the LED strip as a plant growth light that emits red and blue light.
## Define a callback function
.. method:: GrowLight.off()
def turn_on_led(pin):
global led # Need this line to refer to the led object outside the function.
Turns off the LED strip.
if led.is_on():
led.off()
else:
led.on()
.. hint::
## Set the callback function to Button.on_release method.
This class is a subclass of MicroPython's ``neopixel.NeoPixel`` class, so it can be programmed the same way as the Neo Pixel. See `this page <http://docs.micropython.org/en/latest/esp8266/esp8266/tutorial/neopixel.html>`_ for more details and examples.
button.on_release(callback=turn_on_led) # Note that no () are needed.
3 changes: 3 additions & 0 deletions build/html/_sources/api.rst.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
.. _api:

API Reference
=====================================

Expand All @@ -7,5 +9,6 @@ API Reference

sensors
actuators
displays
iot

40 changes: 40 additions & 0 deletions build/html/_sources/guide.rst.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,43 @@

Quickstart Guide
=================================

The Wio Link board designed by `SeeedStudio <http://seeedstudio.com>`_ makes it easier to connect sensors and other electronic devices to the board with the Grove interface. We define six grove `ports` numbered below:

.. image:: ports.png

To get started with programming with MicroPython on the Wio Link board, first make sure that you have the firmware installed on the board following the :ref:`wiolink` guide. Then, in the EsPy IDE, connect to the board by clicking on the "Connect" button on the toolbar. Reset the board by pressing the "reset" button on the board, hitting ``Ctrl+D``, or clicking the ``Reset`` button on the toolbar. You will then see a ``>>>`` prompt in the terminal window at the bottom of the screen.

Programming the electronic devices follows the following rules: first you need to create an ``instance`` of that device. This can usually be done in three simple steps:

1. Import the corresponding class
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Let us use the :ref:`temp_sensor` connected to Port 3 as an example. The syntax is follows:

>>> from sensors import TemperatureSensor

``from`` and ``import`` are Python reserved words. :mod:`sensors` is the name of the module, which is always in lowercase ending with an "s." There are three modules available: :mod:`sensors`, :mod:`actuators`, and :mod:`displays`. Within each module you will find the classes available for your device. Refer to the table below to locate your class, which is always in `CamelCase <https://en.wikipedia.org/wiki/Camel_case>`_.

2. Create an instance referring to the sensor
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Create an instance of the ``TemperatureSensor`` class referring to the sensor at Port 3 like this:

>>> temp_sensor = TemperatureSensor(3)

or

>>> temp_sensor = TemperatureSensor(Port=3)

Each device has a default port, and if the sensor is already connected at its default port, then there is no need to specify port number. There might be additional arguments/parameters when creating the instance. Please refer to the :ref:`api` for more information.

3. Interact with the devices using the instances
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Each class offers a set of functionalities for interacting with the devices. In this case, the ``TemperatureSensor`` class offers ``TemperatureSensor.get_temperature()`` and ``TemperatureSensor.get_humidity()`` methods. To use these methods, simply use the **dot notation** to access the methods:

>>> temp_sensor.get_temperature()
>>> temp_sensor.get_humidity()

Please refer to the :ref:`api` for more information on how to use these classes.
6 changes: 4 additions & 2 deletions build/html/_sources/index.rst.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ If you are here for the first time and looking to get started on building your s

If you are looking for information on how start programming the electronics, please go to the :ref:`quickstart` page.

If you are trying to find out how to program a certain device, please click on the corresponding image below.
If you are trying to find out how to program a certain device, please click on the names of the sensors below the corresponding image in the table below.

.. include:: table.rst

.. toctree::
:maxdepth: 3
Expand All @@ -21,4 +23,4 @@ If you are trying to find out how to program a certain device, please click on t
intro
install
guide
api
api
62 changes: 58 additions & 4 deletions build/html/_sources/sensors.rst.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
Sensors
==============================
:mod:`sensors` - Working with Sensors
=====================================

The :mod:`sensors` module provides a collection of classes to interact with sensors, such as temperature, light, and soil moisture sensor.

.. _temp_sensor:

Temperature/Humidity Sensor
------------------------------

.. image:: https://media.digikey.com/Photos/Seeed%20Technology%20Ltd/101020011_sml.JPG
:width: 200px
:height: 200px

.. class:: sensors.TemperatureSensor(port[=3])

Allows reading temperature and humidity information from the Grove Temperature Sensor based on DHT11. We recommend that this sensor be connected to Port 3, which is the default for this class. The ``port`` parameter defines which port the sensor is connected to.
Expand All @@ -21,6 +28,10 @@ Temperature/Humidity Sensor

Returns the relative humidity in percentage.

.. method:: TemperatureSensor.show_data(screen, line)

Shows the temperature (in Fahrenheit) and relative humidity on the specified ``screen`` object on the specified ``line``.

Example
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Expand All @@ -33,6 +44,15 @@ Example
t.get_temperature(True) # returns the Celsius value
t.get_humidity() # returns the humidity value
.. _temp_sensor_pro:

Temperature/Humidity Sensor Pro
----------------------------------

.. image:: https://static.generation-robots.com/3637-large_default/grove-temperature-and-humidity-sensor-pro.jpg
:width: 200px
:height: 200px

.. class:: sensors.TemperatureSensorPro(port[=3])

Allows reading temperature and humidity information from the Grove Temperature Sensor Pro based on DHT22 (AM2302). We recommend that this sensor be connected to Port 3, which is the default for this class. The ``port`` parameter defines which port the sensor is connected to.
Expand All @@ -49,6 +69,10 @@ Example

Returns the relative humidity in percentage.

.. method:: TemperatureSensorPro.show_data(screen, line)

Shows the temperature (in Fahrenheit) and relative humidity on the specified ``screen`` object on the specified ``line``.

.. code-block:: python
from sensors import TemperatureSensorPro
Expand All @@ -58,9 +82,21 @@ Example
t.get_temperature(True) # returns the Celsius value
t.get_humidity() # returns the humidity value
# shows temperature/humidity data on the oled screen
from displays import OledScreen
screen = OledScreen(6)
t.show_data(screen, 1)
.. _light_sensor:

Light Sensor
------------------------------

.. image:: https://raw.githubusercontent.com/SeeedDocument/Grove-Digital_Light_Sensor/master/img/Digital_Light_Sensor.jpg
:width: 200px
:height: 200px

.. class:: sensors.LightSensor(port[=6], address[=0x29])

Allows reading lux values from the Grove Digital Light Sensor based on the TSL2561 I2C light sensor. The ``port`` parameter cannot be any other number than 6, and the sensor can be connected to the board through an I2C hub. The ``address`` parameter assigns the I2C address of the light sensor. ``0x29 (41)`` is the default for the Grove sensor. The Adafruit version has a default of ``0x39 (57)``.
Expand All @@ -80,6 +116,10 @@ Light Sensor
* Twilight: 10.8
* Full Moon: .108

.. method:: LightSensor.show_data(screen, line)

Shows the light intensity reading in lux on the specified ``screen`` object on the specified ``line``.

Example
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Expand All @@ -89,6 +129,8 @@ Example
# and if it's too dark (lux < 100), prints a warning message
from sensors import LightSensor
import time
l = LightSensor()
while True:
Expand All @@ -97,10 +139,18 @@ Example
if lux < 100:
print("Too Dark!")
time.sleep(20) # wait for 20 seconds
.. _moisture_sensor:

Moisture Sensor
------------------------------

.. class:: MoistureSensor(port[=4])
.. image:: https://github.com/SeeedDocument/Grove_Moisture_Sensor/raw/master/images/Moisture_sensor_.jpg
:width: 200px
:height: 200px

.. class:: sensors.MoistureSensor(port[=4])

Allows reading moisture values from the Grove Moisture Sensor. The ``port`` parameter cannot be any other number than 4, because the sensor is analog.

Expand All @@ -110,4 +160,8 @@ Moisture Sensor

.. warning::

Because the moisture sensor is analog, the values of the sensor readings might vary from case to case. It is a good idea to calibrate the sensor by experimenting on the soil.
Because the moisture sensor is analog, the values of the sensor readings might vary from case to case. It is a good idea to calibrate the sensor by experimenting on the soil.

.. method:: MoistureSensor.show_data(screen, line)

Shows the raw moisture reading on the specified ``screen`` object on the specified ``line``.

0 comments on commit aa2e572

Please sign in to comment.