Merge branch 'publish' into documentation_fixes
1
.gitignore
vendored
@@ -14,3 +14,4 @@ static/gitbook/.DS_Store
|
||||
static/gitbook/assets/.DS_Store
|
||||
static/gitbook/assets/pybytes/.DS_Store
|
||||
scripts/githubToken.json
|
||||
.project
|
||||
|
||||
38
config.toml
@@ -310,11 +310,25 @@ theme = "doc-theme"
|
||||
parent = "pytrackpysense"
|
||||
weight = 20
|
||||
|
||||
[[menu.main]]
|
||||
name = "Pytrack 2.0 X"
|
||||
url = "/pytrackpysense/apireference/pytrack2/"
|
||||
identifier = "pytrackpysense@apireference@pytrack2"
|
||||
parent = "pytrackpysense@apireference"
|
||||
weight = 10
|
||||
|
||||
[[menu.main]]
|
||||
name = "Pytrack"
|
||||
url = "/pytrackpysense/apireference/pytrack/"
|
||||
identifier = "pytrackpysense@apireference@pytrack"
|
||||
parent = "pytrackpysense@apireference"
|
||||
weight = 20
|
||||
|
||||
[[menu.main]]
|
||||
name = "Pysense 2.0 X"
|
||||
url = "/pytrackpysense/apireference/pysense2/"
|
||||
identifier = "pytrackpysense@apireference@pysense2"
|
||||
parent = "pytrackpysense@apireference"
|
||||
weight = 10
|
||||
|
||||
[[menu.main]]
|
||||
@@ -361,10 +375,10 @@ theme = "doc-theme"
|
||||
|
||||
[[menu.main]]
|
||||
name = "PyGate"
|
||||
url = "/tutorials/all/PyGate/"
|
||||
identifier = "tutorials@all@PyGate"
|
||||
parent = "tutorials@all"
|
||||
weight = 10
|
||||
url = "/tutorials/PyGate/"
|
||||
identifier = "tutorials@PyGate"
|
||||
parent = "tutorials"
|
||||
weight = 1
|
||||
|
||||
[[menu.main]]
|
||||
name = "PoE"
|
||||
@@ -1158,6 +1172,20 @@ theme = "doc-theme"
|
||||
url = "/datasheets/boards/expansion3/"
|
||||
identifier = "datasheets@boards@expansion3"
|
||||
parent = "datasheets@boards"
|
||||
weight = 20
|
||||
|
||||
[[menu.main]]
|
||||
name = "Pytrack 2.0X"
|
||||
url = "/datasheets/boards/pytrack2/"
|
||||
identifier = "datasheets@boards@pytrack2"
|
||||
parent = "datasheets@boards"
|
||||
weight = 10
|
||||
|
||||
[[menu.main]]
|
||||
name = "Pysense 2.0X"
|
||||
url = "/datasheets/boards/pysense2/"
|
||||
identifier = "datasheets@boards@pysense2"
|
||||
parent = "datasheets@boards"
|
||||
weight = 10
|
||||
|
||||
[[menu.main]]
|
||||
@@ -1165,7 +1193,7 @@ theme = "doc-theme"
|
||||
url = "/datasheets/boards/pytrack/"
|
||||
identifier = "datasheets@boards@pytrack"
|
||||
parent = "datasheets@boards"
|
||||
weight = 20
|
||||
weight = 30
|
||||
|
||||
[[menu.main]]
|
||||
name = "Pysense"
|
||||
|
||||
@@ -4,7 +4,6 @@ aliases:
|
||||
- advance/downgrade.html
|
||||
- advance/downgrade.md
|
||||
- chapter/advance/downgrade
|
||||
|
||||
---
|
||||
|
||||
The firmware upgrade tool usually updates your device to the latest available firmware version. If you require to downgrade your device to a previous firmware there are two methods to achieve this.
|
||||
|
||||
37
content/datasheets/boards/pysense2.md
Normal file
@@ -0,0 +1,37 @@
|
||||
---
|
||||
title: "Pysense 2.0X"
|
||||
aliases:
|
||||
- datasheets/boards/pysense2.html
|
||||
- datasheets/boards/pysense2.md
|
||||
- product-info/boards/pysense2
|
||||
- chapter/datasheets/boards/pysense2
|
||||
---
|
||||
|
||||

|
||||
|
||||
## Datasheet
|
||||
|
||||
The datasheet of the Pysense 2.0X is available as a PDF File.
|
||||
|
||||
<a href="/gitbook/assets/PySense2X_specsheet.pdf" target="_blank"> Pysense 2.0 X Datasheet </a>
|
||||
|
||||
## Pinout
|
||||
|
||||
The pinout of the Pysense is available as a PDF File
|
||||
|
||||
<a href="/gitbook/assets/pysense2-pinout.pdf" target="_blank"> Pysense Pinout </a>
|
||||
|
||||

|
||||
|
||||
## Battery Charger
|
||||
|
||||
The board features a single cell Li-Ion/Li-Po charger. When the board is being powered via the micro USB connector, it will charge the battery (if connected).
|
||||
|
||||
## Mechanical Dimensions
|
||||
|
||||

|
||||
|
||||
|
||||
## 3D model for case design
|
||||
|
||||
* Please see the <a href="/gitbook/assets/pysense_v2.0X.step" target="_blank"> 3D model </a> (step format)
|
||||
38
content/datasheets/boards/pytrack2.md
Normal file
@@ -0,0 +1,38 @@
|
||||
---
|
||||
title: "Pytrack 2.0X"
|
||||
aliases:
|
||||
- datasheets/boards/pytrack2.html
|
||||
- datasheets/boards/pytrack2.md
|
||||
- product-info/boards/pytrack2
|
||||
- chapter/datasheets/boards/pytrack2
|
||||
---
|
||||
|
||||

|
||||
|
||||
## Datasheet
|
||||
|
||||
The datasheet of the Pytrack is available as a PDF File.
|
||||
|
||||
<a href="/gitbook/assets/PyTrack2X_specsheet.pdf" target="_blank"> Pytrack 2.0X Datasheet </a>
|
||||
|
||||
## Pinout
|
||||
|
||||
The pinout of the Pytrack is available as a PDF File
|
||||
|
||||
<a href="/gitbook/assets/pytrack2-pinout.pdf" target="_blank"> Pytrack Pinout </a>
|
||||
|
||||

|
||||
|
||||
## Battery Charger
|
||||
|
||||
The board features a single cell Li-Ion/Li-Po charger. When the board is being powered via the micro USB connector, it will charge the battery (if connected).
|
||||
|
||||
|
||||
|
||||
## Mechanical Dimensions
|
||||
|
||||

|
||||
|
||||
## 3D model for case design
|
||||
|
||||
* Please see the <a href="/gitbook/assets/pytrack_v2.0X.step" target="_blank"> 3D model </a> (step format)
|
||||
@@ -10,9 +10,9 @@ This module provides access to Transport Layer Security (often known as "Secure
|
||||
|
||||
## Methods
|
||||
|
||||
#### ssl.wrap\_socket(sock, keyfile=None, certfile=None, server\_side=False, cert\_reqs=CERT\_NONE, ca\_certs=None\, timeout=10sec)
|
||||
#### ssl.wrap\_socket(sock, keyfile=None, certfile=None, server\_side=False, cert\_reqs=CERT\_NONE, ssl\_version=0, ca\_certs=None, server\_hostname=None, timeout=10sec)
|
||||
|
||||
Takes an instance `sock` of `socket.socket`, and returns an instance of ssl.SSLSocket, a subtype of `socket.socket`, which wraps the underlying socket in an SSL context. Example:
|
||||
Takes an instance `sock` of `socket.socket`, and returns an instance of `ssl.SSLSocket`, a subtype of `socket.socket`, which wraps the underlying socket in an SSL context. Example:
|
||||
|
||||
```python
|
||||
|
||||
|
||||
@@ -15,7 +15,6 @@ AES is implemented using the ESP32 hardware module.
|
||||
## Quick Usage Example
|
||||
|
||||
```python
|
||||
|
||||
from crypto import AES
|
||||
import crypto
|
||||
key = b'notsuchsecretkey' # 128 bit (16 bytes) key
|
||||
|
||||
@@ -46,6 +46,17 @@ Returns CPU frequency in hertz.
|
||||
|
||||
Gates the clock to the CPU, useful to reduce power consumption at any time during short or long periods. Peripherals continue working and execution resumes as soon as any interrupt is triggered (on many ports this includes system timer interrupt occurring at regular intervals on the order of millisecond).
|
||||
|
||||
#### machine.sleep(\[time\_ms\], resume\_wifi\_ble)
|
||||
|
||||
Sets the device in to light sleep mode , where in this mode digital peripherals, most of the RAM, and CPUs are clock-gated, and supply voltage is reduced. Upon exit from light sleep, peripherals and CPUs resume operation, their internal state is preserved.
|
||||
|
||||
* `time_ms` is the time in milliseconds that the device should wakeup after, if no time is given the device will sleep until the next reset cycle unless another wakeup source is configured.
|
||||
* `resume_wifi_ble` is a boolean value that enables or disable restoring after wakeup any WiFi or BLE connection that was interrupted by light sleep.
|
||||
* `True` Enable WiFi/BLE connections restoration
|
||||
* `False` Disable Wifi/BLE connections restoration, default option is Disabled
|
||||
|
||||
_Note: in light sleep mode LoRa/Lte modems are stopped and have to be re-initialized after wakeup._
|
||||
|
||||
#### machine.deepsleep(\[time\_ms\])
|
||||
|
||||
Stops the CPU and all peripherals, including the networking interfaces (except for LTE). Execution is resumed from the main script, just as with a reset. If a value in milliseconds is given then the device will wake up after that period of time, otherwise it will remain in deep sleep until the reset button is pressed.
|
||||
|
||||
@@ -85,6 +85,24 @@ Returns `True` if the last `ntp_sync` has been completed, `False` otherwise:
|
||||
rtc.synced()
|
||||
```
|
||||
|
||||
#### rtc.memory(\[data\])
|
||||
|
||||
Reads RTC memory contents or write data in passed Buffer in to RTC memory
|
||||
|
||||
Example:
|
||||
|
||||
```python
|
||||
rtc = RTC()
|
||||
rtc.memory(b'10101010') # writes data in RTC memory
|
||||
rtc.memory()
|
||||
```
|
||||
|
||||
Output:
|
||||
|
||||
```python
|
||||
b'10101010'
|
||||
```
|
||||
|
||||
## Constants
|
||||
|
||||
* Clock source: `RTC.INTERNAL_RC`, `RTC.XTAL_32KHZ`
|
||||
|
||||
@@ -72,7 +72,6 @@ Get the elapsed time in microseconds.
|
||||
Example:
|
||||
|
||||
```python
|
||||
|
||||
from machine import Timer
|
||||
import time
|
||||
|
||||
@@ -111,7 +110,6 @@ Disables the alarm.
|
||||
Example:
|
||||
|
||||
```python
|
||||
|
||||
from machine import Timer
|
||||
|
||||
class Clock:
|
||||
|
||||
@@ -83,7 +83,7 @@ On the GPy/FiPy UART2 is unavailable because it is used to communicate with the
|
||||
|
||||
## Methods
|
||||
|
||||
#### uart.init(baudrate=9600, bits=8, parity=None, stop=1, \* , timeout\_chars=2, pins=(TXD, RXD, RTS, CTS))
|
||||
#### uart.init(baudrate=9600, bits=8, parity=None, stop=1, \* , timeout\_chars=2, pins=(TXD, RXD, RTS, CTS), rx\_buffer\_size=512)
|
||||
|
||||
Initialise the UART bus with the given parameters:
|
||||
|
||||
@@ -93,6 +93,7 @@ Initialise the UART bus with the given parameters:
|
||||
* `stop` is the number of stop bits, `1 or 2`.
|
||||
* `timeout_chars` Rx timeout defined in number of characters. The value given here will be multiplied by the time a characters takes to be transmitted at the configured `baudrate`.
|
||||
* `pins` is a 4 or 2 item list indicating the TXD, RXD, RTS and CTS pins (in that order). Any of the pins can be `None` if one wants the UART to operate with limited functionality. If the RTS pin is given the the RX pin must be given as well. The same applies to CTS. When no pins are given, then the default set of TXD (P1) and RXD (P0) pins is taken, and hardware flow control will be disabled. If `pins=None`, no pin assignment will be made.
|
||||
* `rx_buffer_size` is the size of the buffer used for storing the RX packets. By default is is 512 bytes.
|
||||
|
||||
#### uart.deinit()
|
||||
|
||||
|
||||
@@ -47,14 +47,13 @@ GAP allows for devices to take various roles but generic flow works with devices
|
||||
|
||||
## Constructors
|
||||
|
||||
### class network.Bluetooth(id=0, ...)
|
||||
#### class network.Bluetooth(id=0, ...)
|
||||
|
||||
Create a Bluetooth object, and optionally configure it. See init for params of configuration.
|
||||
|
||||
Example:
|
||||
|
||||
```python
|
||||
|
||||
from network import Bluetooth
|
||||
bluetooth = Bluetooth()
|
||||
```
|
||||
@@ -85,7 +84,7 @@ Pin('P12', mode=Pin.OUT)(True)
|
||||
```
|
||||
{{% /hint %}}
|
||||
|
||||
### bluetooth.deinit()
|
||||
#### bluetooth.deinit()
|
||||
|
||||
Disables the Bluetooth radio.
|
||||
|
||||
|
||||
@@ -48,3 +48,25 @@ This method allows to register for notifications on the characteristic.
|
||||
* `handler` is the function that will be executed when the callback is triggered.
|
||||
* `arg` is the argument that gets passed to the callback. If nothing is given, the characteristic object that owns the callback will be used.
|
||||
|
||||
#### characteristic.read\_descriptor(uuid)
|
||||
|
||||
Returns the value of the descriptor specified by the `uuid` parameter. If no descriptor found for the characteristic returns None.
|
||||
|
||||
```python
|
||||
descriptor = char.read_descriptor(0x2900)
|
||||
if(descriptor != None):
|
||||
print("Characteristic Extended Properties: " + str(binascii.hexlify((descriptor))))
|
||||
|
||||
descriptor = char.read_descriptor(0x2901)
|
||||
if(descriptor != None):
|
||||
print("Characteristic User Description: " + str(binascii.hexlify((descriptor))))
|
||||
|
||||
descriptor = char.read_descriptor(0x2902)
|
||||
if(descriptor != None):
|
||||
print("Client Characteristic Configuration: " + str(binascii.hexlify((descriptor))))
|
||||
|
||||
descriptor = char.read_descriptor(0x2904)
|
||||
if(descriptor != None):
|
||||
print("Characteristic Presentation Format: " + str(binascii.hexlify((descriptor))))
|
||||
```
|
||||
|
||||
|
||||
@@ -9,12 +9,11 @@ aliases:
|
||||
Sigfox is a Low Power Wide Area Network protocol that enables remote devices to connect using ultra-narrow band, UNB technology. The protocol is bi-directional, messages can both be sent up to and down from the Sigfox servers.
|
||||
|
||||
{{% hint style="info" %}}
|
||||
When operating in RCZ2 and RCZ4 the module can only send messages on the default macro-channel (this is due to Sigfox network limitations). Therefore, the device needs to reset automatically to the default macro-channel after every 2 transmissions. However, due to FCC duty cycle limitations, there must a minimum of a 20s delay after resetting to the default macro-channel. Our API takes care of this, (and in real life applications you should not be in the need to send Sigfox messages that often), so it will wait for the necessary amount of time to make sure that the duty cycle restrictions are fulfilled.
|
||||
When operating in `RCZ2` and `RCZ4` the module can only send messages on the default macro-channel (this is due to Sigfox network limitations). Therefore, the device needs to reset automatically to the default macro-channel after every 2 transmissions. However, due to FCC duty cycle limitations, there must a minimum of a 20s delay after resetting to the default macro-channel. Our API takes care of this, (and in real life applications you should not be in the need to send Sigfox messages that often), so it will wait for the necessary amount of time to make sure that the duty cycle restrictions are fulfilled.
|
||||
|
||||
This means that if you run a piece of test code like:
|
||||
|
||||
```python
|
||||
|
||||
for i in range(1, 100):
|
||||
# send something
|
||||
s.send('Hello ' + str(i))
|
||||
@@ -28,7 +27,6 @@ This class provides a driver for the Sigfox network processor in the Sigfox enab
|
||||
## Quick Usage Example
|
||||
|
||||
```python
|
||||
|
||||
from network import Sigfox
|
||||
import socket
|
||||
|
||||
@@ -59,7 +57,6 @@ Please ensure that there is an antenna connected to your device before sending/r
|
||||
Create and configure a Sigfox object. See init for params of configuration. Examples:
|
||||
|
||||
```python
|
||||
|
||||
# configure radio for the Sigfox network, using RCZ1 (868 MHz)
|
||||
sigfox = Sigfox(mode=Sigfox.SIGFOX, rcz=Sigfox.RCZ1)
|
||||
|
||||
@@ -68,7 +65,7 @@ sigfox = Sigfox(mode=Sigfox.FSK, frequency=912000000)
|
||||
```
|
||||
|
||||
{{% hint style="info" %}}
|
||||
Sigfox.FSK mode is not supported on LoPy 4 and FiPy.
|
||||
`Sigfox.FSK` mode is not supported on LoPy 4 and FiPy.
|
||||
{{% /hint %}}
|
||||
|
||||
## Methods
|
||||
@@ -107,7 +104,6 @@ Returns a byte object with the 8-Byte bytes object with the Sigfox PAC.
|
||||
To return human-readable values you should import `ubinascii` and convert binary values to hexidecimal representation. For example:
|
||||
|
||||
```python
|
||||
|
||||
print(ubinascii.hexlify(sigfox.mac()))
|
||||
```
|
||||
{{% /hint %}}
|
||||
@@ -121,7 +117,6 @@ Returns a tuple of the form: `(uplink_frequency_hz, downlink_frequency_hz)`
|
||||
Sets or gets the public key flag. When called passing a `True` value the Sigfox public key will be used to encrypt the packets. Calling it without arguments returns the state of the flag.
|
||||
|
||||
```python
|
||||
|
||||
# enable encrypted packets
|
||||
sigfox.public_key(True)
|
||||
|
||||
@@ -145,7 +140,6 @@ sigfox.public_key()
|
||||
Sigfox sockets are created in the following way:
|
||||
|
||||
```python
|
||||
|
||||
import socket
|
||||
s = socket.socket(socket.AF_SIGFOX, socket.SOCK_RAW)
|
||||
```
|
||||
@@ -163,7 +157,6 @@ Use it to close an existing socket.
|
||||
In Sigfox mode the maximum data size is 12 bytes. In FSK the maximum is 64.
|
||||
|
||||
```python
|
||||
|
||||
# send a Sigfox payload of bytes
|
||||
s.send(bytes([1, 2, 3]))
|
||||
|
||||
@@ -176,7 +169,6 @@ s.send('Hello')
|
||||
This method can be used to receive a Sigfox downlink or FSK message.
|
||||
|
||||
```python
|
||||
|
||||
# size of buffer should be passed for expected payload, e.g. 64 bytes
|
||||
s.recv(64)
|
||||
```
|
||||
@@ -186,7 +178,6 @@ s.recv(64)
|
||||
Set the value of the given socket option. The needed symbolic constants are defined in the socket module (`SO_*` etc.). In the case of Sigfox the values are always an integer. Examples:
|
||||
|
||||
```python
|
||||
|
||||
# wait for a downlink after sending the uplink packet
|
||||
s.setsockopt(socket.SOL_SIGFOX, socket.SO_RX, True)
|
||||
|
||||
@@ -206,7 +197,6 @@ s.setsockopt(socket.SOL_SIGFOX, socket.SO_BIT, False)
|
||||
Sending a Sigfox packet with a single bit is achieved by sending an empty string, i.e.:
|
||||
|
||||
```python
|
||||
|
||||
import socket
|
||||
s = socket.socket(socket.AF_SIGFOX, socket.SOCK_RAW)
|
||||
|
||||
@@ -228,14 +218,12 @@ If the socket is set to blocking, your code will be wait until the socket comple
|
||||
A Sigfox capable Pycom devices (SiPy) can both send and receive data from the Sigfox network. To receive data, a message must first be sent up to Sigfox, requesting a downlink message. This can be done by passing a `True` argument into the `setsockopt()` method.
|
||||
|
||||
```python
|
||||
|
||||
s.setsockopt(socket.SOL_SIGFOX, socket.SO_RX, True)
|
||||
```
|
||||
|
||||
An example of the downlink procedure can be seen below:
|
||||
|
||||
```python
|
||||
|
||||
# init Sigfox for RCZ1 (Europe)
|
||||
sigfox = Sigfox(mode=Sigfox.SIGFOX, rcz=Sigfox.RCZ1)
|
||||
|
||||
@@ -261,13 +249,12 @@ print(ubinascii.hexlify(r))
|
||||
To communicate between two Sigfox capable devices, it may be used in FSK mode. Two devices are required to be set to the same frequency, both using FSK.
|
||||
|
||||
{{% hint style="info" %}}
|
||||
Sigfox.FSK mode is not supported on LoPy 4 and FiPy.
|
||||
`Sigfox.FSK` mode is not supported on LoPy 4 and FiPy.
|
||||
{{% /hint %}}
|
||||
|
||||
**Device 1**:
|
||||
|
||||
```python
|
||||
|
||||
sigfox = Sigfox(mode=Sigfox.FSK, frequency=868000000)
|
||||
|
||||
s = socket.socket(socket.AF_SIGFOX, socket.SOCK_RAW)
|
||||
@@ -282,7 +269,6 @@ while True:
|
||||
**Device 2**:
|
||||
|
||||
```python
|
||||
|
||||
sigfox = Sigfox(mode=Sigfox.FSK, frequency=868000000)
|
||||
|
||||
s = socket.socket(socket.AF_SIGFOX, socket.SOCK_RAW)
|
||||
|
||||
@@ -5,11 +5,9 @@ aliases:
|
||||
- firmwareapi/pycom/network/wlan.md
|
||||
- chapter/firmwareapi/pycom/network/wlan
|
||||
---
|
||||
|
||||
This class provides a driver for the WiFi network processor in the module. Example usage:
|
||||
|
||||
```python
|
||||
|
||||
import network
|
||||
import time
|
||||
# setup as a station
|
||||
@@ -25,7 +23,6 @@ print(wlan.ifconfig())
|
||||
## Quick Usage Example
|
||||
|
||||
```python
|
||||
|
||||
import machine
|
||||
from network import WLAN
|
||||
|
||||
@@ -42,9 +39,9 @@ print(wlan.ifconfig())
|
||||
|
||||
## Constructors
|
||||
|
||||
#### class network.WLAN(id=0, ...)
|
||||
### class network.WLAN(id=0, ...)
|
||||
|
||||
Create a WLAN object, and optionally configure it. See [`init`](../wlan.md#wlan-init-mode-ssid-none-auth-none-channel-1-antenna-none-power_save-false-hidden-false) for params of configuration.
|
||||
Create a WLAN object, and optionally configure it. See [`init`](../wlan#wlan-init-mode-ssid-none-auth-none-channel-1-antenna-none-power_save-false-hidden-false) for params of configuration.
|
||||
|
||||
{{% hint style="info" %}}
|
||||
The WLAN constructor is special in the sense that if no arguments besides the `id` are given, it will return the already existing WLAN instance without re-configuring it. This is because WLAN is a system feature of the WiPy. If the already existing instance is not initialised it will do the same as the other constructors an will initialise it with default values.
|
||||
@@ -52,7 +49,7 @@ The WLAN constructor is special in the sense that if no arguments besides the `i
|
||||
|
||||
## Methods
|
||||
|
||||
#### wlan.init(mode, \* , ssid=None, auth=None, channel=1, antenna=None, power\_save=False, hidden=False)
|
||||
#### wlan.init(mode, \* , ssid=None, auth=None, channel=1, antenna=None, power\_save=False, hidden=False, bandwidth=HT40, max\_tx\_pwr=20, country=CN)
|
||||
|
||||
Set or get the WiFi network processor configuration.
|
||||
|
||||
@@ -69,11 +66,13 @@ Arguments are:
|
||||
|
||||
* `power_save` enables or disables power save functions in `STA` mode.
|
||||
* `hidden` only valid in `WLAN.AP` mode to create an access point with a hidden SSID when set to `True`.
|
||||
* `bandwidth` is the Bandwidth to use, either 20MHz or 40 MHz , use `HT20` or `HT40`
|
||||
* `max_tx_pwr` is the maximum WiFi Tx power allowed. see `WLAN.max_tx_power()` for more details
|
||||
* `country` tuple representing the country configuration parameters. see `WLAN.country()` for more details
|
||||
|
||||
For example, you can do:
|
||||
|
||||
```python
|
||||
|
||||
# create and configure as an access point
|
||||
wlan.init(mode=WLAN.AP, ssid='wipy-wlan', auth=(WLAN.WPA2,'www.wipy.io'), channel=7, antenna=WLAN.INT_ANT)
|
||||
```
|
||||
@@ -81,7 +80,6 @@ wlan.init(mode=WLAN.AP, ssid='wipy-wlan', auth=(WLAN.WPA2,'www.wipy.io'), channe
|
||||
or
|
||||
|
||||
```python
|
||||
|
||||
# configure as an station
|
||||
wlan.init(mode=WLAN.STA)
|
||||
```
|
||||
@@ -95,11 +93,11 @@ Pin('P12', mode=Pin.OUT)(True)
|
||||
```
|
||||
{{% /hint %}}
|
||||
|
||||
#### wlan.deinit()
|
||||
### wlan.deinit()
|
||||
|
||||
Disables the WiFi radio.
|
||||
|
||||
#### wlan.connect(ssid, \* , auth=None, bssid=None, timeout=None, ca\_certs=None, keyfile=None, certfile=None, identity=None)
|
||||
### wlan.connect(ssid, \* , auth=None, bssid=None, timeout=None, ca\_certs=None, keyfile=None, certfile=None, identity=None, hostname=None)
|
||||
|
||||
Connect to a wifi access point using the given SSID, and other security parameters.
|
||||
|
||||
@@ -112,24 +110,48 @@ Connect to a wifi access point using the given SSID, and other security paramete
|
||||
* `keyfile` is the path to the client key. Only used if `username` and `password` are not part of the `auth` tuple.
|
||||
* `certfile` is the path to the client certificate. Only used if `username` and `password` are not part of the `auth` tuple.
|
||||
* `identity` is only used in case of `WLAN.WPA2_ENT` security. Needed by the server.
|
||||
* `hostname` is the name of the host connecting to the AP. Max length of name string is 32 Bytes
|
||||
|
||||
{{% hint style="info" %}}
|
||||
The ESP32 only handles certificates with `pkcs8` format (but not the "Traditional SSLeay RSAPrivateKey" format). The private key should be RSA coded with 2048 bits at maximum.
|
||||
{{% /hint %}}
|
||||
|
||||
#### wlan.scan()
|
||||
#### wlan.scan(\[ssid=NULL, bssid=NULL, channel=0, show\_hidden=False, type=WLAN.SCAN\_ACTIVE, scantime=120ms\])
|
||||
|
||||
Performs a network scan and returns a list of named tuples with `(ssid, bssid, sec, channel, rssi)`. Note that channel is always `None` since this info is not provided by the WiPy.
|
||||
Performs a network scan and returns a list of named tuples with (ssid, bssid, sec, channel, rssi). When no config args passed scan will be performed with default configurations.
|
||||
|
||||
#### wlan.disconnect()
|
||||
Note: For Fast scan mode ssid/bssid and channel should be
|
||||
|
||||
* `ssid` : If the SSID is not NULL, it is only the AP with the same SSID that can be scanned.
|
||||
* `bssid` : If the BSSID is not NULL, it is only the AP with the same BSSID that can be scanned. The bssid is given as 6 Hexadecimal bytes literals (i.e b'\xff\xff\xff\xff\xff\xff')
|
||||
* `channel` : If “channel” is 0, there will be an all-channel scan; otherwise, there will be a specific-channel scan.
|
||||
* `show_hidden` : If “show\_hidden” is 0, the scan ignores the AP with a hidden SSID; otherwise, the scan considers the hidden AP a normal one.
|
||||
* `type` : If “type” is `WLAN.SCAN_ACTIVE`, the scan is “active”; otherwise, it is a “passive” one.
|
||||
* Active Scan is performed by sending a probe request. The default scan is an active scan
|
||||
* Passive Scan sends no probe request. Just switch to the specific channel and wait for a beacon.
|
||||
* `scantime` :
|
||||
|
||||
This field is used to control how long the scan dwells on each channel. For passive scans, scantime=\[int\] designates the dwell time for each channel.
|
||||
|
||||
For active scans, dwell times for each channel are listed below. scantime is given as a tuple for min and max times (min,max)
|
||||
|
||||
min=0, max=0: scan dwells on each channel for 120 ms.
|
||||
|
||||
min>0, max=0: scan dwells on each channel for 120 ms.
|
||||
|
||||
min=0, max>0: scan dwells on each channel for max ms.
|
||||
|
||||
min>0, max>0: The minimum time the scan dwells on each channel is min ms. If no AP is found during this time frame, the scan switches to the next channel. Otherwise, the scan dwells on the channel for max ms.If you want to improve the performance of the the scan, you can try to modify these two parameters.
|
||||
|
||||
### wlan.disconnect()
|
||||
|
||||
Disconnect from the WiFi access point.
|
||||
|
||||
#### wlan.isconnected()
|
||||
### wlan.isconnected()
|
||||
|
||||
In case of STA mode, returns `True` if connected to a WiFi access point and has a valid IP address. In AP mode returns `True` when a station is connected, `False` otherwise.
|
||||
|
||||
#### wlan.ifconfig(id=0, config=\['dhcp' or configtuple\])
|
||||
### wlan.ifconfig(id=0, config=\['dhcp' or configtuple\])
|
||||
|
||||
When `id` is 0, the configuration will be get/set on the Station interface. When `id` is 1 the configuration will be done for the AP interface.
|
||||
|
||||
@@ -140,45 +162,238 @@ If `dhcp` is passed as a parameter then the DHCP client is enabled and the IP pa
|
||||
If the 4-tuple config is given then a static IP is configured. For instance:
|
||||
|
||||
```python
|
||||
|
||||
wlan.ifconfig(config=('192.168.0.4', '255.255.255.0', '192.168.0.1', '8.8.8.8'))
|
||||
```
|
||||
|
||||
#### wlan.mode(\[mode\])
|
||||
### wlan.mode(\[mode\])
|
||||
|
||||
Get or set the WLAN mode.
|
||||
|
||||
#### wlan.ssid(\[ssid\])
|
||||
### wlan.ssid(\[ssid\])
|
||||
|
||||
Get or set the SSID when in AP mode.
|
||||
Get or set the SSID (Set SSID of AP).
|
||||
|
||||
#### wlan.auth(\[auth\])
|
||||
In case if mode = `WLAN.STA` this method can get the ssid of AP the board is connected to.
|
||||
|
||||
In case of mode = `WLAN.AP` this method can get the ssid of the board's own AP.
|
||||
|
||||
In case of mode = `WLAN.STA_AP` this method can get the ssid of board's own AP plus the AP the STA is connected to in form of a tuple:
|
||||
|
||||
_\_
|
||||
|
||||
### wlan.auth(\[auth\])
|
||||
|
||||
Get or set the authentication type when in AP mode.
|
||||
|
||||
#### wlan.channel(\[channel\])
|
||||
### wlan.channel(\[channel\])
|
||||
|
||||
Get or set the channel (only applicable in AP mode).
|
||||
_In AP mode:_
|
||||
|
||||
#### wlan.antenna(\[antenna\])
|
||||
Get or set the wifi channel
|
||||
|
||||
_In STA mode:_
|
||||
|
||||
`channel`: is the primary channel to listen to.
|
||||
|
||||
_Note: Setting Channel in STA mode is only Allowed in Promiscuous mode_
|
||||
|
||||
### wlan.antenna(\[antenna\])
|
||||
|
||||
Get or set the antenna type (external or internal).
|
||||
|
||||
{{% hint style="info" %}}
|
||||
To use an external antenna, set `P12 as output pin.`
|
||||
### wlan.mac(\[mac, mode\])
|
||||
|
||||
when no arguments are passed a 6-byte long `bytes` tuple object with the WiFI MAC address of both Wifi Station mode and Acces Point mode
|
||||
|
||||
`mac`: a 6 bytes bytearray mac address
|
||||
|
||||
`mode`: The Interface to set the given MAC address to `WLAN.STA` or `WLAN.AP`
|
||||
|
||||
Ex: To set the mac address of Wifi Station mode:
|
||||
|
||||
```python
|
||||
|
||||
Pin('P12', mode=Pin.OUT)(True)
|
||||
wlan.mac(bytearray([0xAE, 0x77, 0x88, 0x99, 0x22, 0x44]), WLAN.STA)
|
||||
```
|
||||
{{% /hint %}}
|
||||
|
||||
#### wlan.mac()
|
||||
_Note: STA and AP cannot have the Same Mac Address_
|
||||
|
||||
Get a 6-byte long `bytes` object with the WiFI MAC address.
|
||||
### wlan.bandwidth()
|
||||
|
||||
Set the bandwidth of the wifi, either 20 MHz or 40 MHz can be configured, use constants `HT20` or `HT40`
|
||||
|
||||
### wlan.hostname()
|
||||
|
||||
Set the Host name of the device connecting to the AP in case of Wifi `mode=WLAN.STA`, in case of `mode=WLAN.AP` this is the name of the host hosting the AP. Max length of name string is 32 Bytes
|
||||
|
||||
### wlan.ap\_sta\_list()
|
||||
|
||||
Gets an info list of all stations connected to the board's AP.
|
||||
|
||||
Info returned is a list of tuples containning (\[mac address of connected STA\], \[average rssi value\], \[Wlan protocol enabled by STA\]).
|
||||
|
||||
Protocol types are either : `WLAN.PHY_11_B`, `WLAN.PHY_11_G`, `WLAN.PHY_11_N` or `WLAN.PHY_LOW_RATE`
|
||||
|
||||
### wlan.max\_tx\_power(\[power\])
|
||||
|
||||
Gets or Sets the maximum allowable transmission power for wifi.
|
||||
|
||||
Packets of different rates are transmitted in different powers according to the configuration in phy init data. This API only sets maximum WiFi transmiting power. If this API is called, the transmiting power of every packet will be less than or equal to the value set by this API. Default is Level 0.
|
||||
|
||||
Values passed in power are mapped to transmit power levels as follows:
|
||||
|
||||
* \[78, 127\]: level0
|
||||
* \[76, 77\]: level1
|
||||
* \[74, 75\]: level2
|
||||
* \[68, 73\]: level3
|
||||
* \[60, 67\]: level4
|
||||
* \[52, 59\]: level5
|
||||
* \[44, 51\]: level5 - 2dBm
|
||||
* \[34, 43\]: level5 - 4.5dBm
|
||||
* \[28, 33\]: level5 - 6dBm
|
||||
* \[20, 27\]: level5 - 8dBm
|
||||
* \[8, 19\]: level5 - 11dBm
|
||||
* \[-128, 7\]: level5 - 14dBm
|
||||
|
||||
### wlan.country(\[country, schan, nchan, max\_tx\_pwr, policy\])
|
||||
|
||||
Gets or set s Country configuration parameters for wifi.
|
||||
|
||||
* `country` That is the country name code , it is max 2 characters string representing the country eg: "CN" for china nad "NL" for Netherlands
|
||||
* `scahn` is the start channel number, in scan process scanning will be performed starting from this channels till the total number of channels. it should be less than or equal 14.
|
||||
* `nchan` is the total number of channels in the specified country. maximum is 14
|
||||
* `max_tx_pwr` Maximum transmission power allowed. see `WLAN.max_tx_power()` for more details.
|
||||
* `policy` Is the method when setting country configuration for `WLAN.COUNTRY_POL_AUTO` in STA mode the wifi will aquire the same country config of the connected AP, for `WLAN.COUNTRY_POL_MAN` the configured country parameters will take effect regardless of Connected AP.
|
||||
|
||||
### wlan.joined\_ap\_info()
|
||||
|
||||
Returns a tuple with (bssid, ssid, primary channel, rssi, Authorization method, wifi standard used) of the connected AP in case of STA mode.
|
||||
|
||||
### wlan.wifi\_protocol(\[(bool PHY11\_\_B, bool PHY11\_G, bool PHY11\_N)\])
|
||||
|
||||
Sets or gets Wifi Protocol supported.
|
||||
|
||||
### wlan.send\_raw(Buffer, interface=STA, use\_sys\_seq=True)
|
||||
|
||||
Send raw data through the Wifi Interface.
|
||||
|
||||
`Buffer`: Buffer of bytes object Containning Data to be transmitted. Data should not be greater than 1500 nor smaller than 24.
|
||||
|
||||
`interface`: The Interface to use for transmitting Data AP or STA in case the mode used is APSTA. other wise the interface currently active will be used.
|
||||
|
||||
`use_sys_seq`: `True` to use the systems next sequance number for sending the data, `False` for keeping the sequance number in the given raw data buffer unchanged.
|
||||
|
||||
### wlan.callback(trigger, handler=Null, arg=Null)
|
||||
|
||||
Register a user callback function `handler` to be called once any of the `trigger` events occures optionally with a passed `arg`. by default the wlan obj is passed as arg to the handler. To unregister the callback you can call the `wlan.callback` function with empty `handler` and `arg` parameters.
|
||||
|
||||
For trigger events see `Constants` section.
|
||||
|
||||
### wlan.promiscuous(\[bool\])
|
||||
|
||||
* To enable Promiscuous mode `WLAN.promiscuous(True)` should be called, and `WLAN.promiscuous(False)` for disabling
|
||||
* To get current mode setting call function with empty args
|
||||
|
||||
Note:
|
||||
|
||||
* Promiscuous mode should be enabled for Wifi packets types Events to be triggered
|
||||
* for changing wifi channel via `wlan.channel()` promiscuous mode should be enabled.
|
||||
|
||||
Example using promoscious mode:
|
||||
|
||||
```python
|
||||
from network import WLAN
|
||||
import ubinascii
|
||||
|
||||
def pack_cb(pack):
|
||||
mac = bytearray(6)
|
||||
pk = wlan.wifi_packet()
|
||||
control = pk.data[0]
|
||||
subtype = (0xF0 & control) >> 4
|
||||
type = 0x0C & control
|
||||
#print("Control:{}, subtype:{}, type:{}".format(control, subtype, type))
|
||||
if subtype == 4:
|
||||
for i in range (0,6):
|
||||
mac[i] = pk.data[10 + i]
|
||||
print ("Wifi Node with MAC: {}".format(ubinascii.hexlify(mac)))
|
||||
|
||||
wlan = WLAN(mode=WLAN.STA, antenna=WLAN.EXT_ANT)
|
||||
wlan.callback(trigger=WLAN.EVENT_PKT_MGMT, handler=pack_cb)
|
||||
wlan.promiscuous(True)
|
||||
```
|
||||
|
||||
### wlan.events()
|
||||
|
||||
This function will return an integer object as mask for triggered events.
|
||||
|
||||
### wlan.wifi\_packet()
|
||||
|
||||
This function will return a tuble with Wifi packet info captured in promiscuous mode.
|
||||
|
||||
### wlan.ctrl\_pkt\_filter(\[int\])
|
||||
|
||||
This function is used to set the filter mask for Wifi control packets in promiscuous mode. for Filter masks, see `Constants` section.
|
||||
|
||||
To get the current Filter mask, call the function with empty args.
|
||||
|
||||
### wlan.smartConfig\(\)
|
||||
|
||||
Start SmartConfig operation, the smartConfig is a provisioning technique that enables setting Wifi credentials for station mode wirelessly via mobile app.
|
||||
|
||||
####Steps:
|
||||
- call **wlan.smartConfig()** \(if smartConfig is not enabled on boot or you want to restart smartConfig\)
|
||||
- Use mobile App (ESP touch or Pycom App) to set ssid and password for the AP
|
||||
- You can register a callback to be triggered when smart Config is Finesed successfuly or timedout.
|
||||
|
||||
### wlan.Connected\_ap\_pwd()
|
||||
|
||||
Get the password of AP the Device is connected to.
|
||||
|
||||
## Constants
|
||||
|
||||
* WLAN mode: `WLAN.STA`, `WLAN.AP`, `WLAN.STA_AP`
|
||||
* WLAN network security: `WLAN.WEP`, `WLAN.WPA`, `WLAN.WPA2`, `WLAN.WPA2_ENT`
|
||||
* Antenna type: `WLAN.INT_ANT`, `WLAN.EXT_ANT`
|
||||
* WLAN Bandwidth: `WLAN.HT20`, `WLAN.HT40`
|
||||
* WLAN protocol: `WLAN.PHY_11_B`, `WLAN.PHY_11_G`, `WLAN.PHY_11_N`, `WLAN.PHY_LOW_RATE`
|
||||
* Scan Type: `WLAN.SCAN_ACTIVE` `WLAN.SCAN_PASSIVE`
|
||||
* WLAN country config policy: `WLAN.COUNTRY_POL_AUTO`, `WLAN.COUNTRY_POL_MAN`
|
||||
* Secondary Channel position: `WLAN.SEC_CHN_POS_ABOVE`, `WLAN.SEC_CHN_POS_BELOW`
|
||||
* Wlan callback triggers:
|
||||
|
||||
`WLAN.EVENT_PKT_MGMT`: Managment packet recieved in promiscuous mode.
|
||||
|
||||
`WLAN.EVENT_PKT_CTRL`: Control Packet recieved in promiscuous mode
|
||||
|
||||
`WLAN.EVENT_PKT_DATA`: Data packet recieved in promiscuous mode
|
||||
|
||||
`WLAN.EVENT_PKT_DATA_MPDU`: MPDU data packet recieved in promiscuous mode
|
||||
|
||||
`WLAN.EVENT_PKT_DATA_AMPDU`: AMPDU data packet recieved in promiscuous mode
|
||||
|
||||
`WLAN.EVENT_PKT_MISC`: misc paket recieved in promiscuous mode.
|
||||
|
||||
`WLAN.EVENT_PKT_ANY`: Any packet recieved in promiscuous mode.
|
||||
|
||||
`SMART_CONF_DONE`: Smart Config of wifi ssid/pwd Finished
|
||||
|
||||
`SMART_CONF_TIEMOUT`: Smart Config of wifi ssid/pwd timed-out
|
||||
|
||||
* Control packet filters in promiscuous mode:
|
||||
|
||||
`WLAN.FILTER_CTRL_PKT_ALL`: Filter all Control packets
|
||||
|
||||
`WLAN.FILTER_CTRL_PKT_WRAPPER`: Filter control wrapper packets
|
||||
|
||||
`WLAN.FILTER_CTRL_PKT_BAR`: Filter Control BAR packets
|
||||
|
||||
`WLAN.FILTER_CTRL_PKT_BA`: Filter Control BA packets
|
||||
|
||||
`WLAN.FILTER_CTRL_PKT_PSPOLL`: Filter Control PSPOLL Packets
|
||||
|
||||
`WLAN.FILTER_CTRL_PKT_CTS`: Filter Control CTS packets
|
||||
|
||||
`WLAN.FILTER_CTRL_PKT_ACK`: Filter Control ACK packets
|
||||
|
||||
`WLAN.FILTER_CTRL_PKT_CFEND`: Filter Control CFEND Packets
|
||||
|
||||
`WLAN.FILTER_CTRL_PKT_CFENDACK`: Filter Control CFENDACK Packets
|
||||
|
||||
@@ -11,7 +11,6 @@ The `pycom` module contains functions to control specific features of the Pycom
|
||||
## Quick Usage Example
|
||||
|
||||
```python
|
||||
|
||||
import pycom
|
||||
|
||||
pycom.heartbeat(False) # disable the heartbeat LED
|
||||
@@ -22,11 +21,11 @@ pycom.rgbled(0xff00) # make the LED light up in green color
|
||||
|
||||
## Methods
|
||||
|
||||
#### pycom.heartbeat(\[enable\])
|
||||
#### pycom.heartbeat\(\[boolean\]\)
|
||||
|
||||
Get or set the state (enabled or disabled) of the heartbeat LED. Accepts and returns boolean values (`True` or `False`).
|
||||
|
||||
#### pycom.heartbeat\_on\_boot(\[enable\])
|
||||
#### pycom.heartbeat\_on\_boot\(\[boolean\]\)
|
||||
|
||||
Allows you permanently disable or enable the heartbeat LED. Once this setting is set, it will persist between reboots. Note, this only comes into effect on the next boot, it does not stop the already running heartbeat.
|
||||
|
||||
@@ -39,7 +38,6 @@ Set the colour of the RGB LED. The colour is specified as 24 bit value represent
|
||||
Set the value of the specified key in the NVRAM memory area of the external flash. Data stored here is preserved across resets and power cycles. Value can only take 32-bit integers at the moment. Example:
|
||||
|
||||
```python
|
||||
|
||||
import pycom
|
||||
|
||||
pycom.nvs_set('temp', 25)
|
||||
@@ -51,7 +49,6 @@ pycom.nvs_set('count', 10)
|
||||
Get the value the specified key from the NVRAM memory area of the external flash. Example:
|
||||
|
||||
```python
|
||||
|
||||
import pycom
|
||||
|
||||
pulses = pycom.nvs_get('count')
|
||||
@@ -67,50 +64,78 @@ Erase the given key from the NVRAM memory area.
|
||||
|
||||
Erase the entire NVRAM memory area.
|
||||
|
||||
#### pycom.wifi\_on\_boot(\[enable\])
|
||||
#### pycom.wifi\_on\_boot\(\[boolean\]\)
|
||||
|
||||
Get or set the WiFi on boot flag. When this flag is set to `True`, the AP with the default SSID (`lopy-wlan-xxx` for example) will be enabled as part of the boot process. If the flag is set to False, the module will boot with WiFi disabled until it's enabled by the script via the `WLAN` class. This setting is stored in non-volatile memory which preserves it across resets and power cycles. Example:
|
||||
Get or set the WiFi on boot flag. When this flag is set to `True`, The Wifi will be enabled according to the other wifi settings eg (ssid\_sta, pwd\_sta, ssid\_ap, pwd\_ap). when `False` the Wifi module will be disabled untill enabled directly via WLAN class.
|
||||
|
||||
This setting is stored in non-volatile memory which preserves it across resets and power cycles. Example:
|
||||
|
||||
```python
|
||||
|
||||
import pycom
|
||||
|
||||
pycom.wifi_on_boot(True) # enable WiFi on boot
|
||||
pycom.wifi_on_boot() # get the wifi on boot flag
|
||||
```
|
||||
|
||||
#### pycom.wdt\_on\_boot(\[enable\])
|
||||
#### pycom.wifi\_ssid\_sta\([ssid]\)
|
||||
|
||||
Enables the WDT at boot time with the timeout in ms set by the function `wdt_on_boot_timeout`. If this flag is set, the application needs to reconfigure the WDT with a new timeout and feed it regularly to avoid a reset.
|
||||
Get or set the ssid of the Access point the device should connect to on startup.
|
||||
This setting is stored in non-volatile memory which preserves it across resets and power cycles
|
||||
|
||||
```python
|
||||
#### pycom.wifi\_ssid\_ap\([ssid]\)
|
||||
|
||||
import pycom
|
||||
Get or set the ssid of the Access point that should be started by the device at startup, if not set and startup Wifi mode is AP the default AP name \(\<Board\_Name\>-wlan-\<last\_4\_digits\_mac\>\) will be used.This setting is stored in non-volatile memory which preserves it across resets and power cycles
|
||||
|
||||
pycom.wdt_on_boot(True) # enable WDT on boot
|
||||
pycom.wdt_on_boot() # get the WDT on boot flag
|
||||
```
|
||||
#### pycom.wifi\_pwd\_sta\([key]\)
|
||||
|
||||
Get or set the Password of the Access point the device should connect to on startup, leave the password unset if the AP is open.This setting is stored in non-volatile memory which preserves it across resets and power cycles
|
||||
|
||||
#### pycom.wifi\_pwd\_ap\([key]\)
|
||||
|
||||
Get or set the Password of the Access point that should be started by the device at startup, leave unset if the AP should be open.This setting is stored in non-volatile memory which preserves it across resets and power cycles
|
||||
|
||||
#### pycom.smart\_config\_on\_boot\([boolean]\)
|
||||
|
||||
Read or (Enable/Disable) SmartConfig functionality on startup, this flag will be reset after successful completion of the smartConfig process after startup.This setting is stored in non-volatile memory which preserves it across resets and power cycles
|
||||
|
||||
#### pycom.smart\_config\_on\_boot\([boolean]\)
|
||||
|
||||
Read or (Enable/Disable) SmartConfig functionality on startup, this flag will be reset after successful completion of the smartConfig process after startup.This setting is stored in non-volatile memory which preserves it across resets and power cycles
|
||||
|
||||
#### pycom.wifi\_mode\_on\_boot\(\[boolean\]\)
|
||||
|
||||
Set or get the Wifi Mode at startup , `WLAN.STA`, `WLAN.AP` or `WLAN.APSTA`.This setting is stored in non-volatile memory which preserves it across resets and power cycles
|
||||
|
||||
#### pycom.wdt\_on\_boot\_timeout(\[timeout\])
|
||||
|
||||
Sets or gets the WDT on boot timeout in milliseconds. The minimum value is 5000 ms.
|
||||
|
||||
```python
|
||||
|
||||
import pycom
|
||||
|
||||
pycom.wdt_on_boot_timeout(10000) # set the timeout to 5000ms
|
||||
pycom.wdt_on_boot_timeout() # get the WDT timeout value
|
||||
```
|
||||
|
||||
#### pycom.pulses\_get(pin, timeout)
|
||||
#### pycom.wdt\_on\_boot\(\[enable\]\)
|
||||
|
||||
Enables the WDT at boot time with the timeout in ms set by the function `wdt_on_boot_timeout`. If this flag is set, the application needs to reconfigure the WDT with a new timeout and feed it regularly to avoid a reset
|
||||
|
||||
|
||||
```python
|
||||
import pycom
|
||||
|
||||
pycom.wdt_on_boot(True) # enable WDT on boot
|
||||
pycom.wdt_on_boot() # get the WDT on boot flag
|
||||
```
|
||||
|
||||
#### pycom.pulses\_get\(pin, timeout\)
|
||||
|
||||
Return a list of pulses at `pin`. The methods scans for transitions at `pin` and returns a list of tuples, each telling the pin value and the duration in microseconds of that value. `pin` is a pin object, which must have set to `INP` or `OPEN_DRAIN` mode. The scan stops if not transitions occurs within `timeout` milliseconds.
|
||||
|
||||
Example:
|
||||
|
||||
```python
|
||||
|
||||
# get the raw data from a DHT11/DHT22/AM2302 sensor
|
||||
from machine import Pin
|
||||
from pycom import pulses_get
|
||||
@@ -134,7 +159,6 @@ Perform a firmware update. These methods are internally used by a firmware updat
|
||||
Example:
|
||||
|
||||
```python
|
||||
|
||||
# Firmware update by reading the image from the SD card
|
||||
#
|
||||
from pycom import ota_start, ota_write, ota_finish
|
||||
@@ -165,3 +189,13 @@ with open(APPIMG, "rb") as f:
|
||||
|
||||
Instead of reading the data to be written from a file, it can obviously also be received from a server using any suitable protocol, without the need to store it in the devices file system.
|
||||
|
||||
#### pycom.bootmgr(boot\_partition=pycom.FACTORY, fs\_type=FAT, safeboot=False, reset=False)
|
||||
|
||||
* `boot_partition` This is to set the partition to boot from , this could be set to either `pycom.FACTORY` or `pycom.OTA_0`
|
||||
* `fs_type` This is to set the filesystem to use for the flash memory (`/flash`). This could be set to `pycom.FAT` for FAT16 or `pycom.LittleFS` for LittleFS filesystem.
|
||||
|
||||
_Note: When the firmware is built with option_ `FS_USE_LITTLEFS` _the file system for_ `/flash` _is forced to be LittleFS._
|
||||
|
||||
* `safeboot` Enable or Disable safemoot mode.
|
||||
* `reset` Set `True` to reset target after updating the `bootmgr` options , `False` for not resetting.
|
||||
|
||||
|
||||
@@ -16,8 +16,6 @@ In order to connect your LoRa capable Pycom module to a LoRaWAN network you will
|
||||
Firstly you will need to get your modules `Device EUI`, this can be achieved using the following code:
|
||||
|
||||
```python
|
||||
|
||||
|
||||
from network import LoRa
|
||||
import ubinascii
|
||||
|
||||
|
||||
@@ -8,14 +8,12 @@ Below there is a code example that should be implemented in the main.py file. Th
|
||||
|
||||
```python
|
||||
import time
|
||||
import pycom
|
||||
|
||||
if pybytes is not None:
|
||||
if pybytes.__pymesh:
|
||||
pymesh = pybytes.__pymesh
|
||||
if pybytes.__pymesh and pybytes.__pymesh.__pymesh:
|
||||
pymesh = pybytes.__pymesh.__pymesh
|
||||
while True:
|
||||
free_mem = pycom.get_free_heap()
|
||||
pkt = "Hello, from " + str(pymesh.__pymesh.mac()) + ", time " + str(time.time()) + ", mem " + str(free_mem)
|
||||
pkt = "Hello, from " + str(pymesh.mac())
|
||||
pybytes.send_signal(1, pkt)
|
||||
time.sleep(20)
|
||||
```
|
||||
@@ -23,3 +21,5 @@ if pybytes is not None:
|
||||
Every time a data is sent trough Pymesh, the node's monitoring data is also sent. This monitoring data contains information as the number of neighbors, loRa mac, IP, role, age, and location.
|
||||
|
||||
Some of this information can be seen in the Pymesh Monitoring view or in section Signal, in the device interface in Pybytes.
|
||||
|
||||
For additional `pymesh` methods, check the open-source [Pymesh Library](https://github.com/pycom/pycom-libraries/tree/master/pymesh/pymesh_frozen) and the corresponding [Pymesh documentation](/pymesh/).
|
||||
|
||||
@@ -15,7 +15,7 @@ Mesh networks essentially get rid of gateways, which decentralises the network's
|
||||
|
||||
Pymesh works on all of our LoRa supporting development boards, the LoPy4 and FiPy as well as on our OEM modules, L01 and L04.
|
||||
|
||||
_**Note: For obtaining the Pymesh firmware please follow the steps from [Pymesh LICENCE page](/pymesh/licence).**_
|
||||
_**Note: For obtaining the Pymesh firmware please follow the steps from [Pybytes - Pymesh integration](/pybytes/pymeshintegration/).**_
|
||||
|
||||
## What does Pymesh offer you?
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ aliases:
|
||||
|
||||
This Micropython library is included as frozen scripts in the Pymesh firmware release.
|
||||
|
||||
The code is open-sourced in [pycom-libraries repository](https://github.com/pycom/pycom-libraries/tree/master/lib/pymesh).
|
||||
The code is open-sourced in [pycom-libraries repository](https://github.com/pycom/pycom-libraries/blob/master/pymesh/pymesh_frozen/lib/pymesh.py).
|
||||
|
||||
It is easily customisable and contributions are welcome using [Github PRs](https://github.com/pycom/pycom-libraries/pulls).
|
||||
|
||||
|
||||
@@ -6,11 +6,16 @@ aliases:
|
||||
|
||||
## Overview
|
||||
|
||||
The Pymesh micropython library is included as a `frozen python script` in the Pymesh firmware releases.
|
||||
The Pymesh micropython library is included as a `frozen python script` in the Pymesh firmware releases. It is also available as [open-source micropython script](https://github.com/pycom/pycom-libraries/blob/master/pymesh/pymesh_frozen/lib/cli.py).
|
||||
|
||||
Instead of REPL, a specific Pymesh CLI interprets commands. This is shown by `>`.
|
||||
Instead of REPL, a specific Pymesh CLI interprets commands. This is shown by `>`. The CLI is executed on a separate thread inside the Pymesh library.
|
||||
|
||||
{{% hint style="info" %}}
|
||||
* The CLI needs to be started using the `pymesh.cli_start()` method.
|
||||
* In the CLI the `h` command will print the list of available commands.
|
||||
* The command `stop` will break the CLI thread.
|
||||
{{% /hint %}}
|
||||
|
||||
The CLI is executed on a separate thread inside the Pymesh library.
|
||||
|
||||
For example:
|
||||
```
|
||||
@@ -21,32 +26,47 @@ mesh_mac_list [1, 6, 2]
|
||||
## Internal CLI
|
||||
|
||||
```
|
||||
>>> pymesh.cli_start()
|
||||
>h
|
||||
List of available commands
|
||||
ip - display current IPv6 unicast addresses
|
||||
mac - set or display the current LoRa MAC address
|
||||
self - display all info about current node
|
||||
mml - display the Mesh Mac List (MAC of all nodes inside this Mesh)
|
||||
mp - display the Mesh Pairs (pairs of all nodes connections)
|
||||
s - send message
|
||||
ws - verifies if the message sent was acknowledged
|
||||
rm - verifies if any message was received
|
||||
sleep - deep-sleep
|
||||
br - enable/disable or display the current Border Router functionality
|
||||
brs - send packet for Mesh-external, to BR, if any
|
||||
rst - reset NOW, including NVM Pymesh IPv6
|
||||
buf - display buffer info
|
||||
ot - sends command to openthread internal CLI
|
||||
debug - set debug level
|
||||
config - print config file contents
|
||||
debug - set debug level
|
||||
gps - get/set location coordinates
|
||||
h - help, list of commands
|
||||
ip - display current IPv6 unicast addresses
|
||||
mac - set or display the current LoRa MAC address
|
||||
mml - display the Mesh Mac List (MAC of all nodes inside this Mesh), also inquires Leader
|
||||
mp - display the Mesh Pairs (Pairs of all nodes connections), also inquires Leader
|
||||
ot - sends command to openthread internal CLI
|
||||
pause - suspend Pymesh
|
||||
resume - resume Pymesh
|
||||
rm - verifies if any message was received
|
||||
rst - reset NOW, including NVM Pymesh IPv6
|
||||
s - send message
|
||||
self - display all info about current node
|
||||
sleep - deep-sleep
|
||||
stop - close this CLI
|
||||
tx_pow - set LoRa TX power in dBm (2-20)
|
||||
ws - verifies if message sent was acknowledged
|
||||
```
|
||||
|
||||
### Debug commands
|
||||
|
||||
```
|
||||
>stop
|
||||
CLI stopped
|
||||
>>>
|
||||
```
|
||||
This command stops the CLI thread.
|
||||
|
||||
```
|
||||
> debug
|
||||
5
|
||||
```
|
||||
This sets the debug level. Possible values are:
|
||||
This command displays or sets the debug level. Possible values are:
|
||||
```
|
||||
# recommended debug levels, from the most verbose to off
|
||||
DEBUG_DEBG = const(5)
|
||||
@@ -57,6 +77,16 @@ DEBUG_CRIT = const(1)
|
||||
DEBUG_NONE = const(0)
|
||||
```
|
||||
|
||||
```
|
||||
>pause
|
||||
Pymesh pausing
|
||||
>resume
|
||||
Pymesh resuming
|
||||
```
|
||||
This pair of commands stops temporarily and resumes the Pymesh executing threads.
|
||||
|
||||
A possible application is to use LoRaWAN when Pymesh is paused. [An example is here](https://github.com/pycom/pycom-libraries/blob/master/pymesh/pymesh_frozen/lorawan/main.py).
|
||||
|
||||
```
|
||||
>rst
|
||||
Mesh Reset NVM settings ...
|
||||
|
||||
@@ -1,47 +1,50 @@
|
||||
---
|
||||
title: "Pymesh Library CLI"
|
||||
title: "Obtaining Pymesh"
|
||||
aliases:
|
||||
- pymesh/simple-example
|
||||
---
|
||||
|
||||
## Licensing process
|
||||
## Obtaining Pymesh
|
||||
|
||||
In order to receive access to the Pymesh firmware releases (for Lopy4, Fipy, L01 or L04), the next process should be followed:
|
||||
|
||||
1. Complete the <a href="/gitbook/assets/pymesh/Pymesh_Licence_Copyright_Notice.pdf" target="\_blank"> the Pymesh LICENCE PDF document</a>, sign it and send us by [this email](mailto:catalin@pycom.io?subject=[Pymesh_LICENCE]).
|
||||
1. You will receive by email an archive containing the images for all boards.
|
||||
1. Extract the corresponding image, for example Lopy4.tar.gz, and upload the firmware to your board, using the [Pycom Firmware Update Tool](https://pycom.io/downloads/), similar in the following image:
|
||||
<img src="/gitbook/assets/pymesh/pymesh_firmware_update.png" alt="Pymesh Firmware Update" width="500"/>
|
||||
In order to receive access to the Pymesh firmware releases (for Lopy4, Fipy, L01 or L04), please follow the steps from [Pybytes - Pymesh integration](/pybytes/pymeshintegration/).
|
||||
|
||||
## Test Pymesh firmware loading
|
||||
|
||||
### Method 1
|
||||
|
||||
The simplest way to check if the Pymesh class has been successfully installed is to try the following code, directly in REPL:
|
||||
The simplest way to check if the Pymesh class has been successfully instantiated (and started inside Pybytes) is to try the following code, directly in REPL:
|
||||
|
||||
```python
|
||||
>>> from network import LoRa
|
||||
>>> lora = LoRa(mode=LoRa.LORA)
|
||||
>>> mesh = lora.Mesh()
|
||||
# todo: add try/except for checking pybytes object exists
|
||||
>>> pymesh = pybytes.__pymesh.__pymesh
|
||||
>>> pymesh.cli_start()
|
||||
>h
|
||||
List of available commands
|
||||
br - enable/disable or display the current Border Router functionality
|
||||
brs - send packet for Mesh-external, to BR, if any
|
||||
buf - display buffer info
|
||||
config - print config file contents
|
||||
debug - set debug level
|
||||
gps - get/set location coordinates
|
||||
h - help, list of commands
|
||||
ip - display current IPv6 unicast addresses
|
||||
mac - set or display the current LoRa MAC address
|
||||
mml - display the Mesh Mac List (MAC of all nodes inside this Mesh), also inquires Leader
|
||||
mp - display the Mesh Pairs (Pairs of all nodes connections), also inquires Leader
|
||||
ot - sends command to openthread internal CLI
|
||||
pause - suspend Pymesh
|
||||
resume - resume Pymesh
|
||||
rm - verifies if any message was received
|
||||
rst - reset NOW, including NVM Pymesh IPv6
|
||||
s - send message
|
||||
self - display all info about current node
|
||||
sleep - deep-sleep
|
||||
stop - close this CLI
|
||||
tx_pow - set LoRa TX power in dBm (2-20)
|
||||
ws - verifies if message sent was acknowledged
|
||||
|
||||
```
|
||||
|
||||
### Method 2
|
||||
|
||||
Upload the `main.py` from the [Simple Example](/pymesh/simple-example).
|
||||
|
||||
## FAQ
|
||||
|
||||
Q: **I've received an error, such as `(LoadProhibited). Exception was unhandled.`, what should I do?**
|
||||
|
||||
A: In some cases, the NVM partition needs to be formatted. For this a format of whole Flash Memory should be performed.
|
||||
|
||||
This can be done using the cli version of the `Firmware Update Tool`, so please navigate where the app was installed (search for pycom-fwtool-cli executable) and execute:
|
||||
```
|
||||
pycom-fwtool-cli -p <PORT> erase_all
|
||||
```
|
||||
|
||||
`<PORT>` should be replaced with the actual USB COM port, for example:
|
||||
|
||||
* on Windows `COM10`
|
||||
* on Linux `/dev/ttyACM0`
|
||||
* on MacOS `/dev/tty.usbmodemPy8eaa911`
|
||||
|
||||
@@ -6,16 +6,19 @@ aliases:
|
||||
|
||||
## What is Pymesh micropython library?
|
||||
|
||||
The Pymesh Micropython library is a set of frozen scripts in the Pymesh firmware binary release.
|
||||
The Pymesh Micropython library is a set of frozen scripts in the Pymesh firmware binary release; the [open-source scripts are available on github](https://github.com/pycom/pycom-libraries/tree/master/pymesh/pymesh_frozen)
|
||||
|
||||
[Open-source on github](https://github.com/pycom/pycom-libraries/tree/master/pymesh/pymesh_frozen)
|
||||
|
||||
It allows users to access Pymesh in a few lines of code, as shown in the following code snippet.
|
||||
|
||||
Additionally, users can install the Pymesh mobile application which is available [here for both iOS and Android platforms](https://github.com/pycom/pycom-libraries/tree/master/pymesh/mobile_app). It allows users to connect over BLE to a Pymesh node and find out network information.
|
||||
If Pybytes is used, then Pymesh is already started and pymesh object can be obtained by simply using (`main-pybytes.py` from github):
|
||||
|
||||
```python
|
||||
|
||||
# todo: add try/except for checking pybytes object exists
|
||||
pymesh = pybytes.__pymesh.__pymesh
|
||||
```
|
||||
|
||||
If Pybytes is not used, then the Pymesh network has to be started manually. The is shown in the following code snippet (`main.py` from github):
|
||||
|
||||
```python
|
||||
import pycom
|
||||
import time
|
||||
|
||||
@@ -52,9 +55,7 @@ pymesh_config = PymeshConfig.read_config()
|
||||
#initialize Pymesh
|
||||
pymesh = Pymesh(pymesh_config, new_message_cb)
|
||||
|
||||
mac = pymesh.mac()
|
||||
# based on LoRa MAC address, some nodes could be forced to be
|
||||
# sleep-end-devices (always Child) or to have increased Leader priority
|
||||
# mac = pymesh.mac()
|
||||
# if mac > 10:
|
||||
# pymesh.end_device(True)
|
||||
# elif mac == 5:
|
||||
@@ -82,21 +83,24 @@ pymesh.send_mess(5, "Hello World")
|
||||
# pymesh.br_set(PymeshConfig.BR_PRIORITY_NORM, new_br_message_cb)
|
||||
|
||||
# remove Border Router function from current node
|
||||
#pymesh.br_remove()
|
||||
# pymesh.br_remove()
|
||||
|
||||
# send data for Mesh-external, basically to the BR
|
||||
# ip = "1:2:3::4"
|
||||
# port = 5555
|
||||
# pymesh.send_mess_external(ip, port, "Hello World")
|
||||
|
||||
print("done Pymesh init, forever loop, exit/stop with Ctrl+C multiple times")
|
||||
# set BR with callback
|
||||
print("done Pymesh init, CLI is started, h - help/command list, stop - CLI will be stopped")
|
||||
pymesh.cli_start()
|
||||
|
||||
# while True:
|
||||
# time.sleep(3)
|
||||
|
||||
while True:
|
||||
time.sleep(3)
|
||||
|
||||
```
|
||||
|
||||
Additionally, users can install the Pymesh mobile application which is available [here for both iOS and Android platforms](https://github.com/pycom/pycom-libraries/tree/master/pymesh/mobile_app). It allows users to connect over BLE to a Pymesh node and find out network information.
|
||||
|
||||
## Output
|
||||
|
||||
An example of possible output is below.
|
||||
|
||||
@@ -4,12 +4,41 @@ aliases:
|
||||
- pytrackpysense/introduction.html
|
||||
- pytrackpysense/introduction.md
|
||||
- chapter/pytrackpysense
|
||||
- expansion3/introduction.html
|
||||
- expansion3/introduction.md
|
||||
- chapter/expansion3
|
||||
disable_breadcrumbs: true
|
||||
---
|
||||
|
||||
In addition to the Expansion Board, Pycom also offers three additional sensor boards, which are ideal for quickly building a fully functioning IoT solution! Whether the application is environment sensing or asset tracking, these additional boards support a variety of sensors.
|
||||
In addition to the Expansion Board, Pycom also offers three additional types of sensor boards, which are ideal for quickly building a fully functioning IoT solution! Whether the application is environment sensing or asset tracking, these additional boards support a variety of sensors. New versions of the Pytrack and Pysense are now available with additional features:
|
||||
|
||||
## Pytrack
|
||||
## Pytrack 2.0 X
|
||||
|
||||
Pytrack 2.0 X is an improved location enabled version of the Expansion Board, intended for use in GPS applications such as asset tracking or monitoring.
|
||||
|
||||

|
||||
|
||||
## New Features on Pytrack 2.0 X
|
||||
|
||||
* External 6 pin connector to add new Pycom sensor range Pynodes. You can technically have upto 256 nodes connected in a daisy chain (data bus) although we are sure you would never reach that number
|
||||
* SMA connector for External active / passive GPS antennas when the built-in GPS antenna needs a boost!
|
||||
* circuity to enable full power down of module for hard resets without needing to put module in Deep sleep.
|
||||
* safeboot button for when things go wrong
|
||||
|
||||
## Pysense 2.0 X
|
||||
|
||||
Pysense 2.0 X is an improved sensor packed version of the Expansion Board, intended for use in environment sensing applications such as temperature, humidity monitoring, and light sensing.
|
||||
|
||||

|
||||
|
||||
## New Features on Pysense 2.0 X
|
||||
|
||||
* External 6 pin connector to add new Pycom sensor range Pynodes (Coming Soon!)
|
||||
* A new circuity to enable full power down of module for hard resets without needing to put module in Deep sleep.
|
||||
* Enhanced isolation of onboard sensors to improve reliability of sensor reporting.
|
||||
* New safeboot button for when things go wrong
|
||||
|
||||
## Pytrack 1
|
||||
|
||||
Pytrack is a location enabled version of the Expansion Board, intended for use in GPS applications such as asset tracking or monitoring.
|
||||
|
||||
@@ -20,18 +49,16 @@ Pytrack is a location enabled version of the Expansion Board, intended for use i
|
||||
The Pytrack is has a number of features including GPS, 3-Axis Accelerometer and Battery Charger. See the list below for detailed specifics about each sensor, including datasheets.
|
||||
|
||||
* Serial USB
|
||||
* 3-Axis Accelerometer ([LIS2HH12](/pytrackpysense/apireference/pytrack.md#3-axis-accelerometer-lis-2-hh-12))
|
||||
* 3-Axis Accelerometer ([LIS2HH12](apireference/pytrack.md#3-axis-accelerometer-lis-2-hh-12))
|
||||
* Battery Charger (BQ24040 with JST connector)
|
||||
* GPS and GLONASS ([L76-L](/pytrackpysense/apireference/pytrack.md#gps-with-glonass-quectel-l-76-l-gnss))
|
||||
* GPS and GLONASS ([L76-L](apireference/pytrack.md#gps-with-glonass-quectel-l-76-l-gnss))
|
||||
* MicroSD Card Reader
|
||||
|
||||
All of the included sensors are connected to the Pycom device via the I2C interface. These pins are located at `P22` (SDA) and `P21` (SCL).
|
||||
|
||||
You can find the datasheet and more info here:
|
||||
You can find the datasheet and more info here: {{% refname "../datasheets/boards/pytrack.md" %}}
|
||||
|
||||
{{% refname "/datasheets/boards/pytrack" %}}s
|
||||
|
||||
## Pysense
|
||||
## Pysense 1
|
||||
|
||||
Pysense is a sensor packed version of the Expansion Board, intended for use in environment sensing applications such as temperature, humidity monitoring, and light sensing.
|
||||
|
||||
@@ -51,9 +78,7 @@ The Pysense is packed with a number of sensors and hardware, see the list below
|
||||
|
||||
All of the included sensors are connected to the Pycom device via the I2C interface. These pins are located at `GPI09` (SDA) and `GPI08` (SCL).
|
||||
|
||||
You can find the datasheet and more info here:
|
||||
|
||||
{{% refname "../datasheets/boards/pysense.md" %}}
|
||||
You can find the datasheet and more info here: {{% refname "../datasheets/boards/pysense.md" %}}
|
||||
|
||||
## Pyscan
|
||||
|
||||
@@ -65,9 +90,9 @@ Pyscan is a RFID-NFC enabled version of the Expansion Board, intended for use in
|
||||
|
||||
The Pyscan is packed with a number of sensors and hardware, see the list below for detailed specifics about each sensor, including datasheets.
|
||||
|
||||
* 3-Axis Accelerometer ([LIS2HH12](/pytrackpysense/apireference/pyscan.md#3-axis-accelerometer-lis-2-hh-12))
|
||||
* Digital Ambient Light Sensor ([LTR-329ALS-01](/pytrackpysense/apireference/pyscan.md#digital-ambient-light-sensor-ltr-329-als-01))
|
||||
* RFID-NFC Chip ([MFRC63002HN](/pytrackpysense/apireference/pyscan.md#pyscan-nfc-library-mfrc-6300))
|
||||
* 3-Axis Accelerometer ([LIS2HH12](apireference/pyscan.md#3-axis-accelerometer-lis-2-hh-12))
|
||||
* Digital Ambient Light Sensor ([LTR-329ALS-01](apireference/pyscan.md#digital-ambient-light-sensor-ltr-329-als-01))
|
||||
* RFID-NFC Chip ([MFRC63002HN](apireference/pyscan.md#pyscan-nfc-library-mfrc-6300))
|
||||
* Serial USB
|
||||
* Battery Charger (BQ24040 with JST connector)
|
||||
* MicroSD Card Reader
|
||||
@@ -75,6 +100,4 @@ The Pyscan is packed with a number of sensors and hardware, see the list below f
|
||||
|
||||
All of the included sensors are connected to the Pycom device via the I2C interface. These pins are located at `P22` (SDA) and `P21` (SCL).
|
||||
|
||||
You can find the datasheet and more info here:
|
||||
|
||||
{{% refname "../datasheets/boards/pyscan.md" %}}
|
||||
You can find the datasheet and more info here: {{% refname "../datasheets/boards/pyscan.md" %}}
|
||||
|
||||
@@ -5,3 +5,7 @@ aliases:
|
||||
|
||||
To simplify usability, APIs for the libraries have been created, abstracting away the low level interactions with the sensors. The next following pages refer to the respective libraries for the Pytrack, Pysense, and Pyscan.
|
||||
|
||||
{{% 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 %}}
|
||||
|
||||
128
content/pytrackpysense/apireference/pysense2.md
Normal file
@@ -0,0 +1,128 @@
|
||||
---
|
||||
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.
|
||||
|
||||
## 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 %}}
|
||||
84
content/pytrackpysense/apireference/pytrack2.md
Normal file
@@ -0,0 +1,84 @@
|
||||
---
|
||||
title: "Pytrack 2.0 X"
|
||||
aliases:
|
||||
- pytrackpysense/apireference/pytrack2.html
|
||||
- pytrackpysense/apireference/pytrack2.md
|
||||
- chapter/pytrackpysense/apireference/pytrack2
|
||||
---
|
||||
|
||||
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.
|
||||
|
||||
## 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.
|
||||
|
||||
#### 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`. This function should only be used if advised by Pycom for a specific purpose.
|
||||
|
||||
## Pytrack class to control supervisor MCU
|
||||
|
||||
### Constructors
|
||||
|
||||
#### class Pytrack(i2c=None, sda='P22', scl='P21')
|
||||
|
||||
Initialise I2C communication with the supervisor MCU
|
||||
|
||||
### Methods
|
||||
|
||||
#### Pytrack.sd_power(enabled=True)
|
||||
|
||||
This command allows switching the power supply for the SD card (VCC + PullUP resistors).
|
||||
|
||||
#### Pytrack.sensor_power(enabled=True)
|
||||
|
||||
This command allows switching the power supply for the GPS module and any sensors connected through the external 6-pin connector.
|
||||
|
||||
#### Pytrack.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.
|
||||
|
||||
|
||||
{{% hint style="info" %}}
|
||||
Please note that more functionality is being added regularly 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 %}}
|
||||
@@ -5,3 +5,7 @@ aliases:
|
||||
|
||||
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 %}}
|
||||
|
||||
@@ -6,7 +6,7 @@ aliases:
|
||||
- chapter/pytrackpysense/installation/drivers
|
||||
---
|
||||
|
||||
Pytrack and Pysense will work out of the box for Windows 8/10/+, macOS as well as Linux. If using Windows 7, drivers to support the boards will need to be installed.
|
||||
Pytrack and Pysense will work out of the box for Windows 8/10/+ (please download the correct driver through Windows Update), macOS as well as Linux. If using Windows 7, drivers to support the boards will need to be installed.
|
||||
|
||||
Please follow the instructions below to install the required drivers.
|
||||
|
||||
@@ -14,7 +14,9 @@ Please follow the instructions below to install the required drivers.
|
||||
|
||||
Please download the driver software from the link below.
|
||||
|
||||
[Pytrack/Pysense/Pyscan/Expansion Board 3 Driver](https://docs.pycom.io/pytrackpysense/installation/pycom.inf)
|
||||
[Unsigned driver for Windows 7 compatible with Pycom products](/gitbook/assets/pycom.inf.zip)
|
||||
Please note that this driver is not suitable for the Expansion Board 1 & 2.
|
||||
As these drivers are not signed, you may need to disable driver signing enforcement in your Windows operating system.
|
||||
|
||||
## Installation
|
||||
|
||||
|
||||
@@ -8,10 +8,14 @@ aliases:
|
||||
|
||||
To update the firmware on the Pysense/Pytrack/Pyscan/Expansion Board v3, please see the following instructions. The firmware of Pysense/Pytrack/Pyscan/Expansion Board v3 can be updated via the USB port using the terminal tool, `DFU-util`.
|
||||
|
||||
{{% hint style="danger" %}}
|
||||
There is currently **no firmware update** released for the new **Pytrack 2.0 X** and **Pysense 2.0 X**. Please do not try to flash these boards with firmware released for the old Version 1 hardware revision. The hardware revision is printed on the bottom of the shield.
|
||||
{{% /hint %}}
|
||||
|
||||
The latest firmware DFU file can be downloaded from the links below:
|
||||
|
||||
* [Pytrack DFU](https://software.pycom.io/findupgrade?key=pytrack.dfu&type=all&redirect=true)
|
||||
* [Pysense DFU](https://software.pycom.io/findupgrade?key=pysense.dfu&type=all&redirect=true)
|
||||
* [Pytrack 1 DFU](https://software.pycom.io/findupgrade?key=pytrack.dfu&type=all&redirect=true)
|
||||
* [Pysense 1 DFU](https://software.pycom.io/findupgrade?key=pysense.dfu&type=all&redirect=true)
|
||||
* [Expansion Board DFU v3.0](https://software.pycom.io/findupgrade?key=expansion3.dfu&type=all&redirect=true)
|
||||
* [Expansion Board DFU v3.1](https://software.pycom.io/findupgrade?key=expansion31.dfu&type=all&redirect=true)
|
||||
|
||||
@@ -160,4 +164,3 @@ For exemple, a Pytrack board is visible as either:
|
||||
* this is bootloader mode (`f014` is USB PID), active just for 7-8 seconds, if the reset button was just pressed before plugging USB connector.
|
||||
* `Bus 020 Device 005: ID 04d8:f013 Microchip Technology Inc. Pytrack Serial: Pyabcde0`
|
||||
* this is normal, application mode (`f013` is USB PID), this means the bootloader verified application partition and it boot-up correctly.
|
||||
|
||||
|
||||
@@ -10,11 +10,16 @@ To utilise the sensors on the Pytrack and Pysense, Pycom has written libraries t
|
||||
|
||||
[GitHub Repository](https://github.com/pycom/pycom-libraries)
|
||||
|
||||
{{% 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 %}}
|
||||
|
||||
Download the repository as a `.zip` file, navigate to the correct device (Pysense/Pytrack), extract the files and then upload the desired files to the device in the instructions below.
|
||||
|
||||
## Uploading the Libraries to a Device
|
||||
|
||||
These libraries should be uploaded to a device (LoPy, SiPy, WiPy 2.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. 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:
|
||||
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. 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:
|
||||
|
||||
```text
|
||||
- pysense.py
|
||||
@@ -24,7 +29,7 @@ These libraries should be uploaded to a device (LoPy, SiPy, WiPy 2.0, etc.) in t
|
||||
|
||||
Add as many or as few of the libraries that are required.
|
||||
|
||||
In addition to the Pysense or Pytrack specific libraries, you also need to upload the `pycoproc.py` file from the `_lib/pycoproc_` folder inside the libraries archive.
|
||||
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.
|
||||
|
||||
{{% 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.
|
||||
@@ -44,4 +49,3 @@ lt = LTR329ALS01(py)
|
||||
|
||||
print(lt.light())
|
||||
```
|
||||
|
||||
|
||||
@@ -6,9 +6,35 @@ aliases:
|
||||
- chapter/pytrackpysense
|
||||
---
|
||||
|
||||
In addition to the Expansion Board, Pycom also offers three additional sensor boards, which are ideal for quickly building a fully functioning IoT solution! Whether the application is environment sensing or asset tracking, these additional boards support a variety of sensors.
|
||||
In addition to the Expansion Board, Pycom also offers three additional types of sensor boards, which are ideal for quickly building a fully functioning IoT solution! Whether the application is environment sensing or asset tracking, these additional boards support a variety of sensors. New versions of the Pytrack and Pysense are now available with additional features:
|
||||
|
||||
## Pytrack
|
||||
## Pytrack 2.0 X
|
||||
|
||||
Pytrack 2.0 X is an improved location enabled version of the Expansion Board, intended for use in GPS applications such as asset tracking or monitoring.
|
||||
|
||||

|
||||
|
||||
## New Features on Pytrack 2.0 X
|
||||
|
||||
* External 6 pin connector to add new Pycom sensor range Pynodes. You can technically have upto 256 nodes connected in a daisy chain (data bus) although we are sure you would never reach that number
|
||||
* SMA connector for External active / passive GPS antennas when the built-in GPS antenna needs a boost!
|
||||
* circuity to enable full power down of module for hard resets without needing to put module in Deep sleep.
|
||||
* safeboot button for when things go wrong
|
||||
|
||||
## Pysense 2.0 X
|
||||
|
||||
Pysense 2.0 X is an improved sensor packed version of the Expansion Board, intended for use in environment sensing applications such as temperature, humidity monitoring, and light sensing.
|
||||
|
||||

|
||||
|
||||
## New Features on Pysense 2.0 X
|
||||
|
||||
* External 6 pin connector to add new Pycom sensor range Pynodes (Coming Soon!)
|
||||
* A new circuity to enable full power down of module for hard resets without needing to put module in Deep sleep.
|
||||
* Enhanced isolation of onboard sensors to improve reliability of sensor reporting.
|
||||
* New safeboot button for when things go wrong
|
||||
|
||||
## Pytrack 1
|
||||
|
||||
Pytrack is a location enabled version of the Expansion Board, intended for use in GPS applications such as asset tracking or monitoring.
|
||||
|
||||
@@ -26,11 +52,9 @@ The Pytrack is has a number of features including GPS, 3-Axis Accelerometer and
|
||||
|
||||
All of the included sensors are connected to the Pycom device via the I2C interface. These pins are located at `P22` (SDA) and `P21` (SCL).
|
||||
|
||||
You can find the datasheet and more info here:
|
||||
You can find the datasheet and more info here: {{% refname "../datasheets/boards/pytrack.md" %}}
|
||||
|
||||
{{% refname "../datasheets/boards/pytrack.md" %}}
|
||||
|
||||
## Pysense
|
||||
## Pysense 1
|
||||
|
||||
Pysense is a sensor packed version of the Expansion Board, intended for use in environment sensing applications such as temperature, humidity monitoring, and light sensing.
|
||||
|
||||
@@ -50,9 +74,7 @@ The Pysense is packed with a number of sensors and hardware, see the list below
|
||||
|
||||
All of the included sensors are connected to the Pycom device via the I2C interface. These pins are located at `GPI09` (SDA) and `GPI08` (SCL).
|
||||
|
||||
You can find the datasheet and more info here:
|
||||
|
||||
{{% refname "../datasheets/boards/pysense.md" %}}
|
||||
You can find the datasheet and more info here: {{% refname "../datasheets/boards/pysense.md" %}}
|
||||
|
||||
## Pyscan
|
||||
|
||||
|
||||
@@ -2,23 +2,33 @@
|
||||
|
||||
The Pygate is an 8-channel LoRaWAN gateway. This page will help you get started with it.
|
||||
|
||||
The Pygate board can have an PyEthernet adapter connected which allows an ethernet connection. The PyEthernet also support PoE. Do check the separate [page and warning for PoE-NI!](/tutorials/all/poe)
|
||||
{{% hint style="info" %}}
|
||||
While the Pygate shield has the radio chips required to act as a LoRaWAN gateway, it will require a WiPy3, GPy or LoPy4 to run the LoRaWAN gateway software and provide connectivity to the LoRaWAN server (TTN / ChirpStack etc.) via WiFi, Ethernet (with the optional PyEthernet adapter) or LTE-M (a GPy with a mobile subscription is required for LTE-M connectivity).
|
||||
{{% /hint %}}
|
||||
|
||||
A USB connection is recommended for the initial firmware update of the Pycom development module (WiPy 3, GPy, LoPy4) and to upload the configuration & start-up script. The module can be updated over the air via WiFi / LTE-M (depending on network capabilities) or via Ethernet connection which allows installation of the gateway in remote locations.
|
||||
|
||||
The Pygate board can have the PyEthernet adapter connected which allows an Ethernet connection. The PyEthernet also supports PoE. Please check the separate [page and warning for PoE-NI!](/tutorials/all/poe)
|
||||
|
||||
### Quickstart
|
||||
|
||||
To connect your Pygate to a LoRa server, follow these steps:
|
||||
To connect your Pygate to a LoRa server, please follow these steps:
|
||||
|
||||
1. Attach a WiPy, GPy or LoPy4 to the Pygate. The RGB LED of the development board should be aligned with the USB port of the Pygate.
|
||||
1. Attach a WiPy 3, GPy or LoPy 4 to the Pygate. The RGB LED of the development board should be aligned with the USB port of the Pygate.
|
||||
1. Attach the LoRa Antenna to the Pygate.
|
||||
1. Flash the Pycom Device with with a firmware build where Pygate functionality is enabled.
|
||||
1. Create a `config.json` for your Pygate and upload it.
|
||||
1. Create a `main.py` that creates an uplink (wifi, ethernet or lte) and runs the LoRa packet fowarder.
|
||||
1. Run the `main.py`.
|
||||
1. Now it is operational. The communication from other LoRa nodes such as a LoPy4 will now reach the gateway and will receive up and downlink via the PyGate.
|
||||
1. Flash the Pycom Device with with a firmware build where Pygate functionality is enabled. In the firmware update tool, please choose pygate as the firmware type.
|
||||
1. Create a `config.json` for your Pygate and upload it (please check the template further below).
|
||||
1. Create a `main.py` that creates an uplink (wifi, ethernet or lte) and runs the LoRa packet forwarder (see example below).
|
||||
1. Run the `main.py`. This file is automatically execute every time the module resets.
|
||||
1. Now it is operational. The communication from other LoRa nodes such as a LoPy4 will now reach the gateway and will receive up and downlink messages via the PyGate.
|
||||
1. To stop the Pygate at any time press Ctrl-C on the REPL and run `machine.pygate_deinit()`. It will take a few seconds to stop the gateway tasks and safely power-off the concentrator.
|
||||
|
||||
|
||||
Make sure you supply a config matching your region (EU868, US915, etc), e.g. https://github.com/Lora-net/packet_forwarder/tree/master/lora_pkt_fwd/cfg. If you are in EU region, it should be sufficent to update the example below with your GW ID, the LoRa server address and port number.
|
||||
Make sure you supply a config matching your region (EU868, US915, etc), e.g. https://github.com/Lora-net/packet_forwarder/tree/master/lora_pkt_fwd/cfg. If you are in EU region, it should be sufficient to update the example below with your GW ID, the LoRa server address and port number.
|
||||
|
||||
{{% hint style="info" %}}
|
||||
**Note** Running the LoRa gateway on a GPy can get you close to the memory limit of the device. To avoid running out of memory one should not *run* the WiFi task and the LTE task at the same time. This shouldn't really restrict your use of the Pygate, since you wouldn't be *using* WiFi and LTE at the same time. The tasks *run* when you explicitly initialize them with ``wlan = WLAN()`` or ``lte = LTE()``, or when they get automatically started upon boot based on the settings ``pycom.wifi_on_boot(True)`` or ``pycom.lte_modem_en_on_boot(True)``. Bottom line, if you have trouble starting the LoRa packet forwarder, please double check these settings and make sure at least the network that you don't use is not automatically started.{{% /hint %}}
|
||||
|
||||
|
||||
|
||||
### Example TTN Wifi
|
||||
@@ -6,17 +6,89 @@ aliases:
|
||||
- chapter/tutorials/all/PoE
|
||||
---
|
||||
|
||||
The PyEthernet module has onboard Power over Ethernet (PoE) power supply. This means that you can power your hardware with only an ethernet cable coming from a power injector. However, since the PoE is non-isolated, you must adhere to the following warning!
|
||||
|
||||
WARNING:
|
||||
|
||||
PoE power supply of PyEthernet module has no galvanic isolation. This means, that in accordance with
|
||||
IEEE 802.3-2005 standard you must make sure that when powered from PoE power injector there are no other external connections to any part of the module or other hardware where it is installed. Such as USB cable, serial to USB bridge, logic analyser, an oscilloscope, etc.
|
||||
|
||||
As in certain hardware configurations it can lead to unrecoverable damage of not only the PyEthernet module but all hardware connected to it.
|
||||
|
||||
Be aware - violation of that requirement voids Pycom warranty.
|
||||
|
||||
The use of battery with PoE is allowed.
|
||||
|
||||

|
||||
|
||||
The PyEthernet module offers an optional onboard Power over Ethernet (PoE) power supply circuit. This means that you can power your hardware with only an ethernet cable coming from a power injector or PoE enabled Ethernet switch. However, since the PoE is non-isolated, you must adhere to the following warning!
|
||||
|
||||
{{% hint style="danger" %}}
|
||||
WARNING: Before you use the PoE adapter for the first time, please make sure you read and follow the below instructions as failure to do so might damanage your devices!
|
||||
{{% /hint %}}
|
||||
|
||||
The PoE power supply integrated in the PyEthernet module with UPC code 604565285911 has no galvanic isolation. This means that in accordance with
|
||||
IEEE 802.3-2005 standard, you must <b>NOT</b> connect any other devices / cables / chargers if the GND connection is connected to mains earth!
|
||||
This is typically the case with PCs, Oscilloscopes, Logic Analysers, current consumption measurement devices etc.
|
||||
|
||||
Incorrect usages of Power over Ethernet can lead to unrecoverable damage of not only the PyEthernet module but all hardware connected to it.
|
||||
|
||||
A battery can be connected to the PyGate without issues. The battery can be charged either via USB-C or PoE power.
|
||||
|
||||
|
||||
<h3>Setup Options</h3>
|
||||
|
||||
<h4> Power over Ethernet</h4>
|
||||

|
||||
|
||||
<div class="poe-table">
|
||||
<table class="poe">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td> USB-C cable connected to a PC <b>with</b> mains ground protection</td>
|
||||
<td class="poe-red">NOT OK</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td> USB-C cable connected to a Notebook <b>without</b> mains ground protection</td>
|
||||
<td class="poe-green"> OK</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td> USB-C charger <b>with</b> mains ground protection</td>
|
||||
<td class="poe-red"> NOT OK</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td> USB-C charger <b>without</b> mains ground protection</td>
|
||||
<td class="poe-green"> OK</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td> Oscilloscope / Logic Analyser / Other equipment <b>with</b> mains ground protection</td>
|
||||
<td class="poe-red"> NOT OK</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td> Battery</td>
|
||||
<td class="poe-green"> OK</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<br><br>
|
||||
<h4> Power over USB-C or external supply</h4>
|
||||

|
||||
<div class="poe-table">
|
||||
<table class="poe">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td> USB-C cable connected to a PC <b>with</b> mains ground protection</td>
|
||||
<td class="poe-green">OK</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td> USB-C cable connected to a Notebook <b>without</b> mains ground protection</td>
|
||||
<td class="poe-green"> OK </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td> USB-C charger <b>with</b> mains ground protection</td>
|
||||
<td class="poe-green"> OK </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td> USB-C charger <b>without</b> mains ground protection</td>
|
||||
<td class="poe-green"> OK </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td> Oscilloscope / Logic Analyser / Other equipment <b>with</b> mains ground protection</td>
|
||||
<td class="poe-green"> OK </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td> Battery</td>
|
||||
<td class="poe-green"> OK </td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
@@ -6,12 +6,22 @@ aliases:
|
||||
- chapter/tutorials/lora/lorawan-otaa
|
||||
---
|
||||
|
||||
OTAA stands for Over The Air Authentication. With this method the LoPy sends a Join request to the LoRaWAN Gateway using the `APPEUI` and `APPKEY` provided. If the keys are correct the Gateway will reply to the LoPy with a join accept message and from that point on the LoPy is able to send and receive packets to/from the Gateway. If the keys are incorrect no response will be received and the `has_joined()` method will always return `False`.
|
||||
OTAA stands for Over The Air Authentication. With this method the LoPy sends a Join request to the LoRaWAN Gateway using the `app_eui` and `app_key` provided in your LoRaWAN application (Like TheThingsNetwork, Chirpstack etc.). If the keys are correct the Gateway will reply to the LoPy with a join accept message and from that point on the LoPy is able to send and receive packets to/from the Gateway. If the keys are incorrect no response will be received and the `has_joined()` method will always return `False`.
|
||||
|
||||
The example below attempts to get any data received after sending the frame. Keep in mind that the Gateway might not be sending any data back, therefore we make the socket non-blocking before attempting to receive, in order to prevent getting stuck waiting for a packet that will never arrive.
|
||||
|
||||
```python
|
||||
If everything works correctly, the device will print `Joined` to the terminal, and you should see a data packet arrive in your LoRaWAN application containing `0x01 0x02 0x03`
|
||||
|
||||
|
||||
Note: if the `dev_eui` it is not provided, the LoRa MAC of the device will be used in its place. You will need to change the `dev_eui` in your LoRaWAN application to the LoRa MAC address of the device. You can get the LoRa MAC using:
|
||||
```python
|
||||
from network import LoRa
|
||||
import binascii
|
||||
print(binascii.hexlify(LoRa().mac()).upper())
|
||||
```
|
||||
|
||||
|
||||
```python
|
||||
from network import LoRa
|
||||
import socket
|
||||
import time
|
||||
@@ -25,18 +35,23 @@ import ubinascii
|
||||
# United States = LoRa.US915
|
||||
lora = LoRa(mode=LoRa.LORAWAN, region=LoRa.EU868)
|
||||
|
||||
# create an OTAA authentication parameters
|
||||
# create an OTAA authentication parameters, change them to the provided credentials
|
||||
app_eui = ubinascii.unhexlify('ADA4DAE3AC12676B')
|
||||
app_key = ubinascii.unhexlify('11B0282A189B75B0B4D2D8C7FA38548B')
|
||||
#uncomment to use LoRaWAN application provided dev_eui
|
||||
#dev_eui = ubinascii.unhexlify('70B3D549938EA1EE')
|
||||
|
||||
# join a network using OTAA (Over the Air Activation)
|
||||
#uncomment below to use LoRaWAN application provided dev_eui
|
||||
lora.join(activation=LoRa.OTAA, auth=(app_eui, app_key), timeout=0)
|
||||
#lora.join(activation=LoRa.OTAA, auth=(dev_eui, app_eui, app_key), timeout=0)
|
||||
|
||||
# wait until the module has joined the network
|
||||
while not lora.has_joined():
|
||||
time.sleep(2.5)
|
||||
print('Not yet joined...')
|
||||
|
||||
print('Joined')
|
||||
# create a LoRa socket
|
||||
s = socket.socket(socket.AF_LORA, socket.SOCK_RAW)
|
||||
|
||||
@@ -58,4 +73,3 @@ s.setblocking(False)
|
||||
data = s.recv(64)
|
||||
print(data)
|
||||
```
|
||||
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
---
|
||||
title: "LTE Examples"
|
||||
aliases:
|
||||
- chapter/tutorials/lte
|
||||
---
|
||||
|
||||
The following tutorials demonstrate the use of the LTE CAT-M1 and NB-IoT functionality on cellular enabled Pycom modules.
|
||||
|
||||
Our cellular modules support both LTE CAT-M1 and NB-IoT, these are new lower power, long range, cellular protocols. These are not the same as the full version of 2G/3G/LTE supported by cell phones, and require your local carriers to support them. At the time of writing, CAT-M1 and NB-IoT connectivity is not widely available so be sure to check with local carriers if support is available where you are.
|
||||
|
||||
|
||||
BIN
static/gitbook/assets/PySense2X_specsheet.pdf
Normal file
BIN
static/gitbook/assets/PyTrack2X_specsheet.pdf
Normal file
BIN
static/gitbook/assets/Pysense_v2.0X_MechanicalDimensions.png
Normal file
|
After Width: | Height: | Size: 232 KiB |
BIN
static/gitbook/assets/Pytrack_v2.0X_MechanicalDimensions.png
Normal file
|
After Width: | Height: | Size: 340 KiB |
BIN
static/gitbook/assets/poe-ni-warn1.png
Normal file
|
After Width: | Height: | Size: 102 KiB |
BIN
static/gitbook/assets/poe-ni-warn2.png
Normal file
|
After Width: | Height: | Size: 97 KiB |
BIN
static/gitbook/assets/pycom.inf.zip
Normal file
|
Before Width: | Height: | Size: 53 KiB After Width: | Height: | Size: 177 KiB |
|
Before Width: | Height: | Size: 1.4 MiB After Width: | Height: | Size: 105 KiB |
BIN
static/gitbook/assets/pysense2-pinout.pdf
Normal file
BIN
static/gitbook/assets/pysense2-pinout.png
Normal file
|
After Width: | Height: | Size: 174 KiB |
BIN
static/gitbook/assets/pysense20X.png
Normal file
|
After Width: | Height: | Size: 158 KiB |
BIN
static/gitbook/assets/pysense2_desc.png
Normal file
|
After Width: | Height: | Size: 570 KiB |
3294
static/gitbook/assets/pysense_v2.0X.step
Normal file
|
Before Width: | Height: | Size: 1.4 MiB After Width: | Height: | Size: 152 KiB |
BIN
static/gitbook/assets/pytrack2-pinout.pdf
Normal file
BIN
static/gitbook/assets/pytrack2-pinout.png
Normal file
|
After Width: | Height: | Size: 311 KiB |
BIN
static/gitbook/assets/pytrack20X.png
Normal file
|
After Width: | Height: | Size: 153 KiB |
BIN
static/gitbook/assets/pytrack2_decs.png
Normal file
|
After Width: | Height: | Size: 573 KiB |
4017
static/gitbook/assets/pytrack_v2.0X.step
Normal file
@@ -359,3 +359,28 @@ img[src="/gitbook/assets/pybytes/lora/ttn_logo.svg"]{
|
||||
img[src*="/gitbook/assets/pybytes/pymesh/"]{
|
||||
width: 70%;
|
||||
}
|
||||
|
||||
/* PoE table */
|
||||
.poe-table {
|
||||
width:80%;
|
||||
display:table;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
table.poe td:nth-child(1){
|
||||
font-weight: 400;
|
||||
}
|
||||
|
||||
table.poe td:nth-child(2){
|
||||
text-align:center;
|
||||
font-weight: 600;
|
||||
width:100px;
|
||||
}
|
||||
|
||||
table.poe .poe-red {
|
||||
background-color: #EF9A9A !important;
|
||||
}
|
||||
|
||||
table.poe .poe-green {
|
||||
background-color: #c5eee3 !important;
|
||||
}
|
||||
|
||||