diff --git a/config.toml b/config.toml index 0d891501..ea3b4e7b 100644 --- a/config.toml +++ b/config.toml @@ -415,7 +415,7 @@ theme = "doc-theme" weight = 70 [[menu.main]] - name = "Expansion Boards" + name = "Shields" url = "/tutorials/expansionboards/" identifier = "tutorials@expansionboards" parent = "tutorials" @@ -737,54 +737,60 @@ theme = "doc-theme" weight = 40 [[menu.main]] - name = "Expansion boards" + name = "Shields" url = "/firmwareapi/pycom/expansionboards/" identifier = "firmwareapi@pycom@expansionboards" parent = "firmwareapi@pycom" weight = 50 [[menu.main]] - name = "Pygate" - url = "/firmwareapi/pycom/expansionboards/pygate/" - identifier = "firmwareapi@pycom@expansionboards@pygate" + name = "Pycoproc" + url = "/firmwareapi/pycom/expansionboards/pycoproc/" + identifier = "firmwareapi@pycom@expansionboards@pycoproc" parent = "firmwareapi@pycom@expansionboards" weight = 10 [[menu.main]] - name = "pysense" - url = "/firmwareapi/pycom/expansionboards/pysense/" - identifier = "firmwareapi@pycom@expansionboards@pysense" + name = "Pycoproc2" + url = "/firmwareapi/pycom/expansionboards/pycoproc2/" + identifier = "firmwareapi@pycom@expansionboards@pycoproc2" parent = "firmwareapi@pycom@expansionboards" weight = 20 [[menu.main]] - name = "pysense 2.0 x" - url = "/firmwareapi/pycom/expansionboards/pysense2/" + name = "LIS2HH12" + url = "/firmwareapi/pycom/expansionboards/LIS2HH12/" identifier = "firmwareapi@pycom@expansionboards@pysense2" parent = "firmwareapi@pycom@expansionboards" weight = 30 [[menu.main]] - name = "pytrack" - url = "/firmwareapi/pycom/expansionboards/pytrack/" - identifier = "firmwareapi@pycom@expansionboards@pytrack" + name = "LTR329ALS01" + url = "/firmwareapi/pycom/expansionboards/LTR329ALS01/" + identifier = "firmwareapi@pycom@expansionboards@LTR329ALS01" parent = "firmwareapi@pycom@expansionboards" weight = 40 [[menu.main]] - name = "pytrack 2.0 x" - url = "/firmwareapi/pycom/expansionboards/pytrack2/" - identifier = "firmwareapi@pycom@expansionboards@pytrack2" + name = "SI7006A20" + url = "/firmwareapi/pycom/expansionboards/SI7006A20/" + identifier = "firmwareapi@pycom@expansionboards@SI7006A20" parent = "firmwareapi@pycom@expansionboards" weight = 50 [[menu.main]] - name = "pyscan" - url = "/firmwareapi/pycom/expansionboards/pyscan/" - identifier = "firmwareapi@pycom@expansionboards@pyscan" + name = "MPL3115A2" + url = "/firmwareapi/pycom/expansionboards/MPL3115A2/" + identifier = "firmwareapi@pycom@expansionboards@MPL3115A2" parent = "firmwareapi@pycom@expansionboards" weight = 60 -[[menu.main]] - name = "sleep" - url = "/firmwareapi/pycom/expansionboards/sleep/" - identifier = "firmwareapi@pycom@expansionboards@sleep" + [[menu.main]] + name = "MFRC630" + url = "/firmwareapi/pycom/expansionboards/MFRC630/" + identifier = "firmwareapi@pycom@expansionboards@MFRC630" parent = "firmwareapi@pycom@expansionboards" weight = 70 +[[menu.main]] + name = "L76GNSS" + url = "/firmwareapi/pycom/expansionboards/L76GNSS/" + identifier = "firmwareapi@pycom@expansionboards@L76GNSS" + parent = "firmwareapi@pycom@expansionboards" + weight = 80 diff --git a/content/firmwareapi/pycom/expansionboards/L76GNSS.md b/content/firmwareapi/pycom/expansionboards/L76GNSS.md new file mode 100644 index 00000000..31b1e7e6 --- /dev/null +++ b/content/firmwareapi/pycom/expansionboards/L76GNSS.md @@ -0,0 +1,25 @@ +--- +Title: "GPS" +--- + +The L76GNSS is the GPS module that can provide location data to your application. + +## Constructors + +### class L76GNSS(pytrack = None, sda = 'P22', scl = 'P21', timeout = None) + +Creates a L76GNSS object. Constructor must be passed a Pytrack or I2C object to successfully construct. Set the `timeout` to a period in seconds for the GPS to search for a lock. If a lock is not found by the time the `timeout` has expired, the `coordinates` method will return `(None, None)`. + +## Methods + +### L76GNSS.coordinates(debug = False) + +Read the longitude and latitude from the `L76GNSS`. Returns a tuple with `(longitude, latitude)`. With `debug` set to `True` the output from the GPS is verbose. + +### L76GNSS.dump_nmea() + +Continuously print nmea sentences received from the `L76GNSS` to the REPL. This is useful if you want to use a graphical tool over UART to visualise GPS reception + +### L76GNSS.write() + +Send commands to the `L76GNSS`. See the datasheet of the L76 for more information. Be aware that some commands might break the communication interface. diff --git a/content/firmwareapi/pycom/expansionboards/LIS2HH12.md b/content/firmwareapi/pycom/expansionboards/LIS2HH12.md new file mode 100644 index 00000000..ab1a0bf6 --- /dev/null +++ b/content/firmwareapi/pycom/expansionboards/LIS2HH12.md @@ -0,0 +1,35 @@ +--- +Title: "Accelerometer" +--- + +The LIS2HH12 is a 3-Axis Accelerometer provides outputs for acceleration, roll and pitch + +## Constructors + +### class LIS2HH12(pycoproc = None, sda = 'P22', scl = 'P21') + +Creates a LIS2HH12 object. Constructor must be passed a Pycoproc or I2C object to successfully construct. + +## Methods + +### LIS2HH12.acceleration() + +Read the acceleration from the accelerometer. Returns a tuple with the 3 values of acceleration in g-force: `(x, y, z)`. + +### LIS2HH12.roll() + +Read the current roll from the accelerometer. Returns a float in degrees in the range -180 to 180. + +### LIS2HH12.pitch() + +Read the current pitch from the accelerometer. Returns a float in degrees in the range -90 to 90. Once the board tilts beyond this range the values will repeat. This is due to a lack of yaw measurement, making it not possible to know the exact orientation of the board. + +### LIS2HH12.enable_activity_interrupt(threshold, duration, handler=None) + +Set an activity- and inactivity interrupt for the accelerometer. This takes the arguments: +* `threshold`: the activity threshold in `mg`, between 62 - 4000 +* `duration`: the duration in `ms`, between 160 - 40800 +* `handler`: The interrupt handler. When not given, it will print `Activity interrupt` and `Inactivity interrupt` +The function returns a tuple containing the set values: `(threshold, duration)`. These depend on the resolution. + + diff --git a/content/firmwareapi/pycom/expansionboards/LTR329ALS01.md b/content/firmwareapi/pycom/expansionboards/LTR329ALS01.md new file mode 100644 index 00000000..ce3b1f31 --- /dev/null +++ b/content/firmwareapi/pycom/expansionboards/LTR329ALS01.md @@ -0,0 +1,28 @@ +--- +Title: "Ambient Light sensor" +--- + +The LTR329ALS01 is a dual light sensor that provides outputs for external light levels in lux. See the datasheet for more information about the wavelengths of the two sensors. + +### Constructors + +### class LTR329ALS01(pycoproc = None, sda = 'P22', scl = 'P21', gain = LTR329ALS01.ALS_GAIN_1X, integration = LTR329ALS01.ALS_INT_100, rate = LTR329ALS01.ALS_RATE_500) + +Creates a LTR329ALS01 object. Constructor must be passed a Pycoproc or I2C object to successfully construct. The additional arguments are: +* `gain`: The light sensor ADC gain. see the Constants for values +* `integration`: Controls the integration time of the periodic measurement. See the Constants for values +* `rate`: The used sample rate in ms, must be set larger than the integration period. See the Constants for values + +## Methods + +### LTR329ALS01.light() + +Read the light levels of both light sensors. Returns a tuple with two values for light levels in lux: `(blue, red)`, between 0-65535. + +## Constants + +The following arguments may be passed into the constructor. + +* gain: `ALS_GAIN_1X`,`ALS_GAIN_2X`, `ALS_GAIN_4X`, `ALS_GAIN_8X`, `ALS_GAIN_48X`, `ALS_GAIN_96X` +* integration: `ALS_INT_50`, `ALS_INT_100`, `ALS_INT_150`, `ALS_INT_200`, `ALS_INT_250`, `ALS_INT_300`, `ALS_INT_350`, `ALS_INT_400` +* rate: `ALS_RATE_50`, `ALS_RATE_100`, `ALS_RATE_200`, `ALS_RATE_500`, `ALS_RATE_1000`, `ALS_RATE_2000` \ No newline at end of file diff --git a/content/firmwareapi/pycom/expansionboards/MFRC630.md b/content/firmwareapi/pycom/expansionboards/MFRC630.md new file mode 100644 index 00000000..7283d74a --- /dev/null +++ b/content/firmwareapi/pycom/expansionboards/MFRC630.md @@ -0,0 +1,94 @@ +--- +Title: "NFC and RFID reader" +--- + +The MFRC630 is a NFC and RFID card reader. + +## Constructors + +### class MFRC630(pycoproc=None, sda='P22', scl='P21', timeout=None, debug=False) + +Creates a `MFRC630` object. Constructor must be passed a Pycoproc or I2C object to successfully construct. + +## Methods + +### MFRC630.mfrc630_cmd_init() + +Initialises the MFRC630. + +### MFRC630.mfrc630_cmd_reset() + +Reset the device. Stops the currently active command and resets device. + +### MFRC630.mfrc630_cmd_idle() + +Set the device into idle mode. Stops the currently active command and return to idle mode. + +### MFRC630.mfrc630_cmd_load_key(key) + +Loads the provided key into the key buffer. + +* `key` Array which holds the MIFARE key, **it is always 6 bytes long** + +#### MFRC630.mfrc630_MF_read_block(block_address, dest) + +Reads a block of memory from an authenticated card. Try to read a block of memory from the card with the appropriate timeouts and error checking. + +* `block_address` The block to read +* `dest` The array in which to write the 16 bytes read from the card + +Returns `0` for failure, otherwise the number of bytes received. + +#### MFRC630.mfrc630_MF_auth(uid, key_type, block) + +Perform a MIFARE authentication procedure. This function is a higher-level wrapper around the MF authenticate command. The result of the authentication is checked to identify whether it appears to have succeeded. The key must be loaded into the key buffer with `MFRC630.mfrc630_cmd_load_key(key)`. + +Once authenticated, the authentication MUST be stopped manually by calling the `mfrc630_MF_deauth()` function or otherwise disabling the `Crypto1 ON` bit in the status register. + +* `key_type`: The MIFARE key A or B (`MFRC630_MF_AUTH_KEY_A` or `MFRC630_MF_AUTH_KEY_B`) to use +* `block`: The block to authenticate +* `uid`: The authentication procedure required the first four bytes of the card's UID to authenticate + +Returns `0` in case of failure, nonzero in case of success. + +#### MFRC630.mfrc630_MF_deauth() + +Disables MIFARE authentication. Disable the `Crypto1` bit from the status register to disable encryption. + +#### MFRC630.mfrc630_iso14443a_WUPA_REQA(instruction) + +Send `WUPA` and `REQA`. Returns the response byte, the answer to request `A` byte (`ATQA`), or `0` in case of no answer. + +* instruction: `MFRC630_ISO14443_CMD_WUPA`, `MFRC630_ISO14443_CMD_REQA` + +#### MFRC630.mfrc630_iso14443a_select(uid) + +Performs the `SELECT` procedure to discover a card's UID. This performs the `SELECT` procedure as explained in _ISO14443A_, this determines the UID of the card, if multiple cards are present, a collision will occur, which is handled according to the norm. + +* `uid`: The UID of the card will be stored into this array. + +Returns the length of the UID in bytes (`4, 7, 10`), or `0` in case of failure. + +#### MFRC630.print_debug(msg) + +Prints debug statements if `DEBUG` is enabled. + +#### MFRC630.format_block(block, length) + +Prints `block` with `length`. + +#### MFRC630.mfrc630_format_block(data, len) + +Converts `data` to hexadecimal format. + +* `data` The array to be formatted +* `len` The number of bytes to format + +#### MFRC630.mfrc630_print_block(data, len) + +Prints the bytes in `data` array in hexadecimal format, separated by spaces using the `mfrc630_format_block` method. + +* `data` The array to be printed +* `len` The number of bytes to print + +## Constants diff --git a/content/firmwareapi/pycom/expansionboards/MPL3115A2.md b/content/firmwareapi/pycom/expansionboards/MPL3115A2.md new file mode 100644 index 00000000..3435716f --- /dev/null +++ b/content/firmwareapi/pycom/expansionboards/MPL3115A2.md @@ -0,0 +1,29 @@ +--- +Title: "Pressure and Altitude sensor" +--- + +## Constructors + +### class MPL3115A2(pycoproc = None, sda = 'P22', scl = 'P21', mode = MPL3115A2.PRESSURE) + +Creates a MPL3115A2 object. Constructor must be passed a Pycoproc or I2C object to successfully construct. + +## Methods + +### MPL3115A2.pressure() + +Read the atmospheric pressure of the sensor. Returns a float with the pressure in Pascal. + +### MPL3115A2.altitude() + +Read the altitude of the sensor. Returns a float with the altitude in meter. + +### MPL3115A2.temperature() + +Read the temperature of the sensor. Returns a float with the temperature in degrees Celcius. + +## Constants + +The following constants may be passed into the constructor. + +* mode: `PRESSURE`, `ALTITUDE` \ No newline at end of file diff --git a/content/firmwareapi/pycom/expansionboards/SI7006A20.md b/content/firmwareapi/pycom/expansionboards/SI7006A20.md new file mode 100644 index 00000000..6bfd5f64 --- /dev/null +++ b/content/firmwareapi/pycom/expansionboards/SI7006A20.md @@ -0,0 +1,25 @@ +--- +Title: "Humidity and Temperature Sensor" +--- + +The Humidity and Temperature sensor provides values of relative humidity and external temperature. + +## Constructors + +### class SI7006A20(pycoproc = None, sda = 'P22', scl = 'P21') + +Creates a SI7006A20 object. Constructor must be passed a Pycoproc or I2C object to successfully construct. + +## Methods + +### SI7006A20.humidity() + +Read the relative humidity of the sensor. Returns a float with the percentage relative humidity. + +### SI7006A20.temperature() + +Read the external temperature of the sensor. Returns a float with the temperature in degrees Celcius. + +### SI7006A20.dew_point() + +Calculates the dew point temperature for the current temperature and humidity measurement. \ No newline at end of file diff --git a/content/firmwareapi/pycom/expansionboards/_index.md b/content/firmwareapi/pycom/expansionboards/_index.md index 8829d29f..f31463b1 100644 --- a/content/firmwareapi/pycom/expansionboards/_index.md +++ b/content/firmwareapi/pycom/expansionboards/_index.md @@ -1,49 +1,42 @@ --- -title: "Product info & Datasheets" -aliases: - - firmwareapi/introduction.html - - firmwareapi/introduction.md - - product-info - - chapter/firmwareapi +title: "Shields" --- -As the development for these devices are on going with additional features being added, every week, it is essential to ensure you frequently check for updates on the Pytrack/Pysense/Pyscan. As well as updating the device firmware, it is important to check the [GitHub repository](https://github.com/pycom/pycom-libraries) for the respective library files as they as also being updated, to include additional features/functionality. -{{% hint style="info" %}} -Please note that updated libraries are available for the Pytrack 2.0 X and Pysense 2.0 X in the pytrack-2 and pysense-2 directories on GitHub. -These new libraries will allow you to use the new additional features. -{{% /hint %}} +The API pages in this section explain the additional functionality offered by the following shields: +* Pysense +* Pysense 2.0 X +* Pytrack +* Pytrack 2.0 X +* Pyscan -## Uploading the Libraries to a Device - -These libraries should be uploaded to a device (LoPy, SiPy, WiPy 3.0, etc.) in the same process as a standard MicroPython library. The various `.py` files should be placed into the `/lib` folder on the device. - -Add as many or as few of the libraries that are required. +Note that this functionality is not built into the firmware, and you will need to download additional libraries from our [Github libraries repository](https://github.com/pycom/pycom-libraries/tree/master/shields). -In addition to the Pysense or Pytrack specific libraries, for hardware version 1.x boards you also need to upload the `pycoproc.py` file from the `lib/pycoproc` folder inside the libraries archive. For the Pytrack 2.0 X and Pysense 2.0 X, the pycoproc.py file is included in the pytrack-2 and pysense-2 directories to avoid confusion over which library to use. +The API pages are separated per sensor: +* [Accelerometer](lis2hh12/) (LIS2HH12) +* [Light Sensor](ltr329als01/) (LTR329ALS01) +* [Temperature Sensor](si7005a20/) (SI7006A20) +* [Pressure Sensor](mpl311a2/) (MPL3115A2) +* [RFID / NFC](mfrc630/) (MFRC630) +* [GPS](l76gnss/) (L76GNSS) -For example, if using the Pysense and the user wishes to enable the only Accelerometer and the Light Sensor, they should place the following `.py` files into the device's `/lib` folder: +Next to that, you will need either one of the supporting files needed to operate the shield: +* [Pycoproc](pycoproc/) - used on the first version of the Shields +* [Pycoproc2](pycoproc2/) - used on the second version of the Shields -```text -- pysense.py -- pycoproc.py -- LIS2HH12.py -- LTR329ALS01.py -``` +## Uploading the Libraries to a Device -{{% hint style="info" %}} -The Pytrack and Pysense boards behave the same as the Expansion Board. `Upload`, `Run` and upload code to Pycom modules via the Pymakr Plugin, in exactly the same process. -{{% /hint %}} +Place the applicable Python files for your shield into the `/lib` folder of your project. Do not forget to press `upload project to device` in Pymakr to make sure you are able to use them. -## Importing/Using the Libraries +## Importing and using the libraries Once the libraries are uploaded to the device, they can be used/imported as a typical MicroPython library would be. For example, importing and using the light sensor on the Pysense: ```python -from pysense import Pysense +from pycoproc import Pycoproc from LTR329ALS01 import LTR329ALS01 -py = Pysense() +py = Pycoproc() lt = LTR329ALS01(py) print(lt.light()) diff --git a/content/firmwareapi/pycom/expansionboards/pycoproc.md b/content/firmwareapi/pycom/expansionboards/pycoproc.md new file mode 100644 index 00000000..1233a3b9 --- /dev/null +++ b/content/firmwareapi/pycom/expansionboards/pycoproc.md @@ -0,0 +1,60 @@ +--- +Title: "Pycoproc" +--- + +The `pycoproc.py` file is a supporting python library for the first version of Pysense Pytrack and Pyscan expansionboards. For version 2.0 X, see [pycoproc2](../pycoproc2/) + +## Constructors + +### class Pycoproc(board_type, [i2c=None, sda='P22', scl='P21']) + +Initialise I2C communication with the supervisor MCU, if no i2c object is passed, the `sda` and `scl` pins are used. On the shield, the sensors are connected on these pins. Board type can be: +* `Pycoproc.PYSENSE` +* `Pycoproc.PYTRACK` +* `Pycoproc.PYSCAN` + + +## General functions + +### py.read_fw_version() + +Read the PIC firmware version. Check the [update firmware](/updatefirmware/expansionboard/) if an update is available. + +### py.read_hw_version() + +Read the hardware version. + +### py.read_product_id() + +Read the product ID + +### py.button_pressed() + +Returns `True` if the on-board `MCLR` button is pressed. + +### py.read_battery_voltage() + +Returns the battery voltage + +## Power functions + +### py.setup_sleep(seconds) + +Sets the sleep time in seconds for `py.go_to_sleep(...)`. This method will momentarily release the USB connection, meaning you will have to reconnect the USB in Pymakr after using this method. + +### py.setup_int_wake_up(rising, falling) + +Enables the accelerometer INT pin (PIC - RA5) as a wakeup source, if the [accelerometer interrupt](../lis2hh12/#lis2hh12enable_activity_interruptthreshold-duration-handlernone) is configured. The boolean parameters will indicate rising edge (activity detection) and/or falling edge (inactivity detection) is configured. + +### py.setup_int_pin_wake_up([rising=True]) + +Allow waking up from an interrupt on PIC RC1, or `EXT_IO_0` on the external IO header + +### py.go_to_sleep([gps=True]) + +Puts the board in sleep mode. This sleep mode consumes less power than the `machine.deepsleep()` available from the firmware, as it turns the power to the inserted development module off.This will also disable the power to the sensors, sd card and Pyport, except for the accelerometer. Arguments are: +* `gps`: Keep the GPS (if available) in standby mode while sleeping. This reduces the power consumption, but might extend the time to location fix after wakeup. + +### py.get_sleep_remaining() + +In the event of a sleep session that was awoken by an asynchronous event (Accelerometer, INT pin or Reset button) the approximate sleep remaining interval (expressed in **seconds**) can be found out. The user has to manually use `setup_sleep()` to configure the next sleep interval. \ No newline at end of file diff --git a/content/firmwareapi/pycom/expansionboards/pycoproc2.md b/content/firmwareapi/pycom/expansionboards/pycoproc2.md new file mode 100644 index 00000000..185a32bc --- /dev/null +++ b/content/firmwareapi/pycom/expansionboards/pycoproc2.md @@ -0,0 +1,97 @@ +--- +Title: "Pycoproc2" +--- + +The `pycoproc2.py` file is a supporting python library for the Pysense 2 and Pytrack 2 expansionboards. + +> The latest version of `pycoproc2.py` only works with a v16 or later expansionboard-firmware on the Pytrack 2 / Pysense 2. Check whether you have the correct firmware installed by using the following: +> ```python +> from pycoproc import Pycoproc +> py = Pycoproc() +> print(py.read_fw_version()) +> ``` +> If this returns 15 or lower, please update the [expansionboard firmware](/updatefirmware/expansionboard/) + +## Constructors + +### class Pycoproc(i2c=None, sda='P22', scl='P21') + +Initialise I2C communication with the supervisor MCU, if no i2c object is passed, the `sda` and `scl` pins are used. On a Pysense 2 / Pytrack 2 board, the sensors are connected on these pins. + +## General functions + +### py.read_fw_version() + +Read the PIC firmware version. Check the [update firmware](/updatefirmware/expansionboard/) if an update is available. + +### py.read_hw_version() + +Read the hardware version. + +### py.read_product_id() + +Read the product ID + +### py.button_pressed() + +Returns `True` if the on-board `MCLR` button is pressed. + +### py.read_battery_voltage() + +Returns the battery voltage + +### py.reset_cmd() + +Power cycles the development module. + +## Power functions + +### py.sd_power([enabled=True]) + +This command allows switching the power supply for the SD card: +* `True`: the SD card is enabled +* `False`: the SD card is disabled + +### py.sensor_power([enabled=True]) + +This command allows switching the power supply for the GPS module and any sensors connected through the external Pyport: +* `True`: the power is enabled +* `False`: the power is disabled + +### py.gps_standby([enabled=True]) + +This command allows switching the GPS module into stand-by mode. The GPS module is no longer accessible via I2C in this case: +* `True`: the GPS is put in standby mode +* `False`: the GPS is activated. + +### py.setup_sleep(seconds) + +Sets the sleep time in seconds for `py.go_to_sleep(...)`. This method will momentarily release the USB connection, meaning you will have to reconnect the USB in Pymakr after using this method. + +### py.go_to_sleep([gps=True, pycom_module_off=True, accelerometer_off=True, wake_interrupt=False]) + +Puts the board in sleep mode. This sleep mode consumes less power than the `machine.deepsleep()` available from the firmware, as it turns the power to the inserted development module off.This will also disable the power to the sensors, sd card and Pyport, except for the accelerometer. Arguments are: +* `gps`: Keep the GPS (if available) in standby mode while sleeping. This reduces the power consumption, but might extend the time to location fix after wakeup. +* `pycom_module_off`: Turn off the power to the inserted development module. This dramatically reduces the power consumption, but will not allow for wake on accelerometer interrupt. See the example below on how to achieve that. +* `accelerometer_off`: Turn off the power to the accelerometer. +* `wake_interrupt`: Allow waking up from an interrupt on PIC RC1, or `EXT_IO_0` on the external IO header. + +## Example + +Use the following example to wake up from an accelerometer interrupt: + +```python +import machine +import time +from pycoproc import Pycoproc + +py = Pycoproc() +print("enable pycom module to wake up from accelerometer interrupt") +wake_pins = [Pin('P13', mode=Pin.IN, pull=Pin.PULL_DOWN)] +machine.pin_sleep_wakeup(wake_pins, machine.WAKEUP_ANY_HIGH, True) + +print("put pycoproc to sleep and pycom module to deepsleep") +py.setup_sleep(sleep_time_s) +py.go_to_sleep(pycom_module_off=False, accelerometer_off=False, wake_interrupt=True) +machine.deepsleep(sleep_time_s * 1000) +``` \ No newline at end of file diff --git a/content/firmwareapi/pycom/expansionboards/pyscan.md b/content/firmwareapi/pycom/expansionboards/pyscan.md deleted file mode 100644 index 95268327..00000000 --- a/content/firmwareapi/pycom/expansionboards/pyscan.md +++ /dev/null @@ -1,152 +0,0 @@ ---- -title: "Pyscan" -aliases: - - pytrackpysense/apireference/pyscan.html - - pytrackpysense/apireference/pyscan.md - - chapter/pytrackpysense/apireference/pyscan ---- - -This chapter describes the various libraries which are designed for the Pyscan board. This includes details about the various methods and classes available for each of the Pyscan's sensors. - ->Note: follow the guide [here](/firmwareapi/pycom/expansionboards/) to be able to use the functions below - -## 3-Axis Accelerometer (LIS2HH12) - -Pysense has a 3-Axis Accelerometer that provides outputs for acceleration as well as roll, pitch and yaw. - -### Constructors - -#### class LIS2HH12(pysense = None, sda = 'P22', scl = 'P21') - -Creates a `LIS2HH12` object, that will return values for acceleration, roll, pitch and yaw. Constructor must be passed a Pysense or I2C object to successfully construct. - -### Methods - -#### LIS2HH12.acceleration() - -Read the acceleration from the `LIS2HH12`. Returns a **tuple** with the 3 values of acceleration (G). - -#### LIS2HH12.roll() - -Read the current roll from the `LIS2HH12`. Returns a **float** in degrees in the range -180 to 180. - -#### LIS2HH12.pitch() - -Read the current pitch from the `LIS2HH12`. Returns a **float** in degrees in the range -90 to 90. Once the board tilts beyond this range the values will repeat. This is due to a lack of yaw measurement, making it not possible to know the exact orientation of the board. - -## Digital Ambient Light Sensor (LTR-329ALS-01) - -Pysense has a dual light sensor that provides outputs for external light levels in lux. See the datasheet for more information about the wavelengths of the two sensors. - -### Constructors - -#### class LTR329ALS01(pysense = None, sda = 'P22', scl = 'P21', gain = ALS\_GAIN\_1X, integration = ALS\_INT\_100, rate = ALS\_RATE\_500) - -Creates a `LTR329ALS01` object, that will return values for light in lux. Constructor must be passed a Pysense or I2C object to successfully construct. - -### Methods - -#### LTR329ALS01.light() - -Read the light levels of both `LTR329ALS01` sensors. Returns a **tuple** with two values for light levels in lux. - -### Arguments - -The following arguments may be passed into the constructor. - -* gain: `ALS_GAIN_1X`,`ALS_GAIN_2X`, `ALS_GAIN_4X`, `ALS_GAIN_8X`, `ALS_GAIN_48X`, `ALS_GAIN_96X` -* integration: `ALS_INT_50`, `ALS_INT_100`, `ALS_INT_150`, `ALS_INT_200`, `ALS_INT_250`, `ALS_INT_300`, `ALS_INT_350`, `ALS_INT_400` -* rate: `ALS_RATE_50`, `ALS_RATE_100`, `ALS_RATE_200`, `ALS_RATE_500`, `ALS_RATE_1000`, `ALS_RATE_2000` - -## Pyscan NFC library (MFRC6300) - -### Constructors - -#### class MFRC630(pyscan=None, sda='P22', scl='P21', timeout=None, debug=False) - -Creates a `MFRC630` object. Constructor must be passed a Pyscan or I2C object to successfully construct. - -### Methods - -#### MFRC630.mfrc630\_cmd\_init() - -Initialise the `MFRC630` with some settings - -#### MFRC630.mfrc630\_cmd\_reset() - -Reset the device. Stops the currently active command and resets device. - -#### MFRC630.mfrc630\_cmd\_idle() - -Set the device into idle mode. Stops the currently active command and return to idle mode. - -#### MFRC630.mfrc630\_cmd\_load\_key(key) - -Loads the provided key into the key buffer. - -* `key` Array which holds the MIFARE key, **it is always 6 bytes long** - -#### MFRC630.mfrc630\_MF\_read\_block(block\_address, dest) - -Reads a block of memory from an authenticated card. Try to read a block of memory from the card with the appropriate timeouts and error checking. - -* `block_address` The block to read -* `dest` The array in which to write the 16 bytes read from the card - -Returns `0` for failure, otherwise the number of bytes received. - -#### MFRC630.mfrc630\_MF\_auth(uid, key\_type, block) - -Perform a MIFARE authentication procedure. This function is a higher-level wrapper around the MF authenticate command. The result of the authentication is checked to identify whether it appears to have succeeded. The key must be loaded into the key buffer with `MFRC630.mfrc630_cmd_load_key(key)`. - -Once authenticated, the authentication MUST be stopped manually by calling the `mfrc630_MF_deauth()` function or otherwise disabling the `Crypto1 ON` bit in the status register. - -* `key_type` The MIFARE key A or B (`MFRC630_MF_AUTH_KEY_A` or `MFRC630_MF_AUTH_KEY_B`) to use -* `block` The block to authenticate -* `uid` The authentication procedure required the first four bytes of the card's UID to authenticate - -Returns `0` in case of failure, nonzero in case of success. - -#### MFRC630.mfrc630\_MF\_deauth() - -Disables MIFARE authentication. Disable the `Crypto1` bit from the status register to disable encryption. - -#### MFRC630.mfrc630\_iso14443a\_WUPA\_REQA(instruction) - -Send `WUPA` and `REQA`. Returns the response byte, the answer to request `A` byte (`ATQA`), or `0` in case of no answer. - -* instruction: `MFRC630_ISO14443_CMD_WUPA`, `MFRC630_ISO14443_CMD_REQA` - -#### MFRC630.mfrc630\_iso14443a\_select(uid) - -Performs the `SELECT` procedure to discover a card's UID. This performs the `SELECT` procedure as explained in _ISO14443A_, this determines the UID of the card, if multiple cards are present, a collision will occur, which is handled according to the norm. - -* `uid`: The UID of the card will be stored into this array. - -Returns the length of the UID in bytes (`4, 7, 10`), or `0` in case of failure. - -#### MFRC630.print\_debug(msg) - -Prints debug statements if `DEBUG` is enabled. - -#### MFRC630.format\_block(block, length) - -Prints `block` with `length`. - -#### MFRC630.mfrc630\_format\_block(data, len) - -Converts `data` to hexadecimal format. - -* `data` The array to be formatted -* `len` The number of bytes to format - -#### MFRC630.mfrc630\_print\_block(data, len) - -Prints the bytes in `data` array in hexadecimal format, separated by spaces using the `mfrc630_format_block` method. - -* `data` The array to be printed -* `len` The number of bytes to print - -{{% hint style="info" %}} -Please note that more functionality is being added weekly to these libraries. If a required feature is not available, feel free to contribute with a pull request at the [Libraries GitHub repository](https://github.com/pycom/pycom-libraries) -{{% /hint %}} diff --git a/content/firmwareapi/pycom/expansionboards/pysense.md b/content/firmwareapi/pycom/expansionboards/pysense.md deleted file mode 100644 index eafc2328..00000000 --- a/content/firmwareapi/pycom/expansionboards/pysense.md +++ /dev/null @@ -1,114 +0,0 @@ ---- -title: "Pysense" -aliases: - - pytrackpysense/apireference/pysense.html - - pytrackpysense/apireference/pysense.md - - chapter/pytrackpysense/apireference/pysense ---- - -This chapter describes the various libraries which are designed for the Pysense board. This includes details about the various methods and classes available for each of the Pysense's sensors. - ->Note: follow the guide [here](/firmwareapi/pycom/expansionboards/) to be able to use the functions below - -## 3-Axis Accelerometer (LIS2HH12) - -Pysense has a 3-Axis Accelerometer that provides outputs for acceleration as well as roll, pitch and yaw. - -### Constructors - -#### class LIS2HH12(pysense = None, sda = 'P22', scl = 'P21') - -Creates a `LIS2HH12` object, that will return values for acceleration, roll, pitch and yaw. Constructor must be passed a Pysense or I2C object to successfully construct. - -### Methods - -#### LIS2HH12.acceleration() - -Read the acceleration from the `LIS2HH12`. Returns a **tuple** with the 3 values of acceleration (G). - -#### LIS2HH12.roll() - -Read the current roll from the `LIS2HH12`. Returns a **float** in degrees in the range -180 to 180. - -#### LIS2HH12.pitch() - -Read the current pitch from the `LIS2HH12`. Returns a **float** in degrees in the range -90 to 90. Once the board tilts beyond this range the values will repeat. This is due to a lack of yaw measurement, making it not possible to know the exact orientation of the board. - -## Digital Ambient Light Sensor (LTR-329ALS-01) - -Pysense has a dual light sensor that provides outputs for external light levels in lux. See the datasheet for more information about the wavelengths of the two sensors. - -### Constructors - -#### class LTR329ALS01(pysense = None, sda = 'P22', scl = 'P21', gain = ALS\_GAIN\_1X, integration = ALS\_INT\_100, rate = ALS\_RATE\_500) - -Creates a `LTR329ALS01` object, that will return values for light in lux. Constructor must be passed a Pysense or I2C object to successfully construct. - -### Methods - -#### LTR329ALS01.light() - -Read the light levels of both `LTR329ALS01` sensors. Returns a **tuple** with two values for light levels in lux. - -### Arguments - -The following arguments may be passed into the constructor. - -* gain: `ALS_GAIN_1X`,`ALS_GAIN_2X`, `ALS_GAIN_4X`, `ALS_GAIN_8X`, `ALS_GAIN_48X`, `ALS_GAIN_96X` -* integration: `ALS_INT_50`, `ALS_INT_100`, `ALS_INT_150`, `ALS_INT_200`, `ALS_INT_250`, `ALS_INT_300`, `ALS_INT_350`, `ALS_INT_400` -* rate: `ALS_RATE_50`, `ALS_RATE_100`, `ALS_RATE_200`, `ALS_RATE_500`, `ALS_RATE_1000`, `ALS_RATE_2000` - -## Humidity and Temperature Sensor (SI7006A20) - -Pysense has a Humidity and Temperature sensor that provides values of relative humidity and external temperature. - -### Constructors - -#### class SI7006A20(pysense = None, sda = 'P22', scl = 'P21') - -Creates a `SI7006A20` object, that will return values for humidity (%) and temperature ('C). Constructor must be passed a Pysense or I2C object to successfully construct. - -### Methods - -#### SI7006A20.humidity() - -Read the relative humidity of the `SI7006A20`. Returns a **float** with the percentage relative humidity. - -#### SI7006A20.temperature() - -Read the external temperature of the `SI7006A20`. Returns a **float** with the temperature. - -## Barometric Pressure Sensor with Altimeter (MPL3115A2) - -Pysense has a Barometric Pressure sensor that provides readings for pressure, altitude as well as an additional temperature sensor. - -### Constructors - -#### class MPL3115A2(pysense = None, sda = 'P22', scl = 'P21', mode = PRESSURE) - -Creates a `MPL3115A2` object, that will return values for pressure (Pa), altitude (m) and temperature ('C). Constructor must be passed a Pysense or I2C object to successfully construct. - -### Methods - -#### MPL3115A2.pressure() - -Read the atmospheric pressure of the `MPL3115A2`. Returns a **float** with the pressure in (Pa). - -#### MPL3115A2.altitude() - -Read the altitude of the `MPL3115A2`. Returns a **float** with the altitude in (m). - -#### MPL3115A2.temperature() - -Read the temperature of the `MPL3115A2`. Returns a **float** with the temperature in ('C). - -### Arguments - -The following arguments may be passed into the constructor. - -* mode: `PRESSURE`, `ALTITUDE` - -{{% hint style="info" %}} -Please note that more functionality is being added weekly to these libraries. If a required feature is not available, feel free to contribute with a pull request at the [Libraries GitHub repository](https://github.com/pycom/pycom-libraries) -{{% /hint %}} - diff --git a/content/firmwareapi/pycom/expansionboards/pysense2.md b/content/firmwareapi/pycom/expansionboards/pysense2.md deleted file mode 100644 index 56d3a55b..00000000 --- a/content/firmwareapi/pycom/expansionboards/pysense2.md +++ /dev/null @@ -1,130 +0,0 @@ ---- -title: "Pysense 2.0 X" -aliases: - - pytrackpysense/apireference/pysense2.html - - pytrackpysense/apireference/pysense2.md - - chapter/pytrackpysense/apireference/pysense2 ---- - -This chapter describes the various libraries which are designed for the Pysense board. This includes details about the various methods and classes available for each of the Pysense's sensors. - ->Note: follow the guide [here](/firmwareapi/pycom/expansionboards/) to be able to use the functions below - -## 3-Axis Accelerometer (LIS2HH12) - -Pysense has a 3-Axis Accelerometer that provides outputs for acceleration as well as roll, pitch and yaw. - -### Constructors - -#### class LIS2HH12(pysense = None, sda = 'P22', scl = 'P21') - -Creates a `LIS2HH12` object, that will return values for acceleration, roll, pitch and yaw. Constructor must be passed a Pysense or I2C object to successfully construct. - -### Methods - -#### LIS2HH12.acceleration() - -Read the acceleration from the `LIS2HH12`. Returns a **tuple** with the 3 values of acceleration (G). - -#### LIS2HH12.roll() - -Read the current roll from the `LIS2HH12`. Returns a **float** in degrees in the range -180 to 180. - -#### LIS2HH12.pitch() - -Read the current pitch from the `LIS2HH12`. Returns a **float** in degrees in the range -90 to 90. Once the board tilts beyond this range the values will repeat. This is due to a lack of yaw measurement, making it not possible to know the exact orientation of the board. - -## Digital Ambient Light Sensor (LTR-329ALS-01) - -Pysense has a dual light sensor that provides outputs for external light levels in lux. See the datasheet for more information about the wavelengths of the two sensors. - -### Constructors - -#### class LTR329ALS01(pysense = None, sda = 'P22', scl = 'P21', gain = ALS\_GAIN\_1X, integration = ALS\_INT\_100, rate = ALS\_RATE\_500) - -Creates a `LTR329ALS01` object, that will return values for light in lux. Constructor must be passed a Pysense or I2C object to successfully construct. - -### Methods - -#### LTR329ALS01.light() - -Read the light levels of both `LTR329ALS01` sensors. Returns a **tuple** with two values for light levels in lux. - -### Arguments - -The following arguments may be passed into the constructor. - -* gain: `ALS_GAIN_1X`,`ALS_GAIN_2X`, `ALS_GAIN_4X`, `ALS_GAIN_8X`, `ALS_GAIN_48X`, `ALS_GAIN_96X` -* integration: `ALS_INT_50`, `ALS_INT_100`, `ALS_INT_150`, `ALS_INT_200`, `ALS_INT_250`, `ALS_INT_300`, `ALS_INT_350`, `ALS_INT_400` -* rate: `ALS_RATE_50`, `ALS_RATE_100`, `ALS_RATE_200`, `ALS_RATE_500`, `ALS_RATE_1000`, `ALS_RATE_2000` - -## Humidity and Temperature Sensor (SI7006A20) - -Pysense has a Humidity and Temperature sensor that provides values of relative humidity and external temperature. - -### Constructors - -#### class SI7006A20(pysense = None, sda = 'P22', scl = 'P21') - -Creates a `SI7006A20` object, that will return values for humidity (%) and temperature ('C). Constructor must be passed a Pysense or I2C object to successfully construct. - -### Methods - -#### SI7006A20.humidity() - -Read the relative humidity of the `SI7006A20`. Returns a **float** with the percentage relative humidity. - -#### SI7006A20.temperature() - -Read the external temperature of the `SI7006A20`. Returns a **float** with the temperature. - -## Barometric Pressure Sensor with Altimeter (MPL3115A2) - -Pysense has a Barometric Pressure sensor that provides readings for pressure, altitude as well as an additional temperature sensor. - -### Constructors - -#### class MPL3115A2(pysense = None, sda = 'P22', scl = 'P21', mode = PRESSURE) - -Creates a `MPL3115A2` object, that will return values for pressure (Pa), altitude (m) and temperature ('C). Constructor must be passed a Pysense or I2C object to successfully construct. - -### Methods - -#### MPL3115A2.pressure() - -Read the atmospheric pressure of the `MPL3115A2`. Returns a **float** with the pressure in (Pa). - -#### MPL3115A2.altitude() - -Read the altitude of the `MPL3115A2`. Returns a **float** with the altitude in (m). - -#### MPL3115A2.temperature() - -Read the temperature of the `MPL3115A2`. Returns a **float** with the temperature in ('C). - -### Arguments - -The following arguments may be passed into the constructor. - -* mode: `PRESSURE`, `ALTITUDE` - -### Constructors - -#### class Pytrack(i2c=None, sda='P22', scl='P21') - -Initialise I2C communication with the supervisor MCU - -### Methods - -#### Pysense.sd_power(enabled=True) - -This command allows switching the power supply for the SD card (VCC + PullUP resistors) - -#### Pysense.sensor_power(enabled=True) - -This command allows switching the power supply for the onboard sensors and any sensors connected through the external 6-pin connector - - -{{% hint style="info" %}} -Please note that more functionality is being added weekly to these libraries. If a required feature is not available, feel free to contribute with a pull request at the [Libraries GitHub repository](https://github.com/pycom/pycom-libraries) -{{% /hint %}} diff --git a/content/firmwareapi/pycom/expansionboards/pytrack.md b/content/firmwareapi/pycom/expansionboards/pytrack.md deleted file mode 100644 index 1a1380bb..00000000 --- a/content/firmwareapi/pycom/expansionboards/pytrack.md +++ /dev/null @@ -1,56 +0,0 @@ ---- -title: "Pytrack" -aliases: - - pytrackpysense/apireference/pytrack.html - - pytrackpysense/apireference/pytrack.md - - chapter/pytrackpysense/apireference/pytrack ---- - -This chapter describes the various libraries which are designed for the Pytrack board. This includes details about the various methods and classes available for each of the Pytrack's sensors. - ->Note: follow the guide [here](/firmwareapi/pycom/expansionboards/) to be able to use the functions below - -## 3-Axis Accelerometer (LIS2HH12) - -Pytrack has a 3-Axis Accelerometer that provides outputs for acceleration as well as roll, pitch and yaw. - -### Constructors - -#### class LIS2HH12(pytrack = None, sda = 'P22', scl = 'P21') - -Creates a `LIS2HH12` object, that will return values for acceleration, roll, pitch and yaw. Constructor must be passed a Pytrack or I2C object to successfully construct. - -### Methods - -#### LIS2HH12.acceleration() - -Read the acceleration from the `LIS2HH12`. Returns a **tuple** with the 3 values of acceleration (G). - -#### LIS2HH12.roll() - -Read the current roll from the `LIS2HH12`. Returns a **float** in degrees in the range -180 to 180. - -#### LIS2HH12.pitch() - -Read the current pitch from the `LIS2HH12`. Returns a **float** in degrees in the range -90 to 90. Once the board tilts beyond this range the values will repeat. This is due to a lack of yaw measurement, making it not possible to know the exact orientation of the board. - -## GPS with GLONASS (Quectel L76-L GNSS) - -Pytrack has a GPS (with GLONASS) that provides outputs longitude/latitude, speed and other information about the Pytrack's location. - -### Constructors - -#### class L76GNSS(pytrack = None, sda = 'P22', scl = 'P21', timeout = None) - -Creates a `L76GNSS` object, that will return values for longitude and latitude. Constructor must be passed a Pytrack or I2C object to successfully construct. Set the `timeout` to a time period (in seconds) for the GPS to search for a lock. If a lock is not found by the time the `timeout` has expired, the `coordinates` method will return `(None, None)`. - -### Methods - -#### L76GNSS.coordinates(debug = False) - -Read the longitude and latitude from the `L76GNSS`. Returns a **tuple** with the longitude and latitude. With `debug` set to `True` the output from the GPS is verbose. - -{{% hint style="info" %}} -Please note that more functionality is being added weekly to these libraries. If a required feature is not available, feel free to contribute with a pull request at the [Libraries GitHub repository](https://github.com/pycom/pycom-libraries) -{{% /hint %}} - diff --git a/content/gettingstarted/_index.md b/content/gettingstarted/_index.md index 20d278de..b1ad6516 100644 --- a/content/gettingstarted/_index.md +++ b/content/gettingstarted/_index.md @@ -16,7 +16,7 @@ In the following guide, we will explain the basic process to get started using y 1. [Setting up the hardware](#step-1-setting-up-the-hardware) 2. [Setting up your computer](#step-2-setting-up-your-computer) 3. [Programming the module](#step-3-programming-your-module) -4. [Using your Expansionboard](#step-4-using-your-expansionboard) +4. [Using your Shield](#step-4-using-your-shield) @@ -127,7 +127,7 @@ If you need to remove files from your device you can use the following commands: >>> os.fsformat('/flash') ``` -## Step 4: Using your expansionboard +## Step 4: Using your shield From here on, you can continue to use the additional features of your expansionboard: >Note The Expansionboard requires no additional libraries and all functions work out of the box! diff --git a/content/tutorials/expansionboards/_index.md b/content/tutorials/expansionboards/_index.md index 2fb20d4d..a3adad2a 100644 --- a/content/tutorials/expansionboards/_index.md +++ b/content/tutorials/expansionboards/_index.md @@ -1,5 +1,5 @@ --- -title: "Overview" +title: "Shields" aliases: - tutorials/expansionboards/introduction.html - tutorials/expansionboards/introduction.md diff --git a/content/tutorials/expansionboards/pysense2.md b/content/tutorials/expansionboards/pysense2.md index 22a785cd..b6a66c85 100644 --- a/content/tutorials/expansionboards/pysense2.md +++ b/content/tutorials/expansionboards/pysense2.md @@ -7,7 +7,7 @@ aliases: --- The Pysense 2.0 X has an external header that allows you to attach all kinds of sensors. ## All sensors ->Note: You can find this example in the [GitHub repository](https://github.com/pycom/pycom-libraries/tree/master/pysense-2). Over there, you can also find the relevant libraries. +>Note: You can find this example in the [GitHub repository](https://github.com/pycom/pycom-libraries/). Over there, you can also find the relevant libraries. ```python #!/usr/bin/env python # diff --git a/content/tutorials/expansionboards/pytrack.md b/content/tutorials/expansionboards/pytrack.md index 56b8ae7f..eaa8a7b9 100644 --- a/content/tutorials/expansionboards/pytrack.md +++ b/content/tutorials/expansionboards/pytrack.md @@ -7,7 +7,7 @@ aliases: --- Both the Pysense and Pytrack use the same accelerometer. Please see the [Pysense Examples](../pysense) to see how to use the accelerometer. ->Note: You can find this example in the [GitHub repository](https://github.com/pycom/pycom-libraries/tree/master/pytrack). Over there, you can also find the relevant libraries. +>Note: You can find this example in the [GitHub repository](https://github.com/pycom/pycom-libraries/). Over there, you can also find the relevant libraries. ## GPS Example diff --git a/content/tutorials/expansionboards/pytrack2.md b/content/tutorials/expansionboards/pytrack2.md index c17b9c0d..32fd2831 100644 --- a/content/tutorials/expansionboards/pytrack2.md +++ b/content/tutorials/expansionboards/pytrack2.md @@ -7,7 +7,7 @@ aliases: --- The Pytrack 2.0 X has an external header that allows you to attach all kinds of sensors. ## All sensors ->Note: You can find this example in the [GitHub repository](https://github.com/pycom/pycom-libraries/tree/master/pytrack-2). Over there, you can also find the relevant libraries. +>Note: You can find this example in the [GitHub repository](https://github.com/pycom/pycom-libraries/). Over there, you can also find the relevant libraries. ```python #!/usr/bin/env python #