{"id":4754,"date":"2016-03-07T12:59:20","date_gmt":"2016-03-07T12:59:20","guid":{"rendered":"http:\/\/blog.bachi.net\/?p=4754"},"modified":"2017-03-11T15:23:26","modified_gmt":"2017-03-11T15:23:26","slug":"lopy-and-micropython","status":"publish","type":"post","link":"https:\/\/blog.bachi.net\/?p=4754","title":{"rendered":"LoPy and MicroPython"},"content":{"rendered":"<p>Cross-Reference blog.bachi.net:<br \/>\n<a href=\"http:\/\/blog.bachi.net\/?p=3993\">Internet of Things (IoT) Protocols &#038; Standards<\/a><br \/>\n<a href=\"http:\/\/blog.bachi.net\/?p=5765\">LoRa: The Things Network<\/a><\/p>\n<p><a href=\"https:\/\/www.kickstarter.com\/projects\/1795343078\/lopy-the-lora-wifi-and-bluetooth-iot-development-p?ref=nav_search\">kickstarter: LoPy \u2013 the LoRa, WiFi and Bluetooth IoT development platform<\/a>, 8. Feb 2016 &#8211; 8. Mar 2016 (30 Tage)<br \/>\n<a href=\"http:\/\/www.pycom.io\/\">Pycom<\/a><\/p>\n<p><a href=\"https:\/\/www.kickstarter.com\/projects\/214379695\/micro-python-python-for-microcontrollers\/description\">kickstarter: Micro Python: Python for microcontrollers<\/a>, 13. Nov 2013 &#8211; 13. Dez 2013 (30 Tage)<br \/>\n<a href=\"https:\/\/micropython.org\/\">MicroPython &#8211; Python for microcontrollers<\/a><br \/>\n<a href=\"https:\/\/github.com\/micropython\/micropython\">github: MicroPython &#8211; a lean and efficient Python implementation for microcontrollers and constrained systems<\/a><\/p>\n<p><a href=\"https:\/\/forum.pycom.io\/category\/1\/announcements-news\">PyCom Announcements &#038; News<\/a>, (Update Firmware, etc.)<\/p>\n<h3>Documentation<\/h3>\n<p><a href=\"https:\/\/docs.pycom.io\/pycom_esp32\/index.html\">Pycom ESP32<\/a><br \/>\n<a href=\"https:\/\/docs.pycom.io\/lopy\/lopy\/tutorial\/wlan.html\">Pycom LoPy: WLAN<\/a> (old?)<br \/>\n<a href=\"https:\/\/docs.pycom.io\/lopy\/lopy\/quickref.html\">Pycom LoPy: Quick reference for the LoPy<\/a> (old?)<br \/>\n<a href=\"https:\/\/docs.pycom.io\/lopy\/library\/network.html#class-lora\">class LoRa<\/a> (old?)<br \/>\n<a href=\"http:\/\/www.python-kurs.eu\/modularisierung.php\">Python Module: Modularisierung<\/a><br \/>\n<a href=\"http:\/\/py-tutorial-de.readthedocs.io\/de\/latest\/modules.html\">Python Tutorial: Module<\/a><\/p>\n<h3>FTDI Drivers<\/h3>\n<p><a href=\"http:\/\/www.ftdichip.com\/Drivers\/D2XX.htm\">D2XX Drivers<\/a><\/p>\n<h3>Support Download<\/h3>\n<p><a href=\"https:\/\/github.com\/pycom\">github.com\/pycom<\/a><br \/>\n<a href=\"https:\/\/github.com\/pycom\/pycom-libraries\/tree\/master\/examples\">github.com\/pycom\/pycom-libraries\/examples\/<\/a><br \/>\n<a href=\"https:\/\/www.pycom.io\/support\/supportdownloads\/\">Support Download<\/a><\/p>\n<h3>Forum Posts<\/h3>\n<p><a href=\"https:\/\/www.thethingsnetwork.org\/forum\/t\/ic880-a-spi-missing-payload-in-received-packet\/2525\">iC880 A SPI : Missing Payload in received Packet?<\/a><br \/>\n<a href=\"https:\/\/forum.pycom.io\/topic\/63\/lorawan-abp-example\/3\">LoRaWAN ABP example<\/a> => DevEUI<br \/>\n<a href=\"https:\/\/forum.pycom.io\/topic\/288\/connecting-the-lopy-to-my-lorank8-gateway\/3\">Connecting the lopy to my lorank8 gateway<\/a><\/p>\n<h3>Firmware<\/h3>\n<p><a href=\"https:\/\/forum.pycom.io\/topic\/88\/how-to-solve-the-firmware-update-failures\">How to solve the firmware update failures<\/a><br \/>\n<a href=\"https:\/\/forum.pycom.io\/topic\/105\/exciting-open-source-news\">Exciting open source news!<\/a><br \/>\n<a href=\"https:\/\/forum.pycom.io\/topic\/54\/firmware-source-code\">Firmware source code?<\/a><\/p>\n<h3>FTP<\/h3>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\nUsername: micro\r\nPassword: python\r\n<\/pre>\n<h3>Boot-Mode and Safe-Mode<\/h3>\n<p><a href=\"https:\/\/docs.pycom.io\/lopy\/lopy\/general.html#pycom-boot-modes\">Boot modes and safe boot<\/a><br \/>\n<a href=\"https:\/\/docs.pycom.io\/lopy\/lopy\/tutorial\/reset.html\">Safe boot<\/a><\/p>\n<h3>Using &#8220;The Things Network&#8221;<\/h3>\n<p><a href=\"https:\/\/www.thethingsnetwork.org\/docs\/devices\/lopy\/usage.html\">LoPy Usage<\/a><\/p>\n<pre class=\"brush: plain; title: Resetting the board; notranslate\" title=\"Resetting the board\">\r\n&gt;&gt;&gt; CTRL-D\r\nPYB: soft reboot\r\nMicroPython v1.8.6-464-g0f843911 on 2017-02-17; LoPy with ESP32\r\nType &quot;help()&quot; for more information.\r\n\r\n&gt;&gt;&gt; import os\r\n&gt;&gt;&gt; os.uname().release\r\n'1.6.3.b2'\r\n\r\n&gt;&gt;&gt; os.uname()\r\n(sysname='LoPy', nodename='LoPy', release='1.6.3.b2', version='v1.8.6-464-g0f843911 on 2017-02-17', machine='LoPy with ESP32', lorawan='1.0.0')\r\n<\/pre>\n<pre class=\"brush: plain; title: MAC Addresses \/ DevEUI; notranslate\" title=\"MAC Addresses \/ DevEUI\">\r\n&gt;&gt;&gt; import binascii\r\n&gt;&gt;&gt; import network\r\n&gt;&gt;&gt; import machine\r\n&gt;&gt;&gt; from network import LoRa\r\n\r\n#  Device EUI\r\n&gt;&gt;&gt; lora = LoRa(mode=LoRa.LORAWAN)\r\n&gt;&gt;&gt;print(binascii.hexlify(lora.mac()).upper().decode('utf-8'))\r\n70B3D54994AD77E0\r\n\r\n&gt;&gt;&gt; binascii.hexlify(network.LoRa().mac())\r\nb'70b3d5499a6b6439'\r\n&gt;&gt;&gt; binascii.hexlify(machine.unique_id())\r\nb'240ac400c004'\r\n&gt;&gt;&gt; binascii.hexlify(network.WLAN().mac())\r\nb'240ac400c004'\r\n<\/pre>\n<pre class=\"brush: plain; title: LoPy ABP Example; notranslate\" title=\"LoPy ABP Example\">\r\nlora = LoRa(mode=LoRa.LORAWAN, sf=7, tx_power=14)\r\nlora.BW_125KHZ\r\nlora.CODING_4_5\r\n\r\n# create an OTAA authentication tuple (NWSkey, AppSKey, DevAddr)\r\nauth = (bytes(&#x5B;0xXX, 0xXX, 0xXX, 0xXX, 0xXX, 0xXX, 0xXX, 0xXX, 0xXX, 0xXX, 0xXX, 0xXX, 0xXX, 0xXX, 0xXX, 0xXX]),\r\n        bytes(&#x5B;0xXX, 0xXX, 0xXX, 0xXX, 0xXX, 0xXX, 0xXX, 0xXX, 0xXX, 0xXX, 0xXX, 0xXX, 0xXX, 0xXX, 0xXX, 0xXX]),\r\n        0x69128CD3 )\r\n\r\nlora.join(activation=LoRa.ABP, auth=auth, timeout=0)\r\n\r\nwhile not lora.has_joined():\r\nprint('Trying to join LoRa network')\r\nsleep(1)\r\npass\r\nprint('Joined LoRa Network')\r\n\r\npycom.rgbled(GREEN)\r\ns = socket.socket(socket.AF_LORA, socket.SOCK_RAW)\r\ns.setblocking(False)\r\n\r\nwhile True:\r\nprint('Sending Packet')\r\ns.send('Hello from the LoPy')\r\nprint('Done sending')\r\nsleep(2)\r\n<\/pre>\n<pre class=\"brush: plain; title: Expansion Board with User LED and User Button; notranslate\" title=\"Expansion Board with User LED and User Button\">\r\nimport pycom\r\nimport machine\r\nimport time\r\n\r\npycom.heartbeat(False)\r\n\r\nled=machine.Pin(&quot;G16&quot;,machine.Pin.OUT)\r\nbutton=machine.Pin(&quot;G17&quot;,machine.Pin.IN, pull=machine.Pin.PULL_UP)\r\n\r\ndef handler(button):\r\n    led.toggle()\r\n\r\nirq=button.callback(trigger=button.IRQ_FALLING, handler=handler)\r\n<\/pre>\n<h3>Change Frequency<\/h3>\n<p><a href=\"https:\/\/forum.pycom.io\/topic\/768\/changing-frequency-region-after-upgrade\">Changing Frequency region after upgrade<\/a><br \/>\n<a href=\"https:\/\/docs.pycom.io\/pycom_esp32\/library\/network.LoRa.html?highlight=frequency\">class LoRa<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Cross-Reference blog.bachi.net: Internet of Things (IoT) Protocols &#038; Standards LoRa: The Things Network kickstarter: LoPy \u2013 the LoRa, WiFi and Bluetooth IoT development platform, 8. Feb 2016 &#8211; 8. Mar 2016 (30 Tage) Pycom kickstarter: Micro Python: Python for microcontrollers, 13. Nov 2013 &#8211; 13. Dez 2013 (30 Tage) MicroPython &#8211; Python for microcontrollers github: [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-4754","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/blog.bachi.net\/index.php?rest_route=\/wp\/v2\/posts\/4754","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.bachi.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.bachi.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.bachi.net\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.bachi.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=4754"}],"version-history":[{"count":32,"href":"https:\/\/blog.bachi.net\/index.php?rest_route=\/wp\/v2\/posts\/4754\/revisions"}],"predecessor-version":[{"id":5984,"href":"https:\/\/blog.bachi.net\/index.php?rest_route=\/wp\/v2\/posts\/4754\/revisions\/5984"}],"wp:attachment":[{"href":"https:\/\/blog.bachi.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=4754"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.bachi.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=4754"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.bachi.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=4754"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}