diff --git a/config.toml b/config.toml index 2827cef..258ead5 100644 --- a/config.toml +++ b/config.toml @@ -329,7 +329,13 @@ theme = "doc-theme" parent = "tutorials@networkprotocols" weight = 10 [[menu.main]] - name = "HTTP Webserver" + name = "HTTP Client" + url = "/tutorials/networkprotocols/httpclient/" + identifier = "tutorials@networkprotocols@httpclient" + parent = "tutorials@networkprotocols" + weight = 12 +[[menu.main]] + name = "HTTP Server" url = "/tutorials/networkprotocols/webserver/" identifier = "tutorials@networkprotocols@webserver" parent = "tutorials@networkprotocols" @@ -364,6 +370,12 @@ theme = "doc-theme" identifier = "tutorials@networkprotocols@socket" parent = "tutorials@networkprotocols" weight = 50 +[[menu.main]] + name = "WiFi Sniffer" + url = "/tutorials/networkprotocols/wifisniffer/" + identifier = "tutorials@networkprotocols@wifisniffer" + parent = "tutorials@networkprotocols" + weight = 60 [[menu.main]] name = "Expansion Boards" @@ -407,6 +419,12 @@ theme = "doc-theme" identifier = "tutorials@expansionboards@pyscan" parent = "tutorials@expansionboards" weight = 60 +[[menu.main]] + name = "Sleep" + url = "/tutorials/expansionboards/sleep/" + identifier = "tutorials@expansionboards@sleep" + parent = "tutorials@basic" + weight = 20 [[menu.main]] name = "Advanced" url = "/tutorials/advanced/" @@ -985,13 +1003,6 @@ theme = "doc-theme" parent = "datasheets@oem" weight = 60 -[[menu.main]] - name = "OEM Deepsleep" - url = "/datasheets/oem/deepsleep/" - identifier = "datasheets@oem@deepsleep" - parent = "datasheets@oem" - weight = 70 - [[menu.main]] name = "Expansion Boards and Shields" url = "/datasheets/expansionboards/" @@ -1086,6 +1097,7 @@ theme = "doc-theme" identifier = "updatefirmware@device" parent= "updatefirmware" weight = 10 + [[menu.main]] name = "Device (OTA)" url = "/updatefirmware/OTA/" @@ -1093,6 +1105,13 @@ theme = "doc-theme" parent= "updatefirmware" weight = 20 +[[menu.main]] + name = "Device (Differential OTA)" + url = "/updatefirmware/diff_ota/" + identifier = "updatefirmware@diff_ota" + parent= "updatefirmware" + weight = 25 + [[menu.main]] name = "Expansion Board" url = "/updatefirmware/expansionboard/" diff --git a/content/advance/coredump.md b/content/advance/coredump.md new file mode 100644 index 0000000..48b97ce --- /dev/null +++ b/content/advance/coredump.md @@ -0,0 +1,63 @@ +--- +title: "Troubleshooting Coredumps" + +--- + + +It is never nice when a project coredumps. With this tool. you might be able to figure out why it coredumps and what you can do about it. + +>Note that some coredumps are not caused by the Python or C code, but by instability of the microcontroller. For example, supplying not enough power or ... will also generate a coredump. + +1. Install the ESP-IDF toolchain. You can find instructions [here](https://docs.espressif.com/projects/esp-idf/en/latest/esp32/get-started/index.html#get-started-get-esp-idf). If you already built our firmware from source once, you do not need to install the idf again. +2. This will provide us with a tool called `addr2line`, which converts the stacktrace addresses to a line number in C sourcecode. From here, we might be able to determine the root cause of the coredump. You can find the tool in `../xtensa-esp32-elf/bin/xtensa-esp32-elf-addr2line`. + >Note: This is a command line tool only. +3. Grab the .elf for your firmware version and board type [here](https://github.com/pycom/pycom-micropython-sigfox/releases). From here on, we will call it `application.elf` + > If you do not know your current firmware version, you can check it using: + > ```python + > >>> import os + > >>> os.uname() + > ``` + +4. Wait for your running code to coredump. I attached an example here. We are only interested in the top section. + ``` + Guru Meditation Error: Core 0 panic'ed (StoreProhibited). Exception was unhandled. + Core 0 register dump: + PC : 0x40195846 PS : 0x00060530 A0 : 0x801952fb A1 : 0x3ffbaef0 + A2 : 0x00000000 A3 : 0x00000000 A4 : 0x00000005 A5 : 0xffffffff + A6 : 0x0000336d A7 : 0x3ffba1c4 A8 : 0x80194d84 A9 : 0x3ffbaeb0 + A10 : 0x00000028 A11 : 0x00000000 A12 : 0x3ffb9f28 A13 : 0x00000000 + A14 : 0x3ffb9f38 A15 : 0x00000001 SAR : 0x00000000 EXCCAUSE: 0x0000001d + EXCVADDR: 0x0000002d LBEG : 0x40093718 LEND : 0x40093746 LCOUNT : 0xffffffff + + ELF file SHA256: 0000000000000000000000000000000000000000000000000000000000000000 + + Backtrace: 0x40195846:0x3ffbaef0 0x401952f8:0x3ffbaf10 0x40184fe8:0x3ffbaf30 + + ================= CORE DUMP START ================= + hDEAAAEAAAAOAAAAbAEAAA== + tJ/7PzCu+z/Er/s/ + 0K37P2Cv+z/MMwAAEMj8PxDI/D+0n/s/CMj8PwcAAAAIn/s/CJ/7P7Sf+z8AAAAA + EgAAAMih+z90aVQA6MX8P7x9+z/EffsAAAAAAMSv+z8AAAAAIAcGABIAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAADUZPs/PGX7P6Rl+z8AAAAAAAAAAAEAAAAAAAAA + OsRAPwAAAAAoUAlAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + ... + ``` + +5. Navigate terminal to the folder where your `application.elf` file is located. From there, use the following command. replace `[backtrace]` with the numbers following the `Backtrace:` in the coredump. + ```python + xtensa-esp32-elf-addr2line -fe [application.elf] [backtrace] + ``` + > In this case, the backtrace is `0x40195846:0x3ffbaef0 0x401952f8:0x3ffbaf10 0x40184fe8:0x3ffbaf30` + +6. The output of this command will give you the files and line numbers of the last ran commands (`stack trace`), where the last command will have caused the error. + +> More Advanced \ +> You can also use the `xtensa-esp32-elf-gdb` tool in the command line, which will return where in the code the processor crashed. You can use: +> * `info symbol [PC]` (where `[PC]` is the program counter found in the coredump) to get the section of the line that causes the coredump +> * `disassemble [PC]` to get the instructions of the specified line in assemble format. + +## Common errors and solutions + diff --git a/content/advance/downgrade.md b/content/advance/downgrade.md index 828b314..605ff03 100644 --- a/content/advance/downgrade.md +++ b/content/advance/downgrade.md @@ -8,11 +8,12 @@ aliases: 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. -{{% hint style="info" %}} -If you are using an Expansion Board 1.0 or 2.0, you will need to have a jumper connected between `G23` and `GND` to use either procedure below. You will also need to press the reset button before beginning. -{{% /hint %}} +Here you can download Pycom firmwares. Note that these are all available in the Pycom Firmware Update tool. -Here you can download Pycom firmware: +### Current and previous Pygate firmware +* [WiPy](https://software.pycom.io/downloads/pygate/WiPy.html) +* [GPy](https://software.pycom.io/downloads/pygate/GPy.html) +* [LoPy4](https://software.pycom.io/downloads/pygate/LoPy4.html) ### Current and previous Pybytes firmware @@ -32,19 +33,12 @@ Here you can download Pycom firmware: * [FiPy](https://software.pycom.io/downloads/FiPy.html) * [LoPy4](https://software.pycom.io/downloads/LoPy4.html) -{{% hint style="info" %}} -Prior to version `1.16.0.b1` the firmware for modules with LoRa functionality was frequency specific. From `1.16.0.b1` and onward, the firmware is region agnostic and this can either be set programatically or via the config block (see [here](../cli.md#lpwan)). -{{% /hint %}} +> Prior to version `1.16.0.b1` the firmware for modules with LoRa functionality was frequency specific. From `1.16.0.b1` and onward, the firmware is region agnostic and this can either be set programatically or via the config block (see [here](../cli.md#lpwan)). + ## GUI -As of version `1.12.0.b0` of the firmware update tool, you can now provide a `.tar` or `.tar.gz` archive of the firmware you wish to upload to the board. - -When you start the update tool you will see the following screen: - -![](/gitbook/assets/downgrade_gui.png) - -When you tick the `Flash from local file` option, an address bar will appear. Click the `...` button and locate the `.tar(.gz)` file with the firmware you wish to flash to your device. From this point the updater will behave just like a regular update but using the local file instead of downloading the latest. +As of version `1.12.0.b0` of the firmware update tool, you can now provide a `.tar` or `.tar.gz` archive of the firmware you wish to upload to the board. Check out the procedure [here](/updatefirmware/device/) ## Command line diff --git a/content/advance/troubleshooting.md b/content/advance/troubleshooting.md new file mode 100644 index 0000000..49f8269 --- /dev/null +++ b/content/advance/troubleshooting.md @@ -0,0 +1,143 @@ +--- +title: "Updating Expansion Board Firmware " +aliases: + - updatefirmware/expansionboard.html + - updatefirmware/expansionboard.md + - chapter/updatefirmware/expansionboard +--- + +## Not showing up in Pymakr + +### Step 1 +First check if the expansion board (Expansionboard, Pytrack, Pysense, etc.) **Without the py module** shows up in Device Manager under Windows, or `lsusb` under MacOS or Linux. The device should show up with a COM port as shown here: + +or in the terminal as shown here: (Example is an Expansion board 3.1 on MacOS) + +![](/gitbook/assets/usb-terminal.png) + +>Note: the USB vendor ID is always 0x04d8, for the device ID, check [here](/updatefirmware/expansionboard/), Table 1 + +* If it does show up, the expansion module is connected and recognised. This also means the USB cable and board are connected correctly. Contintue to [step 5](#step-5) + +* If it shows up with the Device ID in DFU update mode, check [here](/updatefirmware/expansionboard/). + +* If it does not show up, continue to [step 2](#step-2) + +### Step 2 +If the expansion board is not showing up on your computer, try to use a different USB cable or USB port. On Windows, check if device manager updates when plugging in the board, and, to what driver it gets assigned. Use the guide [here](/gettingstarted/software/drivers) to set the correct driver. +* If this solved the problem, continue to [step 5](#step-5) +* If this did not solve the problem, go to [step 3](#step-3) +> some USB cables only support charging and have no conductors for the communication lines. This also holds for some USB-C to USB micro adapters + +> Note: The green LED next to the `USB` marking on the Expansionboard 2.0 / 3.0 implies the board is operational. If this is not the case, check [step 3](#step-3) + +### Step 3 +In this case, the board is still not showing up on your computer and you have tried all different USB cables and combinations. Now, we are going to use a multimeter to check the voltage. Check the datasheet of your expansion board [here](/datasheets/expansionboards/) for the correct pinouts. Connect the expansion board (again, without -py module) to your computer, and measure the voltages: +Re evaluate this part for naming! +* Between `Vin` and `GND` + * Any value between 4.5 and 5.5 V is fine. + * If this is below 4 V, and the board is not getting extremely hot, re-evaluate your USB setup. + + +* Between `3V3Sensors` or +Check if no power to the board +getting hot +etc + +### Step 4 +* If you cannot get the expansion board to show up on your computer, you can still test the functionality of the py device with another board, or a [USB UART adapter](/gettingstarted/programming/usbserial/). + +* If you suspect the USB is not going to work and have no UART adapter, you can try uploading over [WiFi](/gettingstarted/programming/ftp) (if you did not disable this). + +### Step 5 +If you reached this step, the expansion board's USB connection is fully operational. + +Once the expansion board shows up and gets assigned a COM port in Windows, or a `/dev/tty-` address in MacOS or Linux, the Pymakr plugin will try to connect to it. However, there is no py- module to connect to yet, so it will wait forever. + +Now is the time to insert your py- module. Always place the button / RGB LED towards the USB connector, like shown here: (This works the same for all modules and expansion board variants) + +![](/gitbook/assets/expansion_board_3_lopy4.png) + +> Note: For the Expansion board, make sure that at least the jumpers for TX RX LED and RTS are inserted correctly. + +> Note: all (new) -py modules give a flashing blue led every 4 seconds. This is the heartbeat. Once you see this, the module is guarenteed to work. It is also possible to disable this. + +> In some instances you will have to restart your IDE or computer to pick up the connection again. + +If you inserted the module and: +* The green LED on the Expansion board turned off +* The module gets hot +* The expansionboard is now disconnected +Go to [step 8](#step-8) + +If, on the other hand, the module now shows connected in Pymakr, but keeps coredumping or does not return anything, go to the next step + +### Step 6 +First, try to press the reset button on the device. The output should look similar to this: +``` +ets Jun 8 2016 00:22:57 + +rst:0x1 (POWERON_RESET),boot:0x17 (SPI_FAST_FLASH_BOOT) +configsip: 0, SPIWP:0xee +clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00 +mode:DIO, clock div:1 +load:0x3fff8020,len:8 +load:0x3fff8028,len:2140 +ho 0 tail 12 room 4 +load:0x4009fa00,len:19760 +entry 0x400a05bc + +Pycom MicroPython 1.20.2.rc9 [v1.11-1a257d8] on 2020-06-10; LoPy4 with ESP32 +Type "help()" for more information. +>>> +``` +This means the module is in working condition and you are done! On the other hand, if it does not do this, but continues to crash or return nothing, try to do a `safe-boot` like described [here](/gettingstarted/programming/safeboot/). That should bring the device in a mode where the python code is disabled, or the previous firmware is loaded. + +If your output looks like this: +``` +ets Jun 8 2016 00:22:57 + +rst:0x1 (POWERON_RESET),boot:0x6 (DOWNLOAD_BOOT(UART0/UART1/SDIO_REI_FEO_V2)) +waiting for download +``` +Pin `P2` is stuck pulled `LOW`, causing the controller to expect a new firmware upload. This can be caused by ... updating expansion board? + +If your expansion board fails to update, check this [Forum post](https://forum.pycom.io/topic/4911/expansion-board-3-1-issues?_=1593093156432) + +> Note: The expansion board firmware updater has some issues in MacOS, causing the dfu-util: set alt interfaces zero error, any other operating system works fine + +If that does not help, try to use the [Firmware Updater tool](/updatefirmware/device/). make a more exhaustive guide here. + +> After updating the firmware, the heartbeat will be re-enabled. + +### Step 7 +Your expansion board is operational + +Your -py module is operational + +## Step 8 + +Measure voltages. +If you end up here, your module's hardware is most probably broken. Either the voltage regulator died, or the micrcontroller inside is not responding to any inputs anymore. + +## Notes +If the firmware upgrade tool returns: + +“Failed to connect to ESP32: Timed out waiting for packet header” +And you followed all previous steps (no blinking heartbeat LED, no orange LED on the expansionboard 3.0, etc.) The probability that your board is dead is quite high. It is quite unusual for both an expansion board and a -py module to die simultaneously, without user error. Generally, this is caused by reversing the polarity on the battery charger, thus breaking both modules. + + +# Intermittent problems +Intermittent problems are generally caused by + +Unstable power supply + +Changing jumper placement + +Atom + +Loose connections (for example, a loose USB connector) + +Old firmware + +Running machine.deepsleep()or py.go_to_sleep() will also stop USB connection. \ No newline at end of file diff --git a/content/datasheets/_index.md b/content/datasheets/_index.md index 90f55df..3b64541 100644 --- a/content/datasheets/_index.md +++ b/content/datasheets/_index.md @@ -18,14 +18,17 @@ The follow pages contain all information relating to each product, for example: - [Lopy 4](/datasheets/development/lopy4/) - [Gpy](/datasheets/development/gpy/) - [Sipy](/datasheets/development/sipy/) +- [Fipy](/datasheets/development/fipy/) ## OEM modules - [W01](/datasheets/oem/w01/) - [L01](/datasheets/oem/l01/) +- [L01 OEM Baseboard](/datasheets/oem/l01_reference/) - [L04](/datasheets/oem/l04/) -- [Baseboard](datasheets/oem/universal_reference/) -- [Deepsleep](datasheets/oem/deepsleep/) +- [Universal OEM Baseboard](/datasheets/oem/universal_reference/) + + ## Expansion boards - [Pygate](/datasheets/expansionboards/pygate/) @@ -36,5 +39,5 @@ The follow pages contain all information relating to each product, for example: - [Pyscan](/datasheets/expansionboards/pyscan/) - [Expansion 2](/datasheets/expansionboards/expansion2/) - [Expansion 3](/datasheets/expansionboards/expansion3/) - +- [Deepsleep](/datasheets/expansionboards/deepsleep/) diff --git a/content/datasheets/development/fipy.md b/content/datasheets/development/fipy.md index e7877ad..c0063a2 100644 --- a/content/datasheets/development/fipy.md +++ b/content/datasheets/development/fipy.md @@ -9,15 +9,13 @@ aliases: ![](/gitbook/assets/fipy-1.png) +> Note: Orient the RGB LED / reset button over the USB connector on any expansion board -{{% hint style="info" %}} - Please Note: We have removed the labels from the pictures in the documentation due to inconsistencies with label orientation. *The LED must be aligned above the USB socket* when inserting or removing a development board from an expansion board/Pytrack/Pysense/Pyscan. -{{% /hint %}} **Store**: [Buy Here](https://pycom.io/product/fipy/) -**Getting Started:** [Click Here](/gettingstarted/connection/fipy) +**Getting Started:** [Click Here](/gettingstarted/) ## Datasheet @@ -31,42 +29,21 @@ The Fipy is certified for [CE RED](/gitbook/assets/fipy_c03-b0-red-final.pdf) an [ROHS certification](gitbook/assets/RoHs_declarations/RoHS-for-FiPy(8217-00091P)-20190523.pdf) ## Pinout -The pinout of the FiPy is available as a PDF File - - FiPy Pinout +The pinout of the FiPy is available as a [PDF File](/gitbook/assents/fipy-pinout.pdf) ![](/gitbook/assets/fipy-pinout.png) -{{% hint style="info" %}} -Please note that the PIN assignments for UART1 \(TX1/RX1\), SPI \(CLK, MOSI, MISO\) and I2C \(SDA, SCL\) are defaults and can be changed via software. -{{% /hint %}} +> Please note that the PIN assignments for UART1 \(TX1/RX1\), SPI \(CLK, MOSI, MISO\) and I2C \(SDA, SCL\) are defaults and can be changed via software. ## Notes -### WiFi - -By default, upon booting up the FiPy will create a WiFi access point with the SSID `fipy-wlan-XXXX`, where `XXXX` is a random 4-digit number, and the password `www.pycom.io`. - -The RF switch that chooses between the on-board and external antenna is connected to `P12`, so for this reason using `P12` should be avoided unless WiFi is disabled on your application. - ### Power +Do not use the 3.3V pin **in combination with** the Vin pin to supply the device as this will damage the voltage regulator on the board. + +### Antenna placement +Always attach the appropriate antenna when using a wireless connection (LoRa / LTE / SigFox). For WiFi / BLE, it is not mandatory to use an external antenna when you did not explicitly specify this in your code. -The `Vin` pin on the FiPy can be supplied with a voltage ranging from `3.5v` to `5.5v`. The `3.3v` pin, on the other hand, is output **only** and must not be used to feed power into the FiPy otherwise the on-board regulator will be damaged. ### AT Commands -The AT commands for the Sequans Monarch modem on the FiPy are available in a PDF file. - - AT Commands for Sequans - -## Tutorials - -Tutorials on how to the FiPy module can be found in the [examples](/tutorials/introduction) section of this documentation. The following tutorials might be of interest for those using the FiPy: - -* [WiFi connection](/tutorials/all/wlan) -* [LoRaWAN node](/tutorials/lora/lorawan-abp) -* [LoRaWAN nano gateway](/tutorials/lora/lorawan-nano-gateway) -* [Sigfox](/tutorials/sigfox) -* [LTE CAT-M1](/tutorials/lte/cat-m1) -* [NB-IoT](/tutorials/lte/nb-iot) -* [BLE](/tutorials/all/ble) +The AT commands for the Sequans Monarch modem on the FiPy are available in a [PDF file](gitbook/assets/Monarch-LR5110-ATCmdRefMan-rev6_noConfidential.pdf). diff --git a/content/datasheets/development/gpy.md b/content/datasheets/development/gpy.md index bd03583..3eb900a 100644 --- a/content/datasheets/development/gpy.md +++ b/content/datasheets/development/gpy.md @@ -9,9 +9,7 @@ aliases: ![](/gitbook/assets/gpy-1.png) -{{% hint style="info" %}} - Please Note: We have removed the labels from the pictures in the documentation due to inconsistencies with label orientation. *The LED must be aligned above the USB socket* when inserting or removing a development board from an expansion board/Pytrack/Pysense/Pyscan. -{{% /hint %}} +> Note: Orient the RGB LED / reset button over the USB connector on any expansion board **Store**: [Buy Here](https://pycom.io/product/gpy) @@ -19,12 +17,8 @@ aliases: ## Datasheet -{{% hint style="info" %}} -Please Note: We have removed the labels from the pictures in the documentation due to inconsistencies with label orientation. *The LED must be aligned above the USB socket* when inserting or removing a development board from an expansion board/Pytrack/Pysense/Pyscan. -{{% /hint %}} - -The datasheet of the GPy is available as a [PDF File](/gitbook/assets/specsheets/Pycom_002_Specsheets_GPy_v2.pdf") +The datasheet of the GPy is available as a [PDF File](/gitbook/assets/specsheets/Pycom_002_Specsheets_GPy_v2.pdf) The drawing of the LTE-M antenna is available as a [PDF File](/gitbook/assets/lte-m-antenna-drawing.pdf") @@ -46,27 +40,12 @@ Please note that the PIN assignments for UART1 \(TX1/RX1\), SPI \(CLK, MOSI, MIS ## Notes -### WiFi - -By default, upon booting up the GPy will create a WiFi access point with the SSID `gpy-wlan-XXXX`, where `XXXX` is a random 4-digit number, and the password `www.pycom.io`. - -The RF switch that selects between the on-board and external antenna is connected to `P12`, so for this reason using `P12` should be avoided unless WiFi is disabled in your application. - ### Power +Do not use the 3.3V pin **in combination with** the Vin pin to supply the device as this will damage the voltage regulator on the board. -The `Vin` pin on the GPy can be supplied with a voltage ranging from `3.5v` to `5.5v`. The `3.3v` pin on the other hand is output **only**, and must not be used to feed power into the GPy, otherwise the on-board regulator will be damaged. +### Antenna placement +Always attach the appropriate antenna when using a wireless connection (LTE). For WiFi / BLE, it is not mandatory to use an external antenna when you did not explicitly specify this in your code. ### AT Commands -The AT commands for the Sequans Monarch modem on the GPy are available in a PDF file. - - AT Commands for Sequans - -## Tutorials - -Tutorials on how to the GPy module can be found in the [examples](/tutorials/introduction) section of this documentation. The following tutorials might be of interest for those using the GPy: - -* [WiFi connection](/tutorials/all/wlan) -* [LTE CAT-M1](/tutorials/lte/cat-m1) -* [NB-IoT](/tutorials/lte/nb-iot) -* [BLE](/tutorials/all/ble) +The AT commands for the Sequans Monarch modem on the GPy are available in a [PDF file](/gitbook/assets/Monarch-LR5110-ATCmdRefMan-rev6_noConfidential.pdf) diff --git a/content/datasheets/development/lopy.md b/content/datasheets/development/lopy.md index 6847d8c..bb4fc14 100644 --- a/content/datasheets/development/lopy.md +++ b/content/datasheets/development/lopy.md @@ -10,18 +10,17 @@ aliases: ![](/gitbook/assets/lopy-1.png) -{{% hint style="info" %}} -Please Note: We have removed the labels from the pictures in the documentation due to inconsistencies with label orientation. *The LED must be aligned above the USB socket* when inserting or removing a development board from an expansion board/Pytrack/Pysense/Pyscan. -{{% /hint %}} - +> Note: Orient the RGB LED / reset button over the USB connector on any expansion board **Store**: [Buy Here](https://pycom.io/product/lopy) -**Getting Started:** [Click Here](/gettingstarted/connection/lopy) +**Getting Started:** [Click Here](/gettingstarted/) ## Datasheet -The datasheet of the LoPy is available as a [PDF File](gitbook/assets/specsheets/Pycom_002_Specsheets_LoPy_v2.pdf) +The datasheet of the LoPy is available as a [PDF File] +(/gitbook/assets/specsheets/Pycom_002_Specsheets_LoPy_v2.pdf) + The Lopy is certified for [CE RED](/gitbook/assets/16-213298_expertise_pycom_lopy-1.0r.pdf) and [FCC ACC](/gitbook/assets/2090acc16_grant.pdf") [FCC BCC](/gitbook/assets/2090bcc16_grant.pdf) [FCC CCC](/gitbook/assets/2090ccc16_grant.pdf) @@ -33,29 +32,17 @@ The pinout of the LoPy is available as a [PDF File](/gitbook/assets/lopy-pinout. ![](/gitbook/assets/lopy-pinout.png) -{{% hint style="info" %}} -Please note that the PIN assignments for UART1 \(TX1/RX1\), SPI \(CLK, MOSI, MISO\) and I2C \(SDA, SCL\) are defaults and can be changed via software. -{{% /hint %}} +> Please note that the PIN assignments for UART1 \(TX1/RX1\), SPI \(CLK, MOSI, MISO\) and I2C \(SDA, SCL\) are defaults and can be changed via software. + ## Notes -### WiFi - -By default, upon booting up the LoPy will create a WiFi access point with the SSID `lopy-wlan-XXXX`, where `XXXX` is a random 4-digit number and the password `www.pycom.io`. - ### Power +Do not use the 3.3V pin **in combination with** the Vin pin to supply the device as this will damage the voltage regulator on the board. -The `Vin` pin on the LoPy can be supplied with a voltage ranging from `3.5v` to `5.5v`. The `3.3v` pin on the other hand is output **only**, and must not be used to feed power into the LoPy, otherwise the on-board regulator will be damaged. +### Antenna placement +Always attach the appropriate antenna when using a wireless connection (LoRa). For WiFi / BLE, it is not mandatory to use an external antenna when you did not explicitly specify this in your code. ### Deep Sleep -Due to a couple of issues with the LoPy design, the module draws more current than it should while in Deep Sleep. The DC-DC switching regulator always stays in high performance mode, which is used to provide the lowest possible output ripple when the module is in use. In this mode, it draws a quiescent current of 10mA. When the regulator is put into ECO mode the quiescent current drops to 10uA. Unfortunately, the pin used to control this mode is out of the RTC domain. This means that it is not usable during Deep Sleep. This results in the regulator remaining in PWM mode, keeping its quiescent current at 10mA. The flash chip also doesn't enter into power down mode as the CS pin floats during Deep Sleep. This causes the flash chip to consume around 2mA of current. To work around this issue a ["deep sleep shield"](../../boards/deepsleep/) is available that attaches to the module and allows power to be cut off from the device. The device can then be re-enabled either through a timer or via a pin interrupt. With the Deep Sleep Shield, the current consumption during deep sleep is between 7uA and 10uA depending on the wake sources configured. - -## Tutorials - -Tutorials on the LoPy module can be found in the [examples](/tutorials/introduction) section of this documentation. The following tutorials might be of interest for those using the LoPy: - -* [WiFi connection](/tutorials/all/wlan) -* [LoRaWAN node](/tutorials/lora/lorawan-abp) -* [LoRaWAN nano gateway](/tutorials/lora/lorawan-nano-gateway) -* [BLE](/tutorials/all/ble) +Due to a couple of issues with the LoPy design, the module draws more current than it should while in Deep Sleep. The DC-DC switching regulator always stays in high performance mode, which is used to provide the lowest possible output ripple when the module is in use. In this mode, it draws a quiescent current of 10mA. When the regulator is put into ECO mode the quiescent current drops to 10uA. Unfortunately, the pin used to control this mode is out of the RTC domain. This means that it is not usable during Deep Sleep. This results in the regulator remaining in PWM mode, keeping its quiescent current at 10mA. The flash chip also doesn't enter into power down mode as the CS pin floats during Deep Sleep. This causes the flash chip to consume around 2mA of current. To work around this issue a ["deep sleep shield"](../../boards/deepsleep/) is available that attaches to the module and allows power to be cut off from the device. The device can then be re-enabled either through a timer or via a pin interrupt. With the Deep Sleep Shield, the current consumption during deep sleep is between 7uA and 10uA depending on the wake sources configured. \ No newline at end of file diff --git a/content/datasheets/development/lopy4.md b/content/datasheets/development/lopy4.md index 0152911..8b118bd 100644 --- a/content/datasheets/development/lopy4.md +++ b/content/datasheets/development/lopy4.md @@ -10,10 +10,7 @@ aliases: ![](/gitbook/assets/lopy4-1.png) -{{% hint style="info" %}} - Please Note: We have removed the labels from the pictures in the documentation due to inconsistencies with label orientation. *The LED must be aligned above the USB socket* when inserting or removing a development board from an expansion board/Pytrack/Pysense/Pyscan. -{{% /hint %}} - +> Note: Orient the RGB LED / reset button over the USB connector on any expansion board **Store**: [Buy Here](https://pycom.io/product/lopy4/) @@ -35,28 +32,19 @@ The pinout of the LoPy4 is available as a [PDF File](/gitbook/assets/lopy4-pinou ![](/gitbook/assets/lopy4-pinout.png) -{{% hint style="info" %}} -Please note that the PIN assignments for UART1 (TX1/RX1), SPI (CLK, MOSI, MISO) and I2C (SDA, SCL) are defaults and can be changed in Software. -{{% /hint %}} + +> Please note that the PIN assignments for UART1 (TX1/RX1), SPI (CLK, MOSI, MISO) and I2C (SDA, SCL) are defaults and can be changed in Software. ## Notes +### Power +Do not use the 3.3V pin **in combination with** the Vin pin to supply the device as this will damage the voltage regulator on the board. -### WiFi +### Antenna placement +Always attach the appropriate antenna when using a wireless connection (LoRa / SigFox). For WiFi / BLE, it is not mandatory to use an external antenna when you did not explicitly specify this in your code. -By default, upon booting up the LoPy4 will create a WiFi access point with the SSID `lopy4-wlan-XXXX`, where `XXXX` is a random 4-digit number and the password `www.pycom.io`. - -The RF switch that chooses between the on-board and external antenna is connected to `P12`, so for this reason using `P12` should be avoided unless WiFi is disabled in your application. ### Power +Do not use the 3.3V pin **in combination with** the Vin pin to supply the device as this will damage the voltage regulator on the board. -The `Vin` pin on the LoPy4 can be supplied with a voltage ranging from `3.5v` to `5.5v`. The `3.3v` pin on the other hand is output **only**, and must not be used to feed power into the LoPy4, otherwise the on-board regulator will be damaged. - -## Tutorials - -Tutorials on the LoPy4 module can be found in the [examples](/tutorials/introduction) section of this documentation. The following tutorials might be of interest for those using the LoPy4: - -* [WiFi connection](/tutorials/all/wlan) -* [LoRaWAN node](/tutorials/lora/lorawan-abp) -* [LoRaWAN nano gateway](/tutorials/lora/lorawan-nano-gateway) -* [Sigfox](/tutorials/sigfox) -* [BLE](/tutorials/all/ble) +### Antennas +Always attach the appropriate antenna when using a wireless connection (LoRa / LTE). For WiFi / BLE, it is not mandatory to use an external antenna when you did not explicitly specify this in your code. diff --git a/content/datasheets/development/sipy.md b/content/datasheets/development/sipy.md index ae465d1..49bb2e3 100644 --- a/content/datasheets/development/sipy.md +++ b/content/datasheets/development/sipy.md @@ -9,11 +9,7 @@ aliases: ![](/gitbook/assets/sipy-2.png) -{{% hint style="info" %}} - Please Note: We have removed the labels from the pictures in the documentation due to inconsistencies with label orientation. *The LED must be aligned above the USB socket* when inserting or removing a development board from an expansion board/Pytrack/Pysense/Pyscan. -{{% /hint %}} - - +> Note: Orient the RGB LED / reset button over the USB connector on any expansion board **Store**: [Buy Here](https://pycom.io/product/sipy) @@ -32,28 +28,17 @@ The pinout of the SiPy is available as a [PDF File](/gitbook/assets/sipy-pinout. ![](/gitbook/assets/sipy-pinout.png) -{{% hint style="info" %}} -Please note that the PIN assignments for UART1 \(TX1/RX1\), SPI \(CLK, MOSI, MISO\) and I2C \(SDA, SCL\) are defaults and can be changed via software. -{{% /hint %}} +> Please note that the PIN assignments for UART1 \(TX1/RX1\), SPI \(CLK, MOSI, MISO\) and I2C \(SDA, SCL\) are defaults and can be changed via software. ## Notes -### WiFi - -By default, upon booting up the SiPy will create a WiFi access point with the SSID `sipy-wlan-XXXX`, where `XXXX` is a random 4-digit number, and the password `www.pycom.io`. - ### Power +Do not use the 3.3V pin **in combination with** the Vin pin to supply the device as this will damage the voltage regulator on the board. -The `Vin` pin on the SiPy can be supplied with a voltage ranging from `3.5v` to `5.5v`. The `3.3v` pin on the other hand is output **only**, and must not be used to feed power into the SiPy, otherwise the on-board regulator will be damaged. +### Antenna placement +Always attach the appropriate antenna when using a wireless connection (SigFox). For WiFi / BLE, it is not mandatory to use an external antenna when you did not explicitly specify this in your code. ### Deep Sleep Due to a couple of issues with the SiPy design, the module draws more current than it should while in Deep Sleep. The DC-DC switching regulator always stays in high performance mode, which is used to provide the lowest possible output ripple when the module is in use. In this mode, it draws a quiescent current of 10mA. When the regulator is put into ECO mode the quiescent current drops to 10uA. Unfortunately, the pin used to control this mode is out of the RTC domain. This means that it is not usable during Deep Sleep. This results in the regulator remaining in PWM mode, keeping its quiescent current at 10mA. The flash chip also doesn't enter into power down mode as the CS pin floats during Deep Sleep. This causes the flash chip to consume around 2mA of current. To work around this issue a ["deep sleep shield"](../../boards/deepsleep/) is available that attaches to the module and allows power to be cut off from the device. The device can then be re-enabled either through a timer or via a pin interrupt. With the Deep Sleep Shield, the current consumption during deep sleep is between 7uA and 10uA depending on the wake sources configured. -## Tutorials - -Tutorials on the SiPy module can be found in the [examples](/tutorials/introduction) section of this documentation. The following tutorials might be of interest for those using the SiPy: - -* [WiFi connection](/tutorials/all/wlan) -* [Sigfox](/tutorials/sigfox) -* [BLE](/tutorials/all/ble) diff --git a/content/datasheets/development/wipy2.md b/content/datasheets/development/wipy2.md index 6907ac7..c406c33 100644 --- a/content/datasheets/development/wipy2.md +++ b/content/datasheets/development/wipy2.md @@ -9,10 +9,7 @@ aliases: ![](/gitbook/assets/wipy2-1.png) -{{% hint style="info" %}} - Please Note: We have removed the labels from the pictures in the documentation due to inconsistencies with label orientation. *The LED must be aligned above the USB socket* when inserting or removing a development board from an expansion board/Pytrack/Pysense/Pyscan. -{{% /hint %}} - +> Note: Orient the RGB LED / reset button over the USB connector on any expansion board **Store**: Discontinued, See [WiPy3](../wipy3) @@ -31,19 +28,15 @@ The pinout of the WiPy2 is available as a [PDF File](/gitbook/assets/wipy2-pinou ![](/gitbook/assets/wipy2-pinout.png) -{{% hint style="info" %}} -Please note that the PIN assignments for UART1 \(TX1/RX1\), SPI \(CLK, MOSI, MISO\) and I2C \(SDA, SCL\) are defaults and can be changed via software. -{{% /hint %}} +> Please note that the PIN assignments for UART1 \(TX1/RX1\), SPI \(CLK, MOSI, MISO\) and I2C \(SDA, SCL\) are defaults and can be changed via software. ## Notes -### WiFi - -By default, upon booting up the WiPy2 will create a WiFi access point with the SSID `wipy-wlan-XXXX`, where `XXXX` is a random 4-digit number, and the password `www.pycom.io`. - ### Power +Do not use the 3.3V pin **in combination with** the Vin pin to supply the device as this will damage the voltage regulator on the board. -The `Vin` pin on the WiPy2 can be supplied with a voltage ranging from `3.5v` to `5.5v`. The `3.3v` pin on the other hand is output **only**, and must not be used to feed power into the WiPy2, otherwise the on-board regulator will be damaged. +### Antenna placement +Always attach the appropriate antenna when using a wireless connection. For WiFi / BLE, it is not mandatory to use an external antenna when you did not explicitly specify this in your code. ### Deep Sleep diff --git a/content/datasheets/development/wipy3.md b/content/datasheets/development/wipy3.md index b324163..5d99ef4 100644 --- a/content/datasheets/development/wipy3.md +++ b/content/datasheets/development/wipy3.md @@ -9,9 +9,7 @@ aliases: ![](/gitbook/assets/wipy3.png) -{{% hint style="info" %}} - Please Note: We have removed the labels from the pictures in the documentation due to inconsistencies with label orientation. *The LED must be aligned above the USB socket* when inserting or removing a development board from an expansion board/Pytrack/Pysense/Pyscan. -{{% /hint %}} +> Note: Orient the RGB LED / reset button over the USB connector on any expansion board **Store**: [Buy Here](https://pycom.io/product/wipy-3-0/) @@ -35,9 +33,8 @@ The pinout of the WiPy3 is available as a [PDF File](/gitbook/assets/wipy3-pinou ![](/gitbook/assets/wipy3-pinout.png) -{{% hint style="info" %}} -Please note that the PIN assignments for UART1 \(TX1/RX1\), SPI \(CLK, MOSI, MISO\) and I2C \(SDA, SCL\) are defaults and can be changed via software. -{{% /hint %}} +> Please note that the PIN assignments for UART1 \(TX1/RX1\), SPI \(CLK, MOSI, MISO\) and I2C \(SDA, SCL\) are defaults and can be changed via software. + ## Differences from WiPy 2.0 @@ -48,6 +45,13 @@ Please note that the PIN assignments for UART1 \(TX1/RX1\), SPI \(CLK, MOSI, MIS ## Notes +### Power +Do not use the 3.3V pin **in combination with** the Vin pin to supply the device as this will damage the voltage regulator on the board. + +### Antenna placement +Always attach the appropriate antenna when using a wireless connection. For WiFi / BLE, it is not mandatory to use an external antenna when you did not explicitly specify this in your code. + + ### WiFi By default, upon booting up the WiPy3 will create a WiFi access point with the SSID `wipy-wlan-XXXX`, where `XXXX` is a random 4-digit number, and the password `www.pycom.io`. diff --git a/content/datasheets/oem/deepsleep.md b/content/datasheets/expansionboards/deepsleep.md similarity index 58% rename from content/datasheets/oem/deepsleep.md rename to content/datasheets/expansionboards/deepsleep.md index 3eb88c2..57c0162 100644 --- a/content/datasheets/oem/deepsleep.md +++ b/content/datasheets/expansionboards/deepsleep.md @@ -2,16 +2,14 @@ title: "Deep Sleep Shield" aliases: --- +>The Deep Sleep Shield works very similar to how the Pysense / Pytrack sleep modes work -The schematic of the Deep Sleep Shield is available as a PDF File. +The schematic of the Deep Sleep Shield is available as a [PDF File](/gitbook/assets/deepsleep-schematic.pdf) - Deep Sleep Schematic ## Pinout -The pinout of the Deep Sleep Shield is available as a PDF File - - Deep Sleep Pinout +The pinout of the Deep Sleep Shield is available as a [PDF File](/gitbook/assets/deepsleep-pinout.pdf) ![](/gitbook/assets/deepsleep-pinout.png) diff --git a/content/datasheets/expansionboards/expansion2.md b/content/datasheets/expansionboards/expansion2.md index 81ebd89..20cb589 100644 --- a/content/datasheets/expansionboards/expansion2.md +++ b/content/datasheets/expansionboards/expansion2.md @@ -29,6 +29,7 @@ The pinout of the Expansion Board is available as a [PDF File](/gitbook/assets/e Be gentle when plugging and unplugging from the USB connector. Whilst the USB connector is soldered and is relatively strong, if it breaks off it can be very difficult to fix. {{% /hint %}} -## Battery Charger +## Notes +### Battery Charger The Expansion Board features a single cell Li-Ion/Li-Po charger. When the board is being powered via the micro USB connector, the Expansion Board will charge the battery \(if connected\). When the `CHG` jumper is present, the battery will be charged at `450mA`. If this value is too high for your application, removing the jumper lowers the charge current to `100mA`. diff --git a/content/datasheets/expansionboards/expansion3.md b/content/datasheets/expansionboards/expansion3.md index 551a146..a083db1 100644 --- a/content/datasheets/expansionboards/expansion3.md +++ b/content/datasheets/expansionboards/expansion3.md @@ -26,23 +26,20 @@ The expansion board contains 6 headers labeled: - RUN - BAT - LED -- CHG +- CHG: Decrease battery charging current from 450mA to 100mA ![](/gitbook/assets/expansion3-pinout-1.png) -{{% hint style="danger" %}} -Be gentle when plugging and unplugging from the USB connector. Whilst the USB connector is soldered and is relatively strong, if it breaks off it can be very difficult to fix. -{{% /hint %}} - -## Battery Charger +> Be gentle when plugging and unplugging from the USB connector. Whilst the USB connector is soldered and is relatively strong, if it breaks off it can be very difficult to fix. +## Notes +### Battery Charger +> Make sure you check the polarity of the battery before plugging it in! Connect the positive side to the side marked with a `+`. The Expansion Board features a single cell Li-Ion/Li-Po charger. When the board is being powered via the micro USB connector, the Expansion Board will charge the battery \(if connected\). When the `CHG` jumper is present, the battery will be charged at `450mA`. If this value is too high for your application, removing the jumper lowers the charge current to `100mA`. -{{% hint style="info" %}} -To use the battery, pull `P8/G15` high (connect to `3v3`). If you want to use the SD card as well, use a 10k pull-up. -{{% /hint %}} +> To use the battery, pull `P8/G15` high (connect to `3v3`). If you want to use the SD card as well, use a 10k pull-up. -## Differences between v2.0 and v3.0 +### Differences between v2.0 and v3.0 * The FTDI chip as been replaced with a custom programmed PIC, similar to the diff --git a/content/datasheets/expansionboards/pyethernet.md b/content/datasheets/expansionboards/pyethernet.md new file mode 100644 index 0000000..3fabcdc --- /dev/null +++ b/content/datasheets/expansionboards/pyethernet.md @@ -0,0 +1,21 @@ +--- +title: "PyEthernet" + +--- + + +The PyEthernet is a module meant for the [Pygate](../pygate/) expansionboard, enabeling communication and Power over Ethernet. The module will fit on the Pygate in two ways, but only one is correct. Make sure the RJ45 Ethernet port is facing the other way compared to the RGB LED, like shown in the figure below. + +![](/gitbook/assets/pyethernet.png) ![](/gitbook/assets/pygate_ethernet.png) +> Note that the PyEthernet can also work without PoE, you will just need to connect it to a different power source + +# Datasheet + +We currently have no datasheet available for the module. On the bottom, near the pinheaders, you can find labels for the pin functions. The pins are used to connect both power and a SPI bus. + + +## Notes + +### Power saving +The tiny jumper on the board labeled JP1 enables a default load. Older PoE adapters disable the power injection when only a tiny load is detected. Now by default, the Pygate does not always provide a big enough load for these types of power injectors Connecting the jumper will enable a default load, causing the power **not** to drop. More modern PoE injectors are designed for low power applications as well, not needing the default load. For such applications, you can disconnect the jumper and even save some power! + diff --git a/content/datasheets/expansionboards/pygate.md b/content/datasheets/expansionboards/pygate.md index 8b913f2..1b7c7b8 100644 --- a/content/datasheets/expansionboards/pygate.md +++ b/content/datasheets/expansionboards/pygate.md @@ -36,12 +36,13 @@ Now, attach the antenna(s) to the SMA connector(s) and upload code! ![](/gitbook/assets/pygate-case.jpg) The case will also work for the regular expansion board and has the SD card holder accessible from the outside. +## Notes +### Battery Charger -## Battery Charger +The Pygate features a single cell Li-Ion/Li-Po charger. When the board is being powered via the USB-C connector, the Pygate will charge the battery if connected. +> Make sure you check the polarity of the battery before plugging it in! Connect the positive side to the side marked with a `+`. -The Pygate features a single cell Li-Ion/Li-Po charger. When the board is being powered via the USB-C connector, the Pygate will charge the battery \(if connected\). - -## Troubleshooting +### Troubleshooting * If PIC stays in bootloader mode, the [`dfu-util` update](/pytrackpysense/installation/firmware) should be performed diff --git a/content/datasheets/expansionboards/pyscan.md b/content/datasheets/expansionboards/pyscan.md index f0597dd..d86a98a 100644 --- a/content/datasheets/expansionboards/pyscan.md +++ b/content/datasheets/expansionboards/pyscan.md @@ -41,9 +41,8 @@ For other Operating Systems, no driver is required. ## Pinout -The pinout of the Pyscan is available as a PDF File +The pinout of the Pyscan is available as a [PDF File](/gitbook/assets/pyscan-pinout.pdf) - Pyscan Pinout ![](/gitbook/assets/pyscan-pinout-1.png) @@ -59,4 +58,4 @@ The board features a single cell Li-Ion/Li-Po charger. When the board is being p ## 3D model for case design -* Please see the 3D model (step format) +* Please see the [3D model] (/gitbook/assets/PyScan_v0.7.step) (step format) diff --git a/content/datasheets/expansionboards/pysense.md b/content/datasheets/expansionboards/pysense.md index 19c431a..14487f1 100644 --- a/content/datasheets/expansionboards/pysense.md +++ b/content/datasheets/expansionboards/pysense.md @@ -22,16 +22,17 @@ The pinout of the Pysense is available as a [PDF File](/gitbook/assets/pysense-p ![](/gitbook/assets/pysense-pinout-1.png) - -## Battery Charger +## Notes +### 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). +> Make sure you check the polarity of the battery before plugging it in! Connect the positive side to the side marked with a `+`. -## Mechanical Dimensions +### Mechanical Dimensions ![](/gitbook/assets/Pysense_v1.1_MechanicalDimensions_b.png) -## 3D model for case design +### 3D model for case design -* Please see the 3D model (step format) +* Please see the [3D model](/gitbook/assets/PySense_v1.1.step) (step format) diff --git a/content/datasheets/expansionboards/pysense2.md b/content/datasheets/expansionboards/pysense2.md index c57603e..24689b9 100644 --- a/content/datasheets/expansionboards/pysense2.md +++ b/content/datasheets/expansionboards/pysense2.md @@ -19,16 +19,17 @@ The pinout of the Pysense is available as a [PDF File](/gitbook/assets/pysense2- ![](/gitbook/assets/pysense2-pinout.png) - -## Battery Charger +## Notes +### 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). +> Make sure you check the polarity of the battery before plugging it in! Connect the positive side to the side marked with a `+`. -## Mechanical Dimensions +### Mechanical Dimensions ![](/gitbook/assets/Pysense_v2.0X_MechanicalDimensions.png) -## 3D model for case design +### 3D model for case design * Please see the [3D model](/gitbook/assets/pysense_v2.0X.step) (Step format) \ No newline at end of file diff --git a/content/datasheets/expansionboards/pytrack.md b/content/datasheets/expansionboards/pytrack.md index ac7926a..f6fab12 100644 --- a/content/datasheets/expansionboards/pytrack.md +++ b/content/datasheets/expansionboards/pytrack.md @@ -23,17 +23,17 @@ The pinout of the Pytrack is available as a [PDF File](/gitbook/assets/pytrack-p ![](/gitbook/assets/pytrack-pinout-1.png) - -## Battery Charger +## Notes +### 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). +> Make sure you check the polarity of the battery before plugging it in! Connect the positive side to the side marked with a `+`. - -## Mechanical Dimensions +### Mechanical Dimensions ![](/gitbook/assets/Pysense_v1.1_MechanicalDimensions_b.png) -## 3D model for case design +### 3D model for case design -* Please see the 3D model (step format) +* Please see the [3D model](/gitbook/assets/PyTrack_v1.1.step") (step format) diff --git a/content/datasheets/expansionboards/pytrack2.md b/content/datasheets/expansionboards/pytrack2.md index db80d5b..d14c782 100644 --- a/content/datasheets/expansionboards/pytrack2.md +++ b/content/datasheets/expansionboards/pytrack2.md @@ -19,17 +19,18 @@ The pinout of the Pytrack is available as a [PDF File]( /gitbook/assets/pytrack2-pinout.pdf) ![](/gitbook/assets/pytrack2-pinout.png) - -## Battery Charger +## Notes +### 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). +> Make sure you check the polarity of the battery before plugging it in! Connect the positive side to the side marked with a `+`. -## Mechanical Dimensions +### Mechanical Dimensions ![](/gitbook/assets/Pytrack_v2.0X_MechanicalDimensions.png) -## 3D model for case design +### 3D model for case design * Please see the [3D model](/gitbook/assets/pytrack_v2.0X.step) (step format) diff --git a/content/datasheets/oem/_index.md b/content/datasheets/oem/_index.md index 6d6536f..b25300e 100644 --- a/content/datasheets/oem/_index.md +++ b/content/datasheets/oem/_index.md @@ -10,7 +10,6 @@ This section contains all of the datasheets for the Pycom OEM Devices. This incl - [W01](/datasheets/oem/w01/) - [G01](/datasheets/oem/g01/) - [L01](/datasheets/oem/l01/) -- [L01](/datasheets/oem/l01_reference/) +- [L01 OEM Baseboard](/datasheets/oem/l01_reference/) - [L04](/datasheets/oem/l04/) -- [Baseboard](datasheets/oem/universal_reference/) -- [Deepsleep](datasheets/oem/deepsleep/) \ No newline at end of file +- [Universal OEM Baseboard](/datasheets/oem/universal_reference/) diff --git a/content/datasheets/oem/g01.md b/content/datasheets/oem/g01.md index ea009c2..ac848ab 100644 --- a/content/datasheets/oem/g01.md +++ b/content/datasheets/oem/g01.md @@ -32,21 +32,14 @@ The G01 is certified for [CE RED](/gitbook/assets/17-213357_red-certificate_pyco The drawings for the G01 is available as a [PDF File](/gitbook/assets/g01-drawing.pdf) -{{% hint style="info" %}} -Please note that the PIN assignments for UART1 \(TX1/RX1\), SPI \(CLK, MOSI, MISO\) and I2C \(SDA, SCL\) are defaults and can be changed via software. -{{% /hint %}} +> Please note that the PIN assignments for UART1 \(TX1/RX1\), SPI \(CLK, MOSI, MISO\) and I2C \(SDA, SCL\) are defaults and can be changed via software. + ## AT Commands -The AT commands for the Sequans Monarch modem on the G01 are available in a PDF file. +The AT commands for the Sequans Monarch modem on the G01 are available in a [PDF file](/gitbook/assets/Monarch-LR5110-ATCmdRefMan-rev6_noConfidential.pdf). - - AT Commands for Sequans ## Tutorials -Tutorials on the G01 module can be found in the [examples](/tutorials/introduction) section of this documentation. The following tutorials might be of interest for those using the G01: +Tutorials on the G01 module can be found in the [examples](/tutorials/) section of this documentation. -* [WiFi connection](/tutorials/all/wlan) -* [LTE CAT-M1](/tutorials/lte/cat-m1) -* [NB-IoT](/tutorials/lte/nb-iot) -* [BLE](/tutorials/all/ble) diff --git a/content/datasheets/oem/l01.md b/content/datasheets/oem/l01.md index 6cb8f8e..2ea349a 100644 --- a/content/datasheets/oem/l01.md +++ b/content/datasheets/oem/l01.md @@ -29,16 +29,9 @@ The pinout of the L01 is available as a [PDF File](/gitbook/assets/l01-pinout.pd The drawings for the L01 is available as a [PDF File](/gitbook/assets/l01-drawing.pdf) +> Please note that the PIN assignments for UART1 \(TX1/RX1\), SPI \(CLK, MOSI, MISO\) and I2C \(SDA, SCL\) are defaults and can be changed via software. -{{% hint style="info" %}} -Please note that the PIN assignments for UART1 \(TX1/RX1\), SPI \(CLK, MOSI, MISO\) and I2C \(SDA, SCL\) are defaults and can be changed via software. -{{% /hint %}} ## Tutorials -Tutorials on the L01 module can be found in the [examples](/tutorials/introduction) section of this documentation. The following tutorials might be of interest for those using the L01: - -* [WiFi connection](/tutorials/all/wlan) -* [LoRaWAN node](/tutorials/lora/lorawan-abp) -* [LoRaWAN nano gateway](/tutorials/lora/lorawan-nano-gateway) -* [BLE](/tutorials/all/ble) +Tutorials on the L01 module can be found in the [examples](/tutorials/) section of this documentation. \ No newline at end of file diff --git a/content/datasheets/oem/l01_reference.md b/content/datasheets/oem/l01_reference.md index 286cf3d..0004709 100644 --- a/content/datasheets/oem/l01_reference.md +++ b/content/datasheets/oem/l01_reference.md @@ -11,9 +11,7 @@ aliases: The L01 OEM reference board is a reference design suitable for the L01 as well as the W01. It makes it possible to have a single PCB design that can accommodate both of the OEM modules. -{{% hint style="info" %}} -If you require a reference board for the L04 or G01, this design is **not** suitable as it does not feature a SIM slot or the double antenna connection. For the L04 or G01 please use the [Universal OEM Baseboard Reference](../universal_reference) -{{% /hint %}} +> If you require a reference board for the L04 or G01, this design is **not** suitable as it does not feature a SIM slot or the double antenna connection. For the L04 or G01 please use the [Universal OEM Baseboard Reference](../universal_reference) ## Features @@ -24,22 +22,19 @@ If you require a reference board for the L04 or G01, this design is **not** suit * DC-DC regulator (3.5 - 5.5V) input with low current draw during Deep Sleep * Reset button +> The reference board has exactly the same pinout as a developmnent module and can be used in its place! + ## Layout -The layout of the L01 baseboard reference is available as a PDF File. - - L01 OEM Layout +The layout of the L01 baseboard reference is available as a [PDF File](/gitbook/assets/l01-oem-layout.pdf) ![](/gitbook/assets/l01-oem-layout-1.png) ## Schematic -The schematic of the L01 baseboard reference is available as a PDF File. - - L01 OEM Schematic +The schematic of the L01 baseboard reference is available as a [PDF File](/gitbook/assets/l01-oem-schematic.pdf) ## Altium Project and Gerber Files -The Altium Project and Gerber files are also available as a ZIP File. +The Altium Project and Gerber files are also available as a [ZIP File](/gitbook/assets/l01-oem-baseboard-ref.zip) - L01 OEM Altium Project and Gerber Files diff --git a/content/datasheets/oem/l04.md b/content/datasheets/oem/l04.md index 84dfcd1..9910333 100644 --- a/content/datasheets/oem/l04.md +++ b/content/datasheets/oem/l04.md @@ -28,10 +28,8 @@ The pinout of the L04 is available as a [PDF File](/gitbook/assets/l04-pinout.pd The drawings for the L04 are available as a [PDF File](/gitbook/assets/l04-drawing.pdf) -{{% hint style="info" %}} -Please note that the PIN assignments for UART1 \(TX1/RX1\), SPI \(CLK, MOSI, MISO\) and I2C \(SDA, SCL\) are defaults and can be changed via software. -{{% /hint %}} +> Please note that the PIN assignments for UART1 \(TX1/RX1\), SPI \(CLK, MOSI, MISO\) and I2C \(SDA, SCL\) are defaults and can be changed via software. ## Power Consumption @@ -46,10 +44,4 @@ Here are some basic power usage measurements for various scenarios. ## Tutorials -Tutorials on the L04 module can be found in the [examples](/tutorials/introduction) section of this documentation. The following tutorials might be of interest for those using the L04: - -* [WiFi connection](/tutorials/all/wlan) -* [LoRaWAN node](/tutorials/lora/lorawan-abp) -* [LoRaWAN nano gateway](/tutorials/lora/lorawan-nano-gateway) -* [Sigfox](/tutorials/sigfox) -* [BLE](/tutorials/all/ble) +Tutorials on the L04 module can be found in the [examples](/tutorials/ section of this documentation. diff --git a/content/datasheets/oem/universal_reference.md b/content/datasheets/oem/universal_reference.md index 42b3ad0..2f31ada 100644 --- a/content/datasheets/oem/universal_reference.md +++ b/content/datasheets/oem/universal_reference.md @@ -11,35 +11,34 @@ aliases: The universal OEM reference board is a reference design suitable for the W01, L01, L04 and G01 OEM modules, making it possible to have a single PCB design that can accommodate all of our OEM modules. -{{% hint style="info" %}} -If you require a reference board for the G01, this design is the only one that is suitable. The L01 reference board does not contain the necessary SIM slot. -{{% /hint %}} +>If you require a reference board for the G01, this design is the only one that is suitable. The L01 reference board does not contain the necessary SIM slot. + ## Features * Suits all of the OEM modules \(L01, L04, W01, G01\) * On-board 2.4GHz antenna for WiFi and Bluetooth, with the ability to switch to an external antenna via a U.FL connector. * 3 U.FL connectors for all the outputs available on the OEM modules +* SIM card holder * WS2812B RGB LED * DC-DC regulator (3.5 - 5.5V) input with low current draw during Deep Sleep * Reset button +> The reference board has exactly the same pinout as a developmnent module and can be used in its place! + ## Layout -The layout of the OEM baseboard reference is available as a PDF File +The layout of the OEM baseboard reference is available as a [PDF File](/gitbook/assets/oem-universal-layout.pdf) - OEM Layout ![](/gitbook/assets/oem-universal-layout-1.png) ## Schematic -The schematic of the OEM baseboard reference is available as a PDF File. +The schematic of the OEM baseboard reference is available as a [PDF File](/gitbook/assets/oem-universal-schematic.pdf) - OEM Schematic ## Altium Project and Gerber Files -The Altium Project and Gerber files are also available as a ZIP File. +The Altium Project and Gerber files are also available as a [ZIP File](gitbook/assets/oem-universal-baseboard-ref.zip) -[OEM Altium Project and Gerber Files](/gitbook/assets/oem-universal-baseboard-ref.zip) diff --git a/content/firmwareapi/micropython/usocket.md b/content/firmwareapi/micropython/usocket.md index 48a472d..a0224fe 100644 --- a/content/firmwareapi/micropython/usocket.md +++ b/content/firmwareapi/micropython/usocket.md @@ -40,6 +40,9 @@ s.connect(socket.getaddrinfo('www.micropython.org', 80)[0][-1]) * Family types: `socket.AF_INET`, `socket.AF_LORA`, `socket.AF_SIGFOX` * Socket types: `socket.SOCK_STREAM`, `socket.SOCK_DGRAM`, `socket.SOCK_RAW` + * stream = TCP + * dgram = UDP + * raw = no protocol * Socket protocols: `socket.IPPROTO_UDP`, `socket.IPPROTO_TCP` * Socket options layers: `socket.SOL_SOCKET`, `socket.SOL_LORA`, `socket.SOL_SIGFOX` * IP socket options: `socket.SO_REUSEADDR` @@ -60,9 +63,7 @@ Sockets are automatically closed when they are garbage-collected, but it is reco Bind the `socket` to `address`. The socket must not already be bound. The `address` parameter must be a tuple containing the IP address and the port. -{{% hint style="info" %}} -In the case of LoRa sockets, the address parameter is simply an integer with the port number, for instance: `s.bind(1)` -{{% /hint %}} +>In the case of LoRa sockets, the address parameter is simply an integer with the port number, for instance: `s.bind(1)` #### socket.listen(\[backlog\]) @@ -122,11 +123,9 @@ Return a file object associated with the socket. The exact returned type depends The socket must be in blocking mode; it can have a timeout, but the file object's internal buffer may end up in a inconsistent state if a timeout occurs. -{{% hint style="info" %}} -**Difference to CPython** +> **Difference to CPython** +>Closing the file object returned by `makefile()` **WILL** close the original socket as well. -Closing the file object returned by `makefile()` **WILL** close the original socket as well. -{{% /hint %}} #### socket.read(size) diff --git a/content/firmwareapi/pycom/expansionboards/sleep.md b/content/firmwareapi/pycom/expansionboards/sleep.md index bb92ce8..825d41b 100644 --- a/content/firmwareapi/pycom/expansionboards/sleep.md +++ b/content/firmwareapi/pycom/expansionboards/sleep.md @@ -10,44 +10,7 @@ This chapter describes the various methods for sleep and wakeup which are embedd ## Quick Usage Example -The following example is also available at [Sleep Wakeup Example Libraries GitHub repository](https://github.com/pycom/pycom-libraries/blob/master/examples/accelerometer_wake/main.py) - -```python - -#from pytrack import Pytrack -from pysense import Pysense -from LIS2HH12 import LIS2HH12 -import time - -#py = Pytrack() -py = Pysense() - -# display the reset reason code and the sleep remaining in seconds -# possible values of wakeup reason are: -# WAKE_REASON_ACCELEROMETER = 1 -# WAKE_REASON_PUSH_BUTTON = 2 -# WAKE_REASON_TIMER = 4 -# WAKE_REASON_INT_PIN = 8 - -print("Wakeup reason: " + str(py.get_wake_reason())) -print("Approximate sleep remaining: " + str(py.get_sleep_remaining()) + " sec") -time.sleep(0.5) - -# enable wakeup source from INT pin -py.setup_int_pin_wake_up(False) - -acc = LIS2HH12() - -# enable activity and also inactivity interrupts, using the default callback handler -py.setup_int_wake_up(True, True) - -# set the acceleration threshold to 2000mG (2G) and the min duration to 200ms -acc.enable_activity_interrupt(2000, 200) - -# go to sleep for 5 minutes maximum if no accelerometer interrupt happens -py.setup_sleep(300) -py.go_to_sleep() -``` +An example is available at [Sleep Wakeup Example Libraries GitHub repository](https://github.com/pycom/pycom-libraries/blob/master/examples/accelerometer_wake/main.py) and [here](/tutorials/expansionboards/sleep/) ## Methods diff --git a/content/firmwareapi/pycom/network/lte.md b/content/firmwareapi/pycom/network/lte.md index 2d29443..9807931 100644 --- a/content/firmwareapi/pycom/network/lte.md +++ b/content/firmwareapi/pycom/network/lte.md @@ -37,8 +37,8 @@ The Sequans modem used on Pycom's cellular enabled modules can only work in one ## AT Commands -The AT commands for the Sequans Monarch modem on the GPy/FiPy are available in a PDF file. - AT Commands for Sequans +The AT commands for the Sequans Monarch modem on the GPy/FiPy are available in a [PDF file](/gitbook/assets/Monarch-LR5110-ATCmdRefMan-rev6_noConfidential.pdf). + ## Constructors diff --git a/content/firmwareapi/pycom/pycom.md b/content/firmwareapi/pycom/pycom.md index fbb363f..667052b 100644 --- a/content/firmwareapi/pycom/pycom.md +++ b/content/firmwareapi/pycom/pycom.md @@ -154,7 +154,7 @@ data = pulses_get(pin, 100) #### pycom.ota\_finish() -Perform a firmware update. These methods are internally used by a firmware update though FTP. The update starts with a call to `ota_start()`, followed by a series of calls to `ota_write(buffer)`, and is terminated with `ota_finish()`. After reset, the new image gets active. `buffer` shall hold the image data to be written, in arbitrary sizes. A block size of 4096 is recommended. +Perform a firmware update. These methods are internally used by a firmware update through FTP. The update starts with a call to `ota_start()`, followed by a series of calls to `ota_write(buffer)`, and is terminated with `ota_finish()`. After reset, the new image gets active. `buffer` shall hold the image data to be written, in arbitrary sizes. A block size of 4096 is recommended. Example: @@ -197,5 +197,11 @@ Instead of reading the data to be written from a file, it can obviously also be _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. +* `reset` Set `True` to reset target after updating the `bootmgr` options, `False` for not resetting. + +#### pycom.diff_update_enabled() + +Provides the status of the differential update feature. Returns `True` if differential update is enabled and `False` otherwise. `DIFF_UPDATE_ENABLED` build flag can be used to enable the differential update feature. + +> Note: This function is only available in the firmware versions which support differential update feature. If you get an exception while calling this function, your firmware version does not support this feature. diff --git a/content/gettingstarted/_index.md b/content/gettingstarted/_index.md index 2739d67..914cf81 100644 --- a/content/gettingstarted/_index.md +++ b/content/gettingstarted/_index.md @@ -22,71 +22,69 @@ In the following guide, we will explain the basic process to get started using y ## Step 1: Setting up the hardware -Congratulations on your Pycom module! In the first part of this getting started guide, we will take you through setting up your device. Firstly we will cover how to connect the module to your computer via USB. +In the first part of this getting started guide, we will take you through setting up your device. Firstly we will cover how to connect the module to your computer via USB. -#### Connect your board to your computer through USB +### Connect your board to your computer through USB -This step works the same for all our development boards and expansion boards. Insert your development board (Lopy, Wipy, etc.) into the expansion board (Pytrack, Pysense, etc.) with the reset button and RGB LED above the USB connector like shown below. Connect an USB cable to the USB port and your computer. Now, you can talk to your device through USB, but we still need some software to upload your first program! +This step works the same for all our development boards and expansion boards. Insert your development board (Lopy, Wipy, etc.) into the expansion board (Pytrack, Pysense, Expansion board etc.) with the reset button and RGB LED above the USB connector like shown below. Connect an USB cable to the USB port and your computer. Now, you can talk to your device through USB, but we still need some software to upload your first program! ![](/gitbook/assets/expansion_board_3_lopy4.png) >Note: If you do not have an expansion board, you are able to use a [USB-Serial converter](/gettinstarted/programming/usbserial/) or [WiFi](/gettingstarted/programming/ftp/) to connect. -# Step 2: Setting up your computer -Now that your module is successfully connected, you will need to install some software on your computer to interface with it. For this, we use Pymakr, a plugin for both Visual Studio Code or Atom IDE. Through one of the environments, we can connect to the board and talk python! Follow the link below for the installation instructions: +## Step 2: Setting up your computer + +Now that your module is successfully connected, you will need to install some software on your computer to interface with it. For this, we use Pymakr, a plugin for both Visual Studio Code and Atom IDE. Through either one of the environments, we can connect to the board and talk Python! + +Follow the link below for the installation instructions: - [Atom](/gettingstarted/software/atom/) - [VS Code](/gettingstarted/software/vscode/) -Once you have installed and opened the IDE, the board should automatically show up in the terminal. If not, check if any of your other plugins are in conflict. +Once you have installed and opened the IDE, the board should automatically show up in the terminal. If not, check if any of your other plugins are in conflict. If everything is correct, the REPL (Read Evaluate Print Loop) terminal will show the classic Python `>>>`. -If everything is correct, the terminal will show `>>>`. +>Note: If your device does not get recognized the first time on Windows, check if you need [additional drivers](/gettingstarted/software/drivers/) -# Step 3: Programming your module +## Step 3: Programming your module -Now that you have a connected module and all the required software installed it is time to begin programming your device! +Now that you have connected your device and installed Pymakr, it is time to begin programming your device! + +### Running your first code +If you have any experience with python, you know that the `>>>` means we can start typing commands! Type the following commands in the REPL terminal: +```python +>>> import pycom +>>> pycom.heartbeat(False) +>>> pycom.rgbled(0x330033) +``` +This will turn the RGB LED on your device purple! Notice that the REPL does not give any feedback. Only when we make a mistake, or ask it to return something will it give us a response. -In this first example, we will make the on-board RGB LED flash different colors. ### Creating a project in Pymakr +In this first project, we will make the on-board RGB LED flash different colors. 1. Firstly you will need to create a new, empty, directory on your computer. For this example we will create one called `RGB-Blink`. - -2. Next you will need to open either Atom or Visual Studio Code depending on which you setup previously. - -3. Once the text editor has loaded you will need to click `File` > `Open`, and open the directory you created in step 1 - -If you are using Atom, it is important to check at this point that Atom has successfully identified the project. The name of the directory you created in step 1 (`RGB-Blink` in this case) should be shown in the Pymakr pane like so: - -![](/gitbook/assets/atom_project.png) - ->If this is not the case you can press `alt-ctrl-r` on Windows/Linux or `ctrl-alt-cmd-l` on macOS, in order to reload Atom and fix the issue. - - -4. Now that you have created a poject, we need to add some files. A standard MicroPython project will have a `lib` folder for additional libraries, and two python files: `main.py` and `boot.py`. - +2. Open the project folder you have created in your IDE. +3. Now, we will need to add some files. A standard MicroPython project will have a `lib` folder for additional libraries, and two python files: `main.py` and `boot.py`. * `main.py` This script runs directly after `boot.py` and should contain the main code you wish to run on your device. - * `boot.py` This is the first script that runs on your module when it turns on. This is often used to connect a module to a network without cluttering up the `main.py` file. As a beginner you generally do not need to use a `boot.py`. + * It is often a good idea to split out re-usable code into libraries. If you want to create or use libraries created by others, you will need to create a `lib` directory and put the library files in this. It is important that you put `.py` files directly into `lib` rather than creating a directory tree. For example, the extra sensor libraries for the Pytrack, Pysense and Pyscan are put in this folder. In this example, we will not use it. - * It is often a good idea to split out re-usable code into libraries. If you want to create or use libraries created by others, you will need to create a `lib` directory and put the library files in this. It is important that you put `.py` files directly into `lib` rather than creating a directory tree. By default MicroPython will not detect any libraries within sub-directories. -Your file structure should look something like this: -![]() +#### Controlling the on-board RGB LED -### Controlling the on-board RGB LED - -Now that you have setup and configured your project, we can move on to programming your module. The first thing we will need to do is import some libraries in order to interact with the on-board LED. The Pycom firmware comes with a large amount of libraries for standard functionality built-in. You can find out more about these in the [API documentation](/firmwareapi/introduction). For this example you will need to open the `main.py` file and add the following code: +Now that you have setup and configured your project, we can move on to programming your module. The first thing we will need to do is import some libraries in order to interact with the on-board LED. The Pycom firmware comes with a large amount of built-in modules. You can find out more about these in the [API documentation](/firmwareapi/introduction). For this example you will need to open the `main.py` file and add the following code: ```python import pycom import time ``` -This will import two libraries, `Pycom` which is responsible for Pycom specific features, such as the on-board LED and `time` which is a standard library used timing and delays. +This will import two libraries, `pycom` which is responsible for Pycom specific features, such as the on-board LED and `time` which is a standard library used for timing and delays. -You may have noticed that when you power up your Pycom module, the on-board LED blinks blue on a regular basis. This "heartbeat" is used as a way of know that your module has powered up and started correctly. Before we can change the colour of this LED we need to disable this heart beat. Below your imports you will need to add the following: +>You may have noticed that when you power up your Pycom module, the on-board LED blinks blue on a regular basis. This "heartbeat" is used as a way of know that your module has powered up and started correctly. + +Before we can change the colour of this LED we need to disable this heart beat. Below your imports you will need to add the following: ```python @@ -94,9 +92,9 @@ pycom.heartbeat(False) ``` -Now it's time to test your code. On the Pymakr pane/bottom of the window you will see a `run` button. (If you haven't connected to your device yet, you will need to do that first). When you click the run button, the code in the currently open file will be executed on the device, but it won't copy it to the device. After running this code, you should see that that on-board LED stops blinking blue. +Now it's time to test your code. On the Pymakr pane, you will see a `run` button, but als an `upload (to device)` button. For now, we will use `run`. -Now that we can confirm the device is connected and Pymakr is able to run code on it, we can complete our script to blink the LED like so: +After running the example code above, you should see that that on-board LED stops blinking blue. Now, we can complete our script to blink the LED like so: ```python import pycom @@ -114,20 +112,19 @@ while True: time.sleep(1) ``` -Once you run the above script, it will run forever. You will notice this prevents you from accessing the interactive REPL on the device (You cannot see the `>>>` prompt). In order to stop the script, click onto the Pymakr terminal, and press `ctrl-c` on your keyboard. This should stop the script running and return you to the interactive REPL. +Once you run the above script, it will run forever (due to the infinite `While`-loop). In order to stop the script, click onto the Pymakr terminal, and press `ctrl-c` on your keyboard. This stops the script and returns to the interactive REPL. Great work, the RGB-LED on your device should now blink in red, green and blue ### Uploading to your module -In the previous section we got code running on on your Pycom module using the `run` feature of Pymakr. This is useful for quick testing but has a couple of drawbacks. Firstly the code does not remain on the device permanently. If you reboot the device, it will no longer be running your code. Secondly, it will only work if you are using libraries built into the firmware. If you need any extra libraries, these need to be copied to the device first. This is where the `upload` feature comes in. If instead of `run` you click `upload`, Pymakr will upload all the files in the project (so long as their type is in the `sync_file_types` setting for your project). These then persist on your device even between reboots, and allows you to use libraries from the `lib` folder in your project. - +In the previous section we got code running on on your Pycom module using the `run` feature of Pymakr. This is useful for quick testing but has a couple of drawbacks. Firstly the code does not remain on the device permanently. If you reboot the device, it will no longer be running your code. Secondly, it will only work if you are using libraries built into the firmware. If you need any extra libraries, these need to be copied to the device first. This is where the `upload` feature comes in. If instead of `run` you click `upload`, Pymakr will upload all the files in the project. These then persist on your device even between reboots, and allows you to use libraries from the `lib` folder in your project. If you need to remove files from your device you can use the following commands: ```python -import os -os.fsformat('/flash') +>>> import os +>>> os.fsformat('/flash') ``` ## Getting started with @@ -141,6 +138,7 @@ From here on, you can continue to use the additional features of your expansionb # Step 4: Further reading Now that we got the basic example running, you can continue with the links below. + * [More examples](/tutorials/) * [Documentation](/firmwareapi/) diff --git a/content/gettingstarted/installation/pymakr.md b/content/gettingstarted/installation/pymakr.md deleted file mode 100644 index a8fc91c..0000000 --- a/content/gettingstarted/installation/pymakr.md +++ /dev/null @@ -1,17 +0,0 @@ ---- -title: "Pymakr" -aliases: - - gettingstarted/installation/pymakr.html - - gettingstarted/installation/pymakr.md - - chapter/gettingstarted/installation/pymakr ---- - -![](/gitbook/assets/pymakr-logo-1.png) - -## Pymakr Plugins - -To make it as easy as possible Pycom has developed a plugin for two popular text editors, called Pymakr. These plugins have been built and are available for the following platforms: - -- {{% refname "/pymakr/installation/atom" %}} - -- {{% refname "/pymakr/installation/vscode" %}} diff --git a/content/gettingstarted/programming/safeboot.md b/content/gettingstarted/programming/safeboot.md index a0e3d0b..9195ce3 100644 --- a/content/gettingstarted/programming/safeboot.md +++ b/content/gettingstarted/programming/safeboot.md @@ -8,10 +8,6 @@ aliases: If powering up normally or upon pressing the reset button, a Pycom module will boot into standard mode; the `boot.py` file will be executed first, followed by `main.py`. It is possible to alter the boot procedure of the module by tying certain pins `high` or `low` when the module boots. -## Bootloader - -If you updated your device before using it, you have already put the device into bootloader mode. This is achieved by connecting `G23` to `GND` while the device boots. If you used a Pysense/Pytrack to update, it did this automatically for you. You only need to put your Pycom module into bootloader mode if you are updating its firmware, or are programming your own low level code. This is not required if you are updating your MicroPython code. - ## Safe Boot Some times the code you have written will prevent you gaining access to the REPL or prevent you updating your code. Some example may be: @@ -37,9 +33,7 @@ If problems occur within the filesystem or you wish to factory reset your module >>> os.fsformat('flash') ``` -{{% hint style="danger" %}} -Be aware, resetting the flash filesystem will delete all files inside the internal device storage (not the SD card) and they cannot be recovered. -{{% /hint %}} +> Be aware, formatting the flash filesystem will delete all files inside the internal device storage (not the SD card) and they cannot be recovered. ## Reset diff --git a/content/gettingstarted/software/vscode.md b/content/gettingstarted/software/vscode.md index a4bcab9..a421764 100644 --- a/content/gettingstarted/software/vscode.md +++ b/content/gettingstarted/software/vscode.md @@ -8,27 +8,29 @@ aliases: Pycom supports Microsoft's Visual Studio Code IDE platform with the Pymakr Plugin. -First [download and install Visual Studio Code](https://code.visualstudio.com/). You will also need NodeJS installed on your PC. Please download the latest LTS version available [from the NodeJS website.](https://nodejs.org/) +1. First [download and install Visual Studio Code](https://code.visualstudio.com/). + +2. You will also need NodeJS installed on your PC. Please download the latest LTS version available [from the NodeJS website.](https://nodejs.org/) Please follow these steps to install the [Pymakr VSCode Extension](https://marketplace.visualstudio.com/items?itemName=pycom.Pymakr): -1. Ensure that you have the latest VSCode installed and open. +3. Ensure that you have the latest VSCode installed and open. ![](/gitbook/assets/vsc_setup_step_1-1.png) -2. Navigate to the Extensions page, using the 5th button in the left navigation +4. Navigate to the Extensions page, using the 5th button in the left navigation ![](/gitbook/assets/vsc_setup_step_2-1.png) -3. Search for `Pymakr` and click the install button next to it. +5. Search for `Pymakr` and click the install button next to it. ![](/gitbook/assets/vsc_setup_step_3.png) -4. Within a few minutes, a reload button should appear. Press it to reload VSCode. +6. Within a few minutes, a reload button should appear. Press it to reload VSCode. ![](/gitbook/assets/vsc_setup_step_4.png) -5. That's it! You've installed the Pymakr Extension for VSCode +7. That's it! You've installed the Pymakr Extension for VSCode ![](/gitbook/assets/vsc_setup_step_5.png) @@ -36,17 +38,13 @@ Please follow these steps to install the [Pymakr VSCode Extension](https://marke After installing the Pymakr Plugin, you need to take a few seconds to configure it for first time use. Please follow these steps: -1. Connect your Pycom device to your computer via USB. If you are using an - - Expansion Board, and have just finished a firmware upgrade, be sure to **Remove** - - **the wire between GND and G23** and reset your device by pressing the button. +1. Connect your Pycom device to your computer via USB. 2. Open Visual Studio Code and ensure that the Pymakr Plugin has correctly installed. ![](/gitbook/assets/vsc_config_step_1-1.png) -3. Click `All commands` on the bottom of the Visual Studio Code window +3. Generally, your device will be auto-detected. If this does not work, click `All commands` on the bottom of the Visual Studio Code window ![](/gitbook/assets/vsc_config_step_2-1.png) @@ -56,16 +54,4 @@ After installing the Pymakr Plugin, you need to take a few seconds to configure 5. This will list the available serial ports. If Pymakr is able to auto-detect which to use, this will be copied to your clipboard. If not please manually copy the correct serial port. -![](/gitbook/assets/vsc_config_step_4.png) - -6. Once again click `All commands`, then click `Pymakr > Global Settings`. This will open a JSON file. Paste the serial address you copied earlier into the field `address` and save the file. - -![](/gitbook/assets/vsc_config_step_5-1.png) - -7. Finally close the JSON file, click `All commands`, then `Pymakr > Connect` to connect your device. The Pymakr console should show three arrows `>>>`, indicating that you are connected - -![](/gitbook/assets/vsc_config_step_6.png) - -These settings can also be applied on a per project basis by clicking `All commands` then `Pymakr > Project Settings`. This will open a JSON file which you can edit to enter your desired settings for the currently open project. - ->Note: This process is easiest with either a Pycom Expansion Board or a Pytrack/Pysense as the addresses are automatically selected. For external products such as FTDI USB Serial Cables, the serial address may need to be copied manually. Additionally, the reset button on the device may also need to be pressed before a connection message appears. \ No newline at end of file +![](/gitbook/assets/vsc_config_step_4.png) \ No newline at end of file diff --git a/content/tutorials/basic/print.md b/content/tutorials/basic/print.md index 8b5f437..9c73310 100644 --- a/content/tutorials/basic/print.md +++ b/content/tutorials/basic/print.md @@ -19,4 +19,12 @@ print("\n") #feed a new line print("\t tabbed in") #you can specify a variable into the string as well! print("hello world: " + str(machine.rng()) + " random number" ) +#or use format +print("hello world: {} {}".format(machine.rng(), " random number")) +#you can also ask for user input +result = input("what's up?\n") +print(result) +# and lastly, you can also print like this,which is very useful when printing large amounts of data +i = 10 +print(1,2,3,'e',i) ``` \ No newline at end of file diff --git a/content/tutorials/basic/sleep.md b/content/tutorials/basic/sleep.md index 9c8550b..15130e3 100644 --- a/content/tutorials/basic/sleep.md +++ b/content/tutorials/basic/sleep.md @@ -82,34 +82,4 @@ print("This will never be printed") >Note: Using `deepsleep()` will also stop the USB connection. Be wary of that when trying to upload new code to the device! -#### Other methods - -The expansionboards (Pysense 2.0 X, and Pytrack 2.0 X, DeepSleep shield) use a different mechanism to put the controller to sleep. A separate controller on the expansion board will put the main controller to sleep. This will actually cut all power from the module for the set amount of time, hard resetting it. Cutting power to the expansion board will work as well. Using this method, we can still recover the wake up reason and remaining sleep time. The example below works was written for a Pysense, but works on any of the boards by changing the first lines - -```python -from pysense import Pysense -py = Pysense() -py.setup_sleep(10) # set sleep time of 10 seconds -py.go_to_sleep() -print("this will never be printed") -``` -Using this method, we can also wake the board using the accelerometer and external pin `P6` by rising (`True`) or falling (`False`) edge - -```python -from pysense import Pysense -from LIS2HH12 import LIS2HH12 - -py = Pysense() -acc = LIS2HH12() - -# enable activity and also inactivity interrupts, using the default callback handler -py.setup_int_wake_up(True, True) - -# set the acceleration threshold to 2000mG (2G) and the min duration to 200ms -acc.enable_activity_interrupt(2000, 200) - -py.set_int_pin_wake_up(True) #wake up on rising edge on pin 6 of the expansion header - -py.go_to_sleep()# the device will sleep indefinitely, until pin 6 goes high, or the accelerometer is triggered -``` -LTE Power saving mode (PSM) \ No newline at end of file +For the Pysense, Pytrack and Pyscan expansionboards, an additional sleep function is available. You can find out more about that [here](../expansionboards/sleep/) \ No newline at end of file diff --git a/content/tutorials/expansionboards/_index.md b/content/tutorials/expansionboards/_index.md index e8af92a..2fb20d4 100644 --- a/content/tutorials/expansionboards/_index.md +++ b/content/tutorials/expansionboards/_index.md @@ -6,13 +6,18 @@ aliases: - chapter/tutorials/expansionboards disable_breadcrumbs: true --- ->Note: Before using the Pysense, Pytrack or Pyscan board, check the [GitHub](https://github.com/pycom/pycom-libraries) for the latest version of the libraries. -Make a folder inside your project folder and call it `lib`. Then, copy the appropiate libraries from the github repository to the folder. Always copy the `pysense.py`, `pytrack.py` or `pyscan.py` *and* `pycoproc.py` files if you want to use the boards' functions +>Note: Before using the Pysense, Pytrack and Pyscan boards, check the [GitHub](https://github.com/pycom/pycom-libraries) for the latest version of the libraries. + +To use the Pysense, Pytrack or Pyscan, make a folder inside your project folder and call it `lib`. Then, copy the appropiate sensor libraries from the github repository to the folder. Always copy the `pysense.py` or `pytrack.py` and `pycoproc.py` files if you want to use the boards' functions. The `pycoproc.py` library also allows for a special sleep mode. An example for this is provided [here](../expansionboards/sleep/) + * [Pygate](../expansionboards/pygate/) * [Pysense](../expansionboards/pysense/) * [Pysense 2.0 X](../expansionboards/pysense2/) * [Pytrack](../expansionboards/pytrack/) * [Pytrack 2.0 X](../expansionboards/pytrack2/) -* [Pyscan](../expansionboards/pyscan/) \ No newline at end of file +* [Pyscan](../expansionboards/pyscan/) + + +>Note: Make sure to click `upload to device` to be able to `import` the appropriate libraries in your code! diff --git a/content/tutorials/expansionboards/pygate.md b/content/tutorials/expansionboards/pygate.md index 66a1d80..eab0077 100644 --- a/content/tutorials/expansionboards/pygate.md +++ b/content/tutorials/expansionboards/pygate.md @@ -101,7 +101,8 @@ buf = fp.read() # Start the Pygate machine.pygate_init(buf) - +# disable degub messages +# machine.pygate_debug_level(1) ``` A sample `config.json` file for gateway configuration in EU868 region: diff --git a/content/tutorials/expansionboards/pysense.md b/content/tutorials/expansionboards/pysense.md index a71ee97..577ee81 100644 --- a/content/tutorials/expansionboards/pysense.md +++ b/content/tutorials/expansionboards/pysense.md @@ -6,6 +6,64 @@ aliases: - chapter/tutorials/pysense --- +## All sensors +>Note: You can find this example in the [GitHub repository](https://github.com/pycom/pycom-libraries/tree/master/pysense). Over there, you can also find the relevant libraries. +```python +#!/usr/bin/env python +# +# Copyright (c) 2020, Pycom Limited. +# +# This software is licensed under the GNU GPL version 3 or any +# later version, with permitted additional terms. For more information +# see the Pycom Licence v1.0 document supplied with this file, or +# available at https://www.pycom.io/opensource/licensing +# + +# See https://docs.pycom.io for more information regarding library specifics + +import time +import pycom +from pysense import Pysense +import machine + +from LIS2HH12 import LIS2HH12 +from SI7006A20 import SI7006A20 +from LTR329ALS01 import LTR329ALS01 +from MPL3115A2 import MPL3115A2,ALTITUDE,PRESSURE + +pycom.heartbeat(False) +pycom.rgbled(0x0A0A08) # white + +py = Pysense() + +mp = MPL3115A2(py,mode=ALTITUDE) # Returns height in meters. Mode may also be set to PRESSURE, returning a value in Pascals +print("MPL3115A2 temperature: " + str(mp.temperature())) +print("Altitude: " + str(mp.altitude())) +mpp = MPL3115A2(py,mode=PRESSURE) # Returns pressure in Pa. Mode may also be set to ALTITUDE, returning a value in meters +print("Pressure: " + str(mpp.pressure())) + + +si = SI7006A20(py) +print("Temperature: " + str(si.temperature())+ " deg C and Relative Humidity: " + str(si.humidity()) + " %RH") +print("Dew point: "+ str(si.dew_point()) + " deg C") +t_ambient = 24.4 +print("Humidity Ambient for " + str(t_ambient) + " deg C is " + str(si.humid_ambient(t_ambient)) + "%RH") + + +lt = LTR329ALS01(py) +print("Light (channel Blue lux, channel Red lux): " + str(lt.light())) + +li = LIS2HH12(py) +print("Acceleration: " + str(li.acceleration())) +print("Roll: " + str(li.roll())) +print("Pitch: " + str(li.pitch())) + +print("Battery voltage: " + str(py.read_battery_voltage())) + +time.sleep(3) +py.setup_sleep(10) +py.go_to_sleep() +``` ## Accelerometer This basic example shows how to read pitch and roll from the on-board accelerometer and output it in comma separated value (CSV) format over serial. @@ -24,7 +82,7 @@ while True: time.sleep_ms(100) ``` -![](/gitbook/assets/accelerometer_visualiser.png) - -If you want to visualise the data output by this script a Processing sketch is available [here](https://github.com/pycom/pycom-libraries/tree/master/examples/pytrack_pysense_accelerometer) that will show the board orientation in 3D. +>Note: Use [Processing](https://processing.org/) to visualize the orientation of your board using the example. You can find the Processing sketch [here](https://github.com/pycom/pycom-libraries/tree/master/examples/pytrack_pysense_accelerometer) +> +>![](/gitbook/assets/accelerometer_visualiser.png) diff --git a/content/tutorials/expansionboards/pysense2.md b/content/tutorials/expansionboards/pysense2.md index e69de29..22a785c 100644 --- a/content/tutorials/expansionboards/pysense2.md +++ b/content/tutorials/expansionboards/pysense2.md @@ -0,0 +1,66 @@ +--- +title: "Pysense 2.0 X Examples" +aliases: + - tutorials/pysense.html + - tutorials/pysense.md + - chapter/tutorials/pysense +--- +The Pysense 2.0 X has an external header that allows you to attach all kinds of sensors. +## All sensors +>Note: You can find this example in the [GitHub repository](https://github.com/pycom/pycom-libraries/tree/master/pysense-2). Over there, you can also find the relevant libraries. +```python +#!/usr/bin/env python +# +# Copyright (c) 2020, Pycom Limited. +# +# This software is licensed under the GNU GPL version 3 or any +# later version, with permitted additional terms. For more information +# see the Pycom Licence v1.0 document supplied with this file, or +# available at https://www.pycom.io/opensource/licensing +# + +# See https://docs.pycom.io for more information regarding library specifics + +import time +import pycom +from pysense import Pysense +import machine + +from LIS2HH12 import LIS2HH12 +from SI7006A20 import SI7006A20 +from LTR329ALS01 import LTR329ALS01 +from MPL3115A2 import MPL3115A2,ALTITUDE,PRESSURE + +pycom.heartbeat(False) +pycom.rgbled(0x0A0A08) # white + +py = Pysense() + +mp = MPL3115A2(py,mode=ALTITUDE) # Returns height in meters. Mode may also be set to PRESSURE, returning a value in Pascals +print("MPL3115A2 temperature: " + str(mp.temperature())) +print("Altitude: " + str(mp.altitude())) +mpp = MPL3115A2(py,mode=PRESSURE) # Returns pressure in Pa. Mode may also be set to ALTITUDE, returning a value in meters +print("Pressure: " + str(mpp.pressure())) + + +si = SI7006A20(py) +print("Temperature: " + str(si.temperature())+ " deg C and Relative Humidity: " + str(si.humidity()) + " %RH") +print("Dew point: "+ str(si.dew_point()) + " deg C") +t_ambient = 24.4 +print("Humidity Ambient for " + str(t_ambient) + " deg C is " + str(si.humid_ambient(t_ambient)) + "%RH") + + +lt = LTR329ALS01(py) +print("Light (channel Blue lux, channel Red lux): " + str(lt.light())) + +li = LIS2HH12(py) +print("Acceleration: " + str(li.acceleration())) +print("Roll: " + str(li.roll())) +print("Pitch: " + str(li.pitch())) + +print("Battery voltage: " + str(py.read_battery_voltage())) + +# time.sleep(3) +# py.setup_sleep(10) +# py.go_to_sleep() +``` \ No newline at end of file diff --git a/content/tutorials/expansionboards/pytrack.md b/content/tutorials/expansionboards/pytrack.md index fc599d3..56b8ae7 100644 --- a/content/tutorials/expansionboards/pytrack.md +++ b/content/tutorials/expansionboards/pytrack.md @@ -7,11 +7,9 @@ aliases: --- Both the Pysense and Pytrack use the same accelerometer. Please see the [Pysense Examples](../pysense) to see how to use the accelerometer. +>Note: You can find this example in the [GitHub repository](https://github.com/pycom/pycom-libraries/tree/master/pytrack). Over there, you can also find the relevant libraries. ->Note: You need to add the libraries from [here](https://github.com/pycom/pycom-libraries/tree/master/pytrack) in the `lib` folder of your project before the example will work. You can also find the example in there. - - -## Example +## GPS Example ```python diff --git a/content/tutorials/expansionboards/pytrack2.md b/content/tutorials/expansionboards/pytrack2.md index e69de29..bd375d9 100644 --- a/content/tutorials/expansionboards/pytrack2.md +++ b/content/tutorials/expansionboards/pytrack2.md @@ -0,0 +1,70 @@ +--- +title: "Pytrack 2.0 X Examples" +aliases: + - tutorials/pysense.html + - tutorials/pysense.md + - chapter/tutorials/pysense +--- +The Pytrack 2.0 X has an external header that allows you to attach all kinds of sensors. +## All sensors +>Note: You can find this example in the [GitHub repository](https://github.com/pycom/pycom-libraries/tree/master/pytrack-2). Over there, you can also find the relevant libraries. +```python +#!/usr/bin/env python +# +# Copyright (c) 2020, Pycom Limited. +# +# This software is licensed under the GNU GPL version 3 or any +# later version, with permitted additional terms. For more information +# see the Pycom Licence v1.0 document supplied with this file, or +# available at https://www.pycom.io/opensource/licensing +# + +import machine +import math +import network +import os +import time +import utime +import gc +import pycom +from machine import RTC +from machine import SD +from L76GNSS import L76GNSS +from pytrack import Pytrack + +pycom.heartbeat(False) +pycom.rgbled(0x0A0A08) # white + +time.sleep(2) +gc.enable() + +# setup rtc +rtc = machine.RTC() +rtc.ntp_sync("pool.ntp.org") +utime.sleep_ms(750) +print('\nRTC Set from NTP to UTC:', rtc.now()) +utime.timezone(7200) +print('Adjusted from UTC to EST timezone', utime.localtime(), '\n') + +py = Pytrack() + +time.sleep(1) +l76 = L76GNSS(py, timeout=30, buffer=512) + +# sd = SD() +# os.mount(sd, '/sd') +# f = open('/sd/gps-record.txt', 'w') + +# while (True): +for _ in range(5): + coord = l76.coordinates() + #f.write("{} - {}\n".format(coord, rtc.now())) + print("{} - {} - {}".format(coord, rtc.now(), gc.mem_free())) + +""" +# sleep procedure +time.sleep(3) +py.setup_sleep(10) +py.go_to_sleep() +""" +``` \ No newline at end of file diff --git a/content/tutorials/expansionboards/sleep.md b/content/tutorials/expansionboards/sleep.md new file mode 100644 index 0000000..e5b4dda --- /dev/null +++ b/content/tutorials/expansionboards/sleep.md @@ -0,0 +1,51 @@ +--- +title: 'Sleep' +--- + +The expansionboards (Pysense 2.0 X, and Pytrack 2.0 X, DeepSleep shield) use a different mechanism to put the controller to sleep. A separate controller on the expansion board will put the main controller to sleep. This will actually cut all power from the module for the set amount of time, hard resetting it. Cutting power to the expansion board will work as well. Using this method, we can still recover the wake up reason and remaining sleep time. The example below works was written for a Pysense, but works on any of the boards by changing the first lines + +```python +from pysense import Pysense +py = Pysense() +py.setup_sleep(10) # set sleep time of 10 seconds +py.go_to_sleep() +print("this will never be printed") +``` +Using this method, we can also wake the board using the accelerometer interrupt method: + +```python + +#from pytrack import Pytrack +from pysense import Pysense +from LIS2HH12 import LIS2HH12 +import time + +#py = Pytrack() +py = Pysense() + +# display the reset reason code and the sleep remaining in seconds +# possible values of wakeup reason are: +# WAKE_REASON_ACCELEROMETER = 1 +# WAKE_REASON_PUSH_BUTTON = 2 +# WAKE_REASON_TIMER = 4 +# WAKE_REASON_INT_PIN = 8 + +print("Wakeup reason: " + str(py.get_wake_reason())) +print("Approximate sleep remaining: " + str(py.get_sleep_remaining()) + " sec") +time.sleep(0.5) + +# enable wakeup source from INT pin +py.setup_int_pin_wake_up(False) + +acc = LIS2HH12() + +# enable activity and also inactivity interrupts, using the default callback handler +py.setup_int_wake_up(True, True) + +# set the acceleration threshold to 2000mG (2G) and the min duration to 200ms +acc.enable_activity_interrupt(2000, 200) + +# go to sleep for 5 minutes maximum if no accelerometer interrupt happens +py.setup_sleep(300) +py.go_to_sleep() +``` \ No newline at end of file diff --git a/content/tutorials/networkprotocols/_index.md b/content/tutorials/networkprotocols/_index.md index 8f71cb9..f469cbc 100644 --- a/content/tutorials/networkprotocols/_index.md +++ b/content/tutorials/networkprotocols/_index.md @@ -6,8 +6,9 @@ aliases: --- Using our devices, several different network protocols can be used. We have grouped them in different categories. Not all examples will work with every network. Generally, examples are compatible with different networks. -**Protecols** +**Protocols** +* [WiFi Sniffer](../networkprotocols/wifisniffer/) * [HTTPS](../networkprotocols/https/) * [MQTT](../networkprotocols/mqtt/) * [NTP](../networkprotocols/ntp/) diff --git a/content/tutorials/networkprotocols/httpclient.md b/content/tutorials/networkprotocols/httpclient.md new file mode 100644 index 0000000..726c53e --- /dev/null +++ b/content/tutorials/networkprotocols/httpclient.md @@ -0,0 +1,7 @@ +--- +Title: 'HTTP Client' +--- +In this example, we discuss how to access information served on the internet. Once you have connected to either WiFi or LTE, it is possible to access any webpage. Now there is no such thing as a webbrowser like Chrome or Firefox in your device, and the REPL is not that great at rendering webpages either, so we are mainly looking at the source of the page here. + +For example, we can use the socket to render +... \ No newline at end of file diff --git a/content/tutorials/networkprotocols/https.md b/content/tutorials/networkprotocols/https.md index 38b2d8f..8928ad7 100644 --- a/content/tutorials/networkprotocols/https.md +++ b/content/tutorials/networkprotocols/https.md @@ -5,7 +5,30 @@ aliases: - tutorials/all/https.md - chapter/tutorials/all/https --- +Using HTTPS adds Transport Layer Security (TLS) to your network traffic. The advantage is an encrypted connection between your device and the server. +## Basic example +```python +from network import WLAN #note that you can also use LTE +import socket +import ssl +import time + +wlan = WLAN() +wlan.init(mode=WLAN.STA, ssid='your ssid', auth=(WLAN.WPA2, 'your password')) +print("connecting", end='') +while not wlan.isconnected(): + time.sleep(0.25) + print(".", end='') + +print("connected") +print(wlan.ifconfig()) +s = socket.socket(usocket.AF_INET, usocket.SOCK_STREAM) +ss = ssl.wrap_socket(s) #adds TLS +ss.connect(socket.getaddrinfo('pycom.io', 443)[0][-1]) +rec = ss.recv(4096) +print(rec) +``` Basic connection using `ssl.wrap_socket()`. ```python @@ -15,6 +38,7 @@ import ssl s = socket.socket() ss = ssl.wrap_socket(s) ss.connect(socket.getaddrinfo('www.google.com', 443)[0][-1]) +ss.se ``` Below is an example using certificates with the blynk cloud. diff --git a/content/tutorials/networks/wifisniffer.md b/content/tutorials/networkprotocols/wifisniffer.md similarity index 100% rename from content/tutorials/networks/wifisniffer.md rename to content/tutorials/networkprotocols/wifisniffer.md diff --git a/content/tutorials/networks/_index.md b/content/tutorials/networks/_index.md index e69de29..264f0c0 100644 --- a/content/tutorials/networks/_index.md +++ b/content/tutorials/networks/_index.md @@ -0,0 +1,16 @@ +--- +title: 'Networks' + +--- + +The Pycom devices support several different types of networks. +We have the WiFi and Bluetooth connections: + +* [WiFi](../networks/wifi/) +* [Bluetooth Low Energy](../networks/ble/) +* [LoRa](../networks/lora/) +* [Sigfox]( ../networks/sigfox/) +* [LTE](../networks/lte/) +* [Ethernet](../networks/ethernet/) + +> If you are looking for examples on how to connect to different services, check [here](../networkprotocols/) \ No newline at end of file diff --git a/content/tutorials/networks/lora/_index.md b/content/tutorials/networks/lora/_index.md index d7d0c64..01fd4ba 100644 --- a/content/tutorials/networks/lora/_index.md +++ b/content/tutorials/networks/lora/_index.md @@ -4,6 +4,7 @@ aliases: --- The following tutorials demonstrate the use of the LoRa functionality on the LoPy. LoRa can work in 2 different modes; **LoRa-MAC** (which we also call Raw-LoRa) and **LoRaWAN** mode. +> Note: LoRa will not work with Pygate firmware loaded on your device. It will return a `/event_groups.c:498 (xEventGroupClearBits)- assert failed!` error. * **LoRaWAN mode** implements the full LoRaWAN stack for a class A device. It supports both OTAA and ABP connection methods, as well as advanced features like adding and removing custom channels to support "special" frequencies plans like the those used in New Zealand. There are two basic ways of accessing the LoraWAN network: * [LoRaWAN ABP](../lora/lorawan-abp/) diff --git a/content/tutorials/networks/lte/_index.md b/content/tutorials/networks/lte/_index.md index f4c9120..b4beb3c 100644 --- a/content/tutorials/networks/lte/_index.md +++ b/content/tutorials/networks/lte/_index.md @@ -14,29 +14,34 @@ import time import socket lte = LTE() +lte.init() +#some carriers have special requirements, check print(lte.send_at_cmd("AT+SQNCTM=?")) to see if your carrier is listed. #when using verizon, use #lte.init(carrier=verizon) #when usint AT&T use, #lte.init(carrier=at&t) #some carriers do not require an APN -#also, check the band settings, for some carriers they auto-configure. +#also, check the band settings with your carrier lte.attach(band=20, apn="your apn") +print("attaching..",end='') while not lte.isattached() time.delay(0.25) - print('.') + + print('.',end='') print(lte.send_at_cmd('AT!="fsm"')) # get the System FSM -print("LTE modem attached!") +print("attached!") + lte.connect() +print("connecting [##",end='') while not lte.isconnected(): time.sleep(0.25) - print('#') + print('#',end='') #print(lte.send_at_cmd('AT!="showphy"')) print(lte.send_at_cmd('AT!="fsm"')) -print("LTE modem connected!") +print("] connected!") print(socket.getaddrinfo('pycom.io', 80)) - lte.deinit() #now we can safely machine.deepsleep() ``` @@ -44,10 +49,31 @@ The last line of the script should return a tuple containing the IP address of t >Note: the first time, it can take a long while to attach to the network. +# LTE disconnecting +When the LTE disconnects in an unexpected situation, for example when the signal is lost, `lte.isconnected()` will still return `True`. Currently, there is a solution using the callback and handler function listed below: +```python +from network import LTE +import time +from sleep import sleep +import machine +def cb_handler(arg): + print("CB: LTE Coverage lost") + print("CB: sleep", s) + print("CB: deinit") + lte.deinit() + print("CB: reset") + machine.reset() + +lte.lte_callback(LTE.EVENT_COVERAGE_LOSS, cb_handler) + +``` # LTE Troubleshooting guide + + Below, we review the responses from `print(lte.send_at_cmd('AT!="fsm"'))`. If you are having trouble attaching to the network, or getting a connection up and running, this might give some direction into what you are looking for. We are mainly looking at the status of the top two indicators for now. 1. Before calling `lte.attach()`, the status will be `STOPPED`. + ``` SYSTEM FSM ========== @@ -184,6 +210,7 @@ Below, we review the responses from `print(lte.send_at_cmd('AT!="fsm"'))`. If yo | HP CAT FSM |IDLE | +--------------------------+--------------------+ ``` + * Firmware version: Use the following to check the version number: ```python diff --git a/content/updatefirmware/_index.md b/content/updatefirmware/_index.md index 983546c..c08e394 100644 --- a/content/updatefirmware/_index.md +++ b/content/updatefirmware/_index.md @@ -11,5 +11,6 @@ You can update the firmware of several different boards using different methods: * [Device](/updatefirmware/device/) * [Device (OTA)](/updatefirmware/ota/) +* [Device (Differential OTA)](/updatefirmware/diff_ota/) * [Expansion Board](/updatefirmware/expansionboard/) * [LTE Modem](/updatefirmware/ltemodem/) diff --git a/content/updatefirmware/diff_ota.md b/content/updatefirmware/diff_ota.md new file mode 100644 index 0000000..fb7dbc5 --- /dev/null +++ b/content/updatefirmware/diff_ota.md @@ -0,0 +1,61 @@ +--- +title: "Differential OTA Update" +aliases: + - updatefirmwate/diff_ota.html + - updatefirmwate/diff_ota.md + - chapter/updatefirmwate/diff_ota + +--- + +Differential update allows you to update your device using a differential update file (patch file) instead of a complete new binary. This can save a considerable amount of space and bandwidth while downloading the new firmware. The exact size of the patch file depends on the differences between the source and the target versions and it will usually be quite small when upgrading to a successive version. + +> Note: You can only perform the differential updates if your current firmware version supports this feature. The target can be any version above `1.20`. You can check whether this feature is enabled in your firmware or not by calling `pycom.diff_update_enabled()` function. + +## Generating a Differential Update File + +The differential update files can be generated by using our `DiffCreator` tool which uses `bsdiff`. +In order to generate the differential update file, you will need the following tools and files: + +* [DiffCreator](/gitbook/assets/DiffCreator.tar.gz) +* Old firmware version binary +* New firmware version binary + +> Note: The binary files used for this are the *.bin* files generated after the firmware is built. If you have downloaded the firmware as a compressed archive, you can decompress it to find the *.bin* file. + +1. Download the `DiffCreator` tool using the above link. +2. After extracting the contents of the `DiffCreator` archive, navigate to the directory with the terminal and type `make` to build the utility. +3. After building you can run the following command in the terminal to generate the patch file: + +``` +./diff_creator source.bin target.bin patch.bin +``` + +* `source.bin` is the current binary of your device, +* `target.bin` is the target binary +* `patch.bin` is the name of the patch file that you want to be generated. + + +> Note: replace the `.bin` filenames with the actual filenames. + +This will create the *patch.bin* file which can be used to upgrade your firmware instead of *target.bin* file. + + +## Using the Differential Update File + +To apply the differential update, use any of the methds described [here](../ota) by using your generated differential update file (e.g. patch.bin) as the new firmware binary. + +The following message will be displayed on REPL when a differential update file is detected by the device: + +``` +Differential Update Image detected. Restart the device to apply the patch. +``` + +After this, the device must be restarted so that the patch can be applied. After restart, you should see the following messages in REPL: + +``` +Patching the binary... +Patching SUCCESSFUL. +``` + +After patching is done, the device will restart again automatically and this time the updated firmware will be loaded. + diff --git a/content/updatefirmware/expansionboard.md b/content/updatefirmware/expansionboard.md index ab39728..8c6426d 100644 --- a/content/updatefirmware/expansionboard.md +++ b/content/updatefirmware/expansionboard.md @@ -8,9 +8,8 @@ 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 %}} +> 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. + The latest firmware DFU file can be downloaded from the links below: @@ -20,10 +19,9 @@ The latest firmware DFU file can be downloaded from the links below: * [Expansion Board DFU v3.1](https://software.pycom.io/findupgrade?key=expansion31.dfu&type=all&redirect=true) -{{% hint style="info" %}} - Make sure to choose the correct firmware version for your expansion board. both 3.0 and 3.1 versions have version numbers in the silkscreen on the back of the board. See the image below for examples highlighted in Red - ![](/gitbook/assets/expansion_board_version.png) -{{% /hint %}} + +> Make sure to choose the correct firmware version for your expansion board. both 3.0 and 3.1 versions have version numbers in the silkscreen on the back of the board. See the image below for examples highlighted in Red +>![](/gitbook/assets/expansion_board_version.png) While in the normal, application mode, the Pysense/Pytrack/Pyscan/Expansion Board v3 require a Serial USB CDC driver, in DFU, bootloader mode, the DFU driver is required. Below, the USB Product ID is depicted for each case. diff --git a/content/updatefirmware/ltemodem.md b/content/updatefirmware/ltemodem.md index e71df7b..bb178ef 100644 --- a/content/updatefirmware/ltemodem.md +++ b/content/updatefirmware/ltemodem.md @@ -24,27 +24,30 @@ The last 5 numbers define the firmware version. A higher number represents a new > Note: The prefered method for updating the LTE modem is using upgdiff- files, as these updates are faster. Check in the zip archive wheter a upgdiff- update for your version is available. When using a upgdiff- file, you do not need to use `updater.elf` +> Using `sqnsupgrade` does not currently work properly in the pygate firmware + There are several different ways to update the firmware of the LTE modem. -1. [Flash](/updatefirmware/ltemodem/#flash) -2. [SD card](/updatefirmware/ltemodem/#sd-card) -3. [USB](/updatefirmware/ltemodem/#usb) -4. [Wireless](/updatefirmware/ltemodem/#wireless) +1. [Flash](/updatefirmware/ltemodem/#flash) (slow) +2. [SD card](/updatefirmware/ltemodem/#sd-card) (fastest) +3. [USB](/updatefirmware/ltemodem/#usb) (medium) +4. [Wireless](/updatefirmware/ltemodem/#wireless) (slowest) >Note: In case of any failure or interruption to the process of LTE modem upgrade you can repeat the same steps **after doing a hard reset to the board (i.e disconnecting and reconnecting power), pressing the reset button is not enough.** The modem firmware files are password protected. In order to download them, head to https://forum.pycom.io and become a member (if you aren't already) and click on: -Announcements & News --> Announcements for members only --> the Firmware Files for the Sequans LTE modem are now secured or click [here](https://software.pycom.io/downloads/sequans2.html). +Announcements & News --> Announcements for members only --> the Firmware Files for the Sequans LTE modem are now secured to retrieve the credentials. You can find the firmwares listed [here](https://software.pycom.io/downloads/sequans2.html). ## Flash >Note: For Flash updates, we currently only support the use of upgdiff- files! If there is no upgdiff- file for your version available, try to use another method. -1. Copy the firmware update file you want to use in your project folder and click `upload to device` in the Pymakr plugin. Make sure the first 5 numbers match the current version of your modem firmware. +1. Copy the firmware update file you want to use in your project folder and click `upload to device` in the Pymakr plugin. Make sure the first 5 numbers match the current version of your modem firmware. Uploading might take a while because of the large filesize. + > Note: If the firmware does not sync to your device, open the Pymakr settings → project settings and add `"dup"` to the entry `"sync_file_types"`. This will create a `pymakr.conf` file in your project and allow you to sync `.dup` files to the device using pymakr. 2. After uploading the file, you can run the following commands - ```python - import sqnsupgrade - sqnsupgrade.run('upgdiff_old-to-new.dup') - ``` + ```python + import sqnsupgrade + sqnsupgrade.run('upgdiff_old-to-new.dup') + ``` 3. The update takes about 5 minutes. Note that the update may seem to 'stall' around 7-10% and again at 99%. This is completely normal. >Note: **Do not disconnect power to the module during the updating process** 4. The updater will show the new `SYSTEM VERSION` when it is done, and return control to REPL. @@ -71,13 +74,13 @@ Announcements & News --> Announcements for members only --> the Firmware Files f ```python import sqnsupgrade sqnsupgrade.run('/sd/upgdiff_old-to-new.dup') - #if this is not available, run the following instead - #sqnsupgrade.run('/sd/name.dup') - #If you are updating from version 33080, use this - #sqnsupgrade.run('/sd/name.dup', '/sd/updater.elf') + # if no upgdiff is available, run the following instead + # sqnsupgrade.run('/sd/name.dup') + # WARNING! If you are updating from version 33080, use the updater.elf file as well + # sqnsupgrade.run('/sd/name.dup', '/sd/updater.elf') ``` - >Note: Replace `name.dup` with the actual filename. There are different versions for `CAT-M1` and `NB-IoT` + >Note: Replace `name.dup` or `upgdiff_old-to-new.dup` with the actual filename. There are different versions for `CAT-M1` and `NB-IoT` 4. The command will now make sure the firmware is updated. This takes about 5 minutes. Note that the update may seem to 'stall' around 7-10% and again at 99%. This is completely normal. >Note: **Do not disconnect power to the module during the updating process** @@ -87,7 +90,7 @@ Announcements & News --> Announcements for members only --> the Firmware Files f ## USB If you do not have an SD card available, you can use the existing USB-UART interface. For this you will need to install -* [Python 3](https://www.python.org/downloads), if it's not directly available through your OS distributor +* [Python 3](https://www.python.org/downloads) * [PySerial](https://pythonhosted.org/pyserial/pyserial.html#installation) * [sqnsupgrade python script](https://github.com/pycom/pycom-libraries/tree/master/lib/sqnsupgrade) @@ -99,14 +102,16 @@ If you do not have an SD card available, you can use the existing USB-UART inter 2. Take note of the Serial port used and close the IDE. 3. Go to the directory where you saved the `sqnsupgrade` script and run the following commands in the command line / terminal - ``` + ```python $ python3 >>> import sqnsupgrade - >>> sqnsupgrade.run('Serial_Port', '/path/to/name.dup', '/path/to/updater.elf') + >>> sqnsupgrade.run('Serial_Port', '/path/to/name.dup') + # WARNING! If you are updating from version 33080, use the updater.elf file as well + # >>> sqnsupgrade.run('Serial_Port', '/path/to/name.dup', '/path/to/updater.elf') ``` >Note: Replace the paths and `name.dup` with the actual files. There are different versions for `CAT-M1` and `NB-IoT` -4. The `updater.elf` script will make sure the firmware is updated. It takes about 5 minutes. Note that the update may seem to 'stall' around 7-10% and again at 99%. This is completely normal. +4. The update is now running. Note that the update may seem to 'stall' around 7-10% and again at 99%. This is completely normal. >Note: **Do not disconnect power to the module during the updating process** 5. The updater will show `SYSTEM VERSION` when it is done, and return control to REPL. @@ -116,7 +121,7 @@ If you do not have an SD card available, you can use the existing USB-UART inter To update the modem firmware wirelessly, you can follow the [Flash](/updatefirmware/ltemodem/#flash) guide. Upload the files through the [FTP Server and communicate throught Telnet](/gettingstarted/programming/ftp/), or use [Pybytes Pymakr](https://pybytes.pycom.io/pymakr) - + diff --git a/content/updatefirmware/ota.md b/content/updatefirmware/ota.md index 4aa098b..dc1d882 100644 --- a/content/updatefirmware/ota.md +++ b/content/updatefirmware/ota.md @@ -12,8 +12,7 @@ Pycom modules come with the ability to update the devices firmware, while it is ## Pybytes 1. Go to your device (make sure it is connected to the platform!) 2. Click on the configuration tab -3. Use the OTA firmware update tool here -hello +3. Use the OTA firmware update tool there ## Method A @@ -21,7 +20,7 @@ Here we will describe one possible update methodology you could use that is impl Imagine you a smart metering company and you wish to roll out an update for your Pycom based smart meter. These meters usually send data back via LoRa. Unfortunately LoRa downlink messages have a very limited size and several hundred if not thousand would be required to upload a complete firmware image. To get around this you can have your devices sending their regular data via LoRa and when they receive a special command via a downlink message, the devices will connect to a WiFi network. It is unfeasible to ask customers to allow your device to connect to their home network so instead this network could be provided by a vehicle. This vehicle will travel around a certain geographic area in which the devices have been sent the special downlink message to initiate the update. The devices will look for the WiFi network being broadcast by the vehicle and connect. The devices will then connect to a server running on this WiFi network. This server (also shown in this example) will generate manifest files that instruct the device on what it should update, and where to get the update data from. -## Server +### Server Code available [here](https://github.com/pycom/pycom-libraries/blob/master/examples/OTA/OTA_server.py) @@ -128,7 +127,7 @@ In order for the URL's to be properly formatted you are required to send a "host GET /manifest.json?current_ver=1.0.0 HTTP/1.0\r\nHost: 192.168.1.144:8000\r\n\r\n ``` -## Client Library +### Client Library A MicroPyton library for interfacing with the server described above is available [here](https://github.com/pycom/pycom-libraries/blob/master/examples/OTA/1.0.0/flash/lib/OTA.py). @@ -137,7 +136,7 @@ This library is split into two layers. The top level `OTA` class implements all >Although the above code is functional, it is provided only as an example of how an end user might implement a OTA update mechanism. It is not 100% feature complete e.g. even though it does backup previous versions of files, the roll back procedure is not implemented. This is left of the end user to do. -## Example +### Example Below is am example implementing the methodology previously explained in this tutorial to initiate an OTA update. diff --git a/static/gitbook/assets/DiffCreator.tar.gz b/static/gitbook/assets/DiffCreator.tar.gz new file mode 100644 index 0000000..9665ca5 Binary files /dev/null and b/static/gitbook/assets/DiffCreator.tar.gz differ diff --git a/static/gitbook/assets/pyethernet.png b/static/gitbook/assets/pyethernet.png new file mode 100644 index 0000000..3f8a465 Binary files /dev/null and b/static/gitbook/assets/pyethernet.png differ diff --git a/static/gitbook/assets/pygate_ethernet.png b/static/gitbook/assets/pygate_ethernet.png new file mode 100644 index 0000000..418eab5 Binary files /dev/null and b/static/gitbook/assets/pygate_ethernet.png differ diff --git a/static/gitbook/assets/usb-terminal.png b/static/gitbook/assets/usb-terminal.png new file mode 100644 index 0000000..b0db533 Binary files /dev/null and b/static/gitbook/assets/usb-terminal.png differ diff --git a/themes/doc-theme/static/css/doc-theme.css b/themes/doc-theme/static/css/doc-theme.css index 509acd6..828273d 100644 --- a/themes/doc-theme/static/css/doc-theme.css +++ b/themes/doc-theme/static/css/doc-theme.css @@ -242,12 +242,21 @@ li.hot { .theme--light.v-toolbar { color: #171730!important; } +/* changes 13-07-2020: + corrected tabs in table of contents (top right) + + */ nav#TableOfContents { + display: contents; overflow-y: scroll; max-height: 640px; } +nav#TableOfContents > ul{ + padding-left:0px +} + img { max-width: 90%; margin-left: 0;