<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>http://www.openhardwareconf.org/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=BenLeslie</id>
	<title>Open Hardware Miniconf - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="http://www.openhardwareconf.org/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=BenLeslie"/>
	<link rel="alternate" type="text/html" href="http://www.openhardwareconf.org/wiki/Special:Contributions/BenLeslie"/>
	<updated>2026-04-11T09:09:16Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.44.1</generator>
	<entry>
		<id>http://www.openhardwareconf.org/index.php?title=Swagbadge2021_UpdatingSoftware&amp;diff=1262</id>
		<title>Swagbadge2021 UpdatingSoftware</title>
		<link rel="alternate" type="text/html" href="http://www.openhardwareconf.org/index.php?title=Swagbadge2021_UpdatingSoftware&amp;diff=1262"/>
		<updated>2020-12-22T21:57:19Z</updated>

		<summary type="html">&lt;p&gt;BenLeslie: /* Saving your private key */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Updating the software framework =&lt;br /&gt;
&lt;br /&gt;
Swagbadge owners might want to update the software framework (Aiko). Dagbadge owners will need to put the framework onto their badge before they can use it.&lt;br /&gt;
&lt;br /&gt;
Here&#039;s how to do that!&lt;br /&gt;
&lt;br /&gt;
== Requirements ==&lt;br /&gt;
&lt;br /&gt;
* #swagbadge or #dagbadge or any ESP32 with an OLED screen&lt;br /&gt;
* Micro-USB cable&lt;br /&gt;
* Linux, Mac OS or Linux system running Python 3&lt;br /&gt;
* Command line tools: git&lt;br /&gt;
&lt;br /&gt;
== Setting up your Windows 10 system for connecting to badge hardware ==&lt;br /&gt;
&lt;br /&gt;
How to find your serial COM port on Windows: &lt;br /&gt;
* Use the Device Manager. &lt;br /&gt;
* Under the &amp;quot;Ports&amp;quot; category, you&#039;ll see one or more entries. Hopefully one of which is your badge! It will tell you what Port it is on. &lt;br /&gt;
* If you can&#039;t see your badge, you might need to go up to the View menu and use &amp;quot;Show hidden devices&amp;quot; and see if that helps.&lt;br /&gt;
&lt;br /&gt;
Windows 10 may automatically discover your #swagbadge USB hardware and automatically install the correct USB serial hardware driver, or if nothing still shows up, you might need to update your USB drivers for supporting the USB hardware CP210x on your #swagbadge, please follow these instructions:&lt;br /&gt;
* Download the CP210x drivers from [https://www.silabs.com/developers/usb-to-uart-bridge-vcp-drivers Silicon Labs Windows Universal Driver]&lt;br /&gt;
* Unpack the zip file&lt;br /&gt;
* Follow the Silicon Labs instructions for [https://www.silabs.com/documents/public/application-notes/AN335.pdf INF only install] (Section 5 on page 9)&lt;br /&gt;
&lt;br /&gt;
By this point, you have know the serial COM port that your #swagbadge is connected to, e.g COM4&lt;br /&gt;
&lt;br /&gt;
== Setting up your Mac OS system for connecting to #swagbadge hardware ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
How to find your serial COM port on OS X: &lt;br /&gt;
&lt;br /&gt;
    $ ls /dev/tty.usb*&lt;br /&gt;
&lt;br /&gt;
Unless you have lot of dev boards (or maybe a phone) plugged in you should just see a single filename there.&lt;br /&gt;
Use this (without the `/dev/` prefix) when using the `open` command in `mpfshell`&lt;br /&gt;
&lt;br /&gt;
To get a working `mpfshell` install a recent version of Python (Python3.8 is known to work) using a installed DMG.&lt;br /&gt;
Then create a *venv* and install the necessary tools using pip.&lt;br /&gt;
For example:&lt;br /&gt;
&lt;br /&gt;
    $ mkdir swag&lt;br /&gt;
    $ cd swag&lt;br /&gt;
    $ python3.8 -m venv env&lt;br /&gt;
    $ ./env/bin/pip install esptool mpfshell&lt;br /&gt;
&lt;br /&gt;
You can then run `mpfshell` to connect:&lt;br /&gt;
&lt;br /&gt;
    $ ./env/bin/mpfshell&lt;br /&gt;
    mpfs [/]&amp;gt; open &amp;lt;your device node as found previously&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Setting up your Linux system for connecting to #swagbadge hardware ==&lt;br /&gt;
[Link other instructions here]&lt;br /&gt;
&lt;br /&gt;
== Setting up your Windows 10 system for installing #swagbadge firmware == &lt;br /&gt;
&lt;br /&gt;
* Install [https://docs.conda.io/en/latest/miniconda.html Miniconda3] to create a specific Python development environment. (Note we are using Python3 not Python2)&lt;br /&gt;
* Create specific Python 3 environment for playing around with your #swagbadge&lt;br /&gt;
** Start an Anaconda Powershell Prompt (aka Windows Terminal)&lt;br /&gt;
** &amp;lt;code&amp;gt;conda create --yes -n swagbadge python=3&amp;lt;/code&amp;gt;&lt;br /&gt;
** &amp;lt;code&amp;gt;conda activate swagbadge&amp;lt;/code&amp;gt;&lt;br /&gt;
* Your command prompt should now look like: &amp;lt;code&amp;gt;(swagbadge) C:\Users\[Username]&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Install some python tools to let us prepare and communicate with the badge&lt;br /&gt;
** &amp;lt;code&amp;gt;pip install esptool mpfshell&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* To test that the required tools are installed, trying running the following commands&lt;br /&gt;
** &amp;lt;code&amp;gt;esptool&amp;lt;/code&amp;gt;  # Should show you help on running the esptool&lt;br /&gt;
** &amp;lt;code&amp;gt;mpfshell&amp;lt;/code&amp;gt;  # Should show three lines of output&lt;br /&gt;
*** &amp;lt;code&amp;gt;exit&amp;lt;/code&amp;gt;  #  To exit mpfshell&lt;br /&gt;
&lt;br /&gt;
== Download #swagbadge (Aiko Engine) firmware ==&lt;br /&gt;
&lt;br /&gt;
Within your Anaconda Prompt session, change directory to where you’d like the #swagbadge software to be downloaded, for example:&lt;br /&gt;
* &amp;lt;code&amp;gt;cd $HOME/software&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Download #swagbadge firmware:&lt;br /&gt;
* &amp;lt;code&amp;gt;git clone https://github.com/geekscape/aiko_engine_mp.git&amp;lt;/code&amp;gt; # NOTE: this URL will change once we&#039;re live&lt;br /&gt;
* &amp;lt;code&amp;gt;cd aiko_engine_mp&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Install MicroPython&lt;br /&gt;
* Create a directory to hold the MicroPython firmware, such as aiko_engine_mp/firmware/&lt;br /&gt;
* &amp;lt;code&amp;gt;mkdir firmware&amp;lt;/code&amp;gt;&lt;br /&gt;
* Using your web browser, download: [http://micropython.org/resources/firmware/esp32-idf4-20200902-v1.13.bin esp32-idf4-20200902-v1.13.bin] (mouse right button click → [Save As …]  saving the MicroPython firmware in the firmware directory you just made.&lt;br /&gt;
** The [http://micropython.org/download/ MicroPython download list] has a link to a bunch of firmware drivers, we are using the one for the esp32 device, with the latest 1.4 generic&lt;br /&gt;
&lt;br /&gt;
Erase #swagbadge LoLin-Lite ESP32 flash memory&lt;br /&gt;
* &amp;lt;code&amp;gt;esptool --chip esp32 --port COM3 erase_flash&amp;lt;/code&amp;gt; # adjust the port to suit.&lt;br /&gt;
* You’ll know it’s worked, if the output finishes with “Hard resetting via RTS pin…”&lt;br /&gt;
&lt;br /&gt;
Install microPython on the badge&lt;br /&gt;
* &amp;lt;code&amp;gt;esptool --chip esp32 --port COM3 --baud 460800 write_flash -z 0x1000 firmware\esp32-idf4-20200902-v1.13.bin&amp;lt;/code&amp;gt; #adjust port and firmware location if necessary&lt;br /&gt;
* You’ll know it’s worked, if the output finishes with “Hard resetting via RTS pin…”&lt;br /&gt;
&lt;br /&gt;
Test that the software is installed correctly by using mpfshell&lt;br /&gt;
* &amp;lt;code&amp;gt;mpfshell -o COM3&amp;lt;/code&amp;gt; # Adjust port to suit&lt;br /&gt;
* If it has made a connection to your badge, you will see it say&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;Connected to esp32&lt;br /&gt;
** Micropython File Shell v0.9.1, sw@kaltpost.de **&lt;br /&gt;
-- Running on Python 3.8 using PySerial 3.4 --&lt;br /&gt;
mpfs [/]&amp;gt; &amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Using mpfshell ==&lt;br /&gt;
&lt;br /&gt;
mpfshell has two functions: it lets you put files on/off the device, and it can give you a python shell to execute code on the device.&lt;br /&gt;
* Getting files on/off the device is a bit like commandline ftp&lt;br /&gt;
** ls - looks at the files on your micropython device&lt;br /&gt;
** lls - looks at the files on your local computer in the current directory&lt;br /&gt;
** put - puts a file to the device&lt;br /&gt;
** cat - shows you the contents of the file&lt;br /&gt;
** help() - gives you more information on the commands&lt;br /&gt;
** repl - opens up the python shell on the badge&lt;br /&gt;
&lt;br /&gt;
Note: To get out of repl, use Ctrl-Q (on Windows) which drops you back into mpfshell&lt;br /&gt;
&lt;br /&gt;
A little program to say hello world!&lt;br /&gt;
* &amp;lt;code&amp;gt; &amp;gt;&amp;gt;&amp;gt; print(&amp;quot;hello world&amp;quot;)&amp;lt;/code&amp;gt;&lt;br /&gt;
* Output: &amp;lt;code&amp;gt;hello world&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A little program to turn the blue light on the board on and off (this is on the underside of the Swagbadge, visible through a circular cutout)&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&amp;gt;&amp;gt;&amp;gt; import machine&lt;br /&gt;
&amp;gt;&amp;gt;&amp;gt; pin22=machine.Pin(22, machine.Pin.OUT, machine.Pin.PULL_UP)&lt;br /&gt;
&amp;gt;&amp;gt;&amp;gt; pin22.value(0) &lt;br /&gt;
&amp;gt;&amp;gt;&amp;gt; pin22.value(1)&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Saving your private key ==&lt;br /&gt;
&lt;br /&gt;
Use mpfshell to get the file: `configuration/keys.db`.&lt;br /&gt;
&lt;br /&gt;
== Putting the Aiko framework onto the device, using mpfshell == &lt;br /&gt;
* &amp;lt;code&amp;gt;mpfshell COM5 -s scripts\aiko.mpf&amp;lt;/code&amp;gt; #run from within the aiko_framework_mp directory&lt;br /&gt;
&lt;br /&gt;
=== Windows only: Patch mpfshell ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Note!&#039;&#039; mpfshell needs a patch applied to let it run a script under Windows.&lt;br /&gt;
&lt;br /&gt;
* Inside &amp;lt;code&amp;gt;C:/users/USERNAME/Miniconda2/envs/swagbadge/Lib/site-packages/mp&amp;lt;/code&amp;gt;&lt;br /&gt;
* edit &amp;lt;code&amp;gt;mpfshell.py&amp;lt;/code&amp;gt;&lt;br /&gt;
* Search for &amp;lt;code&amp;gt;elif args.script is not None:&amp;lt;/code&amp;gt;, around line 796&lt;br /&gt;
* between that line and the next, insert two lines. It should look like:&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
    elif args.script is not None:&lt;br /&gt;
&lt;br /&gt;
        if platform.system() == &amp;quot;Windows&amp;quot;:  #INSERT THIS LINE&lt;br /&gt;
            mpfs.use_rawinput = True        #INSERT THIS LINE&lt;br /&gt;
&lt;br /&gt;
        f = open(args.script, &amp;quot;r&amp;quot;)&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
* Python is very particular about spacing. The rest of the code uses 4 spaces for indents so follow suit.&lt;br /&gt;
&lt;br /&gt;
= Reboot to shell / Force runaway code to stop =&lt;br /&gt;
&lt;br /&gt;
It&#039;s possible to write code that will leave your badge unresponsive. Rebooting just reruns the same bad code. What to do?&lt;br /&gt;
&lt;br /&gt;
* Place a finger on each of the bottom slider pads, either side of the microprocessor. &lt;br /&gt;
* Trigger a restart by using the button on the back of the badge, or Ctrl-D in repl (if you can get into repl)&lt;br /&gt;
&lt;br /&gt;
The badge will restart but not autorun any code, just drop you back at the repl prompt. From there you can &amp;lt;code&amp;gt;put&amp;lt;/code&amp;gt; bugfixed code back onto the device.&lt;/div&gt;</summary>
		<author><name>BenLeslie</name></author>
	</entry>
	<entry>
		<id>http://www.openhardwareconf.org/index.php?title=Swagbadge2021_UpdatingSoftware&amp;diff=1261</id>
		<title>Swagbadge2021 UpdatingSoftware</title>
		<link rel="alternate" type="text/html" href="http://www.openhardwareconf.org/index.php?title=Swagbadge2021_UpdatingSoftware&amp;diff=1261"/>
		<updated>2020-12-22T21:55:07Z</updated>

		<summary type="html">&lt;p&gt;BenLeslie: Add section on your private key&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Updating the software framework =&lt;br /&gt;
&lt;br /&gt;
Swagbadge owners might want to update the software framework (Aiko). Dagbadge owners will need to put the framework onto their badge before they can use it.&lt;br /&gt;
&lt;br /&gt;
Here&#039;s how to do that!&lt;br /&gt;
&lt;br /&gt;
== Requirements ==&lt;br /&gt;
&lt;br /&gt;
* #swagbadge or #dagbadge or any ESP32 with an OLED screen&lt;br /&gt;
* Micro-USB cable&lt;br /&gt;
* Linux, Mac OS or Linux system running Python 3&lt;br /&gt;
* Command line tools: git&lt;br /&gt;
&lt;br /&gt;
== Setting up your Windows 10 system for connecting to badge hardware ==&lt;br /&gt;
&lt;br /&gt;
How to find your serial COM port on Windows: &lt;br /&gt;
* Use the Device Manager. &lt;br /&gt;
* Under the &amp;quot;Ports&amp;quot; category, you&#039;ll see one or more entries. Hopefully one of which is your badge! It will tell you what Port it is on. &lt;br /&gt;
* If you can&#039;t see your badge, you might need to go up to the View menu and use &amp;quot;Show hidden devices&amp;quot; and see if that helps.&lt;br /&gt;
&lt;br /&gt;
Windows 10 may automatically discover your #swagbadge USB hardware and automatically install the correct USB serial hardware driver, or if nothing still shows up, you might need to update your USB drivers for supporting the USB hardware CP210x on your #swagbadge, please follow these instructions:&lt;br /&gt;
* Download the CP210x drivers from [https://www.silabs.com/developers/usb-to-uart-bridge-vcp-drivers Silicon Labs Windows Universal Driver]&lt;br /&gt;
* Unpack the zip file&lt;br /&gt;
* Follow the Silicon Labs instructions for [https://www.silabs.com/documents/public/application-notes/AN335.pdf INF only install] (Section 5 on page 9)&lt;br /&gt;
&lt;br /&gt;
By this point, you have know the serial COM port that your #swagbadge is connected to, e.g COM4&lt;br /&gt;
&lt;br /&gt;
== Setting up your Mac OS system for connecting to #swagbadge hardware ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
How to find your serial COM port on OS X: &lt;br /&gt;
&lt;br /&gt;
    $ ls /dev/tty.usb*&lt;br /&gt;
&lt;br /&gt;
Unless you have lot of dev boards (or maybe a phone) plugged in you should just see a single filename there.&lt;br /&gt;
Use this (without the `/dev/` prefix) when using the `open` command in `mpfshell`&lt;br /&gt;
&lt;br /&gt;
To get a working `mpfshell` install a recent version of Python (Python3.8 is known to work) using a installed DMG.&lt;br /&gt;
Then create a *venv* and install the necessary tools using pip.&lt;br /&gt;
For example:&lt;br /&gt;
&lt;br /&gt;
    $ mkdir swag&lt;br /&gt;
    $ cd swag&lt;br /&gt;
    $ python3.8 -m venv env&lt;br /&gt;
    $ ./env/bin/pip install esptool mpfshell&lt;br /&gt;
&lt;br /&gt;
You can then run `mpfshell` to connect:&lt;br /&gt;
&lt;br /&gt;
    $ ./env/bin/mpfshell&lt;br /&gt;
    mpfs [/]&amp;gt; open &amp;lt;your device node as found previously&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Setting up your Linux system for connecting to #swagbadge hardware ==&lt;br /&gt;
[Link other instructions here]&lt;br /&gt;
&lt;br /&gt;
== Setting up your Windows 10 system for installing #swagbadge firmware == &lt;br /&gt;
&lt;br /&gt;
* Install [https://docs.conda.io/en/latest/miniconda.html Miniconda3] to create a specific Python development environment. (Note we are using Python3 not Python2)&lt;br /&gt;
* Create specific Python 3 environment for playing around with your #swagbadge&lt;br /&gt;
** Start an Anaconda Powershell Prompt (aka Windows Terminal)&lt;br /&gt;
** &amp;lt;code&amp;gt;conda create --yes -n swagbadge python=3&amp;lt;/code&amp;gt;&lt;br /&gt;
** &amp;lt;code&amp;gt;conda activate swagbadge&amp;lt;/code&amp;gt;&lt;br /&gt;
* Your command prompt should now look like: &amp;lt;code&amp;gt;(swagbadge) C:\Users\[Username]&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Install some python tools to let us prepare and communicate with the badge&lt;br /&gt;
** &amp;lt;code&amp;gt;pip install esptool mpfshell&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* To test that the required tools are installed, trying running the following commands&lt;br /&gt;
** &amp;lt;code&amp;gt;esptool&amp;lt;/code&amp;gt;  # Should show you help on running the esptool&lt;br /&gt;
** &amp;lt;code&amp;gt;mpfshell&amp;lt;/code&amp;gt;  # Should show three lines of output&lt;br /&gt;
*** &amp;lt;code&amp;gt;exit&amp;lt;/code&amp;gt;  #  To exit mpfshell&lt;br /&gt;
&lt;br /&gt;
== Download #swagbadge (Aiko Engine) firmware ==&lt;br /&gt;
&lt;br /&gt;
Within your Anaconda Prompt session, change directory to where you’d like the #swagbadge software to be downloaded, for example:&lt;br /&gt;
* &amp;lt;code&amp;gt;cd $HOME/software&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Download #swagbadge firmware:&lt;br /&gt;
* &amp;lt;code&amp;gt;git clone https://github.com/geekscape/aiko_engine_mp.git&amp;lt;/code&amp;gt; # NOTE: this URL will change once we&#039;re live&lt;br /&gt;
* &amp;lt;code&amp;gt;cd aiko_engine_mp&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Install MicroPython&lt;br /&gt;
* Create a directory to hold the MicroPython firmware, such as aiko_engine_mp/firmware/&lt;br /&gt;
* &amp;lt;code&amp;gt;mkdir firmware&amp;lt;/code&amp;gt;&lt;br /&gt;
* Using your web browser, download: [http://micropython.org/resources/firmware/esp32-idf4-20200902-v1.13.bin esp32-idf4-20200902-v1.13.bin] (mouse right button click → [Save As …]  saving the MicroPython firmware in the firmware directory you just made.&lt;br /&gt;
** The [http://micropython.org/download/ MicroPython download list] has a link to a bunch of firmware drivers, we are using the one for the esp32 device, with the latest 1.4 generic&lt;br /&gt;
&lt;br /&gt;
Erase #swagbadge LoLin-Lite ESP32 flash memory&lt;br /&gt;
* &amp;lt;code&amp;gt;esptool --chip esp32 --port COM3 erase_flash&amp;lt;/code&amp;gt; # adjust the port to suit.&lt;br /&gt;
* You’ll know it’s worked, if the output finishes with “Hard resetting via RTS pin…”&lt;br /&gt;
&lt;br /&gt;
Install microPython on the badge&lt;br /&gt;
* &amp;lt;code&amp;gt;esptool --chip esp32 --port COM3 --baud 460800 write_flash -z 0x1000 firmware\esp32-idf4-20200902-v1.13.bin&amp;lt;/code&amp;gt; #adjust port and firmware location if necessary&lt;br /&gt;
* You’ll know it’s worked, if the output finishes with “Hard resetting via RTS pin…”&lt;br /&gt;
&lt;br /&gt;
Test that the software is installed correctly by using mpfshell&lt;br /&gt;
* &amp;lt;code&amp;gt;mpfshell -o COM3&amp;lt;/code&amp;gt; # Adjust port to suit&lt;br /&gt;
* If it has made a connection to your badge, you will see it say&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;Connected to esp32&lt;br /&gt;
** Micropython File Shell v0.9.1, sw@kaltpost.de **&lt;br /&gt;
-- Running on Python 3.8 using PySerial 3.4 --&lt;br /&gt;
mpfs [/]&amp;gt; &amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Using mpfshell ==&lt;br /&gt;
&lt;br /&gt;
mpfshell has two functions: it lets you put files on/off the device, and it can give you a python shell to execute code on the device.&lt;br /&gt;
* Getting files on/off the device is a bit like commandline ftp&lt;br /&gt;
** ls - looks at the files on your micropython device&lt;br /&gt;
** lls - looks at the files on your local computer in the current directory&lt;br /&gt;
** put - puts a file to the device&lt;br /&gt;
** cat - shows you the contents of the file&lt;br /&gt;
** help() - gives you more information on the commands&lt;br /&gt;
** repl - opens up the python shell on the badge&lt;br /&gt;
&lt;br /&gt;
Note: To get out of repl, use Ctrl-Q (on Windows) which drops you back into mpfshell&lt;br /&gt;
&lt;br /&gt;
A little program to say hello world!&lt;br /&gt;
* &amp;lt;code&amp;gt; &amp;gt;&amp;gt;&amp;gt; print(&amp;quot;hello world&amp;quot;)&amp;lt;/code&amp;gt;&lt;br /&gt;
* Output: &amp;lt;code&amp;gt;hello world&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A little program to turn the blue light on the board on and off (this is on the underside of the Swagbadge, visible through a circular cutout)&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&amp;gt;&amp;gt;&amp;gt; import machine&lt;br /&gt;
&amp;gt;&amp;gt;&amp;gt; pin22=machine.Pin(22, machine.Pin.OUT, machine.Pin.PULL_UP)&lt;br /&gt;
&amp;gt;&amp;gt;&amp;gt; pin22.value(0) &lt;br /&gt;
&amp;gt;&amp;gt;&amp;gt; pin22.value(1)&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Saving your private key ==&lt;br /&gt;
&lt;br /&gt;
Todo&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Putting the Aiko framework onto the device, using mpfshell == &lt;br /&gt;
* &amp;lt;code&amp;gt;mpfshell COM5 -s scripts\aiko.mpf&amp;lt;/code&amp;gt; #run from within the aiko_framework_mp directory&lt;br /&gt;
&lt;br /&gt;
=== Windows only: Patch mpfshell ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Note!&#039;&#039; mpfshell needs a patch applied to let it run a script under Windows.&lt;br /&gt;
&lt;br /&gt;
* Inside &amp;lt;code&amp;gt;C:/users/USERNAME/Miniconda2/envs/swagbadge/Lib/site-packages/mp&amp;lt;/code&amp;gt;&lt;br /&gt;
* edit &amp;lt;code&amp;gt;mpfshell.py&amp;lt;/code&amp;gt;&lt;br /&gt;
* Search for &amp;lt;code&amp;gt;elif args.script is not None:&amp;lt;/code&amp;gt;, around line 796&lt;br /&gt;
* between that line and the next, insert two lines. It should look like:&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
    elif args.script is not None:&lt;br /&gt;
&lt;br /&gt;
        if platform.system() == &amp;quot;Windows&amp;quot;:  #INSERT THIS LINE&lt;br /&gt;
            mpfs.use_rawinput = True        #INSERT THIS LINE&lt;br /&gt;
&lt;br /&gt;
        f = open(args.script, &amp;quot;r&amp;quot;)&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
* Python is very particular about spacing. The rest of the code uses 4 spaces for indents so follow suit.&lt;br /&gt;
&lt;br /&gt;
= Reboot to shell / Force runaway code to stop =&lt;br /&gt;
&lt;br /&gt;
It&#039;s possible to write code that will leave your badge unresponsive. Rebooting just reruns the same bad code. What to do?&lt;br /&gt;
&lt;br /&gt;
* Place a finger on each of the bottom slider pads, either side of the microprocessor. &lt;br /&gt;
* Trigger a restart by using the button on the back of the badge, or Ctrl-D in repl (if you can get into repl)&lt;br /&gt;
&lt;br /&gt;
The badge will restart but not autorun any code, just drop you back at the repl prompt. From there you can &amp;lt;code&amp;gt;put&amp;lt;/code&amp;gt; bugfixed code back onto the device.&lt;/div&gt;</summary>
		<author><name>BenLeslie</name></author>
	</entry>
	<entry>
		<id>http://www.openhardwareconf.org/index.php?title=Swagbadge2021_GettingStarted&amp;diff=1260</id>
		<title>Swagbadge2021 GettingStarted</title>
		<link rel="alternate" type="text/html" href="http://www.openhardwareconf.org/index.php?title=Swagbadge2021_GettingStarted&amp;diff=1260"/>
		<updated>2020-12-22T21:53:58Z</updated>

		<summary type="html">&lt;p&gt;BenLeslie: /* Getting the device on your wifi - commandline with mpfshell */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Getting started with the Swagbadge =&lt;br /&gt;
&lt;br /&gt;
== Support ==&lt;br /&gt;
* The [https://spectrum.chat/lca2021-swagbadge Swag Badge Spectrum chat] is a place where the badge team hangs out, ready to answer your questions.&lt;br /&gt;
&lt;br /&gt;
== My package arrived in the mail, first steps. ==&lt;br /&gt;
* Your package should contain your badge, and some other goodies! &lt;br /&gt;
** [[File:swagbadgepackage.jpg|400px|alt=Image showing the contents of the swagbag package]]&lt;br /&gt;
** Badge&lt;br /&gt;
** SAO headers (x 4)&lt;br /&gt;
** SAO proto boards (x 2)&lt;br /&gt;
** SAO tux board&lt;br /&gt;
** Lanyard&lt;br /&gt;
** Stickers&lt;br /&gt;
** Instructions&lt;br /&gt;
* Take off the protective cases to reveal the screens.&lt;br /&gt;
* Powering it up&lt;br /&gt;
** Insert a micro USB cable into the badge and connect the other end to a USB port on your computer or USB power source.&lt;br /&gt;
** A green light should glow on the rear of the board, and a title appear across the two screens.&lt;br /&gt;
* Turning it on and off again&lt;br /&gt;
** Plugging/unplugging it is fine. Usually the badge isn&#039;t running anything intensely enough that just unpowering it would cause a problem.&lt;br /&gt;
* On bootup, you should see:&lt;br /&gt;
** The OLED screens will display &amp;quot;Aiko&amp;quot; and a version number as a title&lt;br /&gt;
** It will also display something else to tell you to set up your wifi.&lt;br /&gt;
&lt;br /&gt;
== Getting it on your network ==&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Safety precautions we have provided&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
* When using any hardware ordered off the internet, you can&#039;t be quite certain what software might be present on it. Before shipping these badges to you, we reflashed a fresh copy of MicroPython onto the Lolin32.&lt;br /&gt;
* The framework running on the badge is Aiko, which is open source.&lt;br /&gt;
* The software on the badge is available on the CCHS repository, also all open source.&lt;br /&gt;
* The badges are designed to communicate over MQTT - a lightweight standard for messaging on IoT devices, but we are aware of privacy considerations: you don&#039;t want anybody able to control your badge from afar. The swagbadge protocol provides support for encrypted messages.&lt;br /&gt;
&lt;br /&gt;
=== Getting the device on your wifi - wireless ===&lt;br /&gt;
&lt;br /&gt;
* The first time you boot your device, it won&#039;t know how to talk to your network. If it can&#039;t detect a pre-existing set of network credentials, or connect to anything it knows about, it will establish a temporary access point and prompt you to navigate to it to enter your wifi details.&lt;br /&gt;
* &#039;&#039;Note: Your device can only talk to a 2.4GHz network: it is not compatible with 5GHz WiFi.&#039;&#039;&lt;br /&gt;
* The screens on your badge will say: &amp;lt;code&amp;gt;Configure WiFi: aiko1234a12341234. Try http://192.168.4.1&amp;lt;/code&amp;gt;&lt;br /&gt;
* Use your phone or computer to connect to the wifi network on the badge. Its name starts with &amp;lt;code&amp;gt;aiko&amp;lt;/code&amp;gt; followed by some numbers/letters.&lt;br /&gt;
* Once you&#039;re connected to the badge, open a web browser to the IP address on the screens. Something like &amp;lt;code&amp;gt;http://192.168.4.1&amp;lt;/code&amp;gt;&lt;br /&gt;
* You&#039;ll be prompted to enter your wifi SSID and wifi password.&lt;br /&gt;
* Once you&#039;ve saved that, the badge will restart using the credentials you&#039;ve provided and it will shut down its wifi access point.&lt;br /&gt;
&lt;br /&gt;
Note: If you are using an Android device to link the badge to your WiFi, it will pop up a dialog to say you are switching to a network that doesn&#039;t have Internet access and ask if you want to switch back. Select &amp;quot;Keep&amp;quot; to stay on the badge&#039;s temporary access point.&lt;br /&gt;
&lt;br /&gt;
=== Getting the device on your wifi - commandline with mpfshell ===&lt;br /&gt;
&lt;br /&gt;
* If setting up via the wifi AP (access point) doesn&#039;t work, you can put a configuration file onto the badge.&lt;br /&gt;
* You&#039;ll need to start by getting [[Swagbadge2021_UpdatingSoftware|a copy of the aiko firmware, and installing mpfshell]]&lt;br /&gt;
* &#039;&#039;Note: Your device can only talk to a 2.4GHz network: it is not compatible with 5GHz.&#039;&#039;&lt;br /&gt;
* Edit aiko_engine_mp/configuration/net.py and insert the details of your SSID and password.&lt;br /&gt;
* use mpfshell: &amp;lt;code&amp;gt;mpfshell -o COM3&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;put configuration/net.py configuration/net.py&amp;lt;/code&amp;gt;&lt;br /&gt;
* fire up repl to view the console log &lt;br /&gt;
* You can now restart your device&lt;br /&gt;
* On bootup it should now talk to your network and you can see it on the console log.&lt;br /&gt;
&lt;br /&gt;
On bootup you should now see...&lt;br /&gt;
&lt;br /&gt;
= Running pre-installed applications =&lt;br /&gt;
* Pre-installed things, how to access and run them.&lt;br /&gt;
&lt;br /&gt;
= Extensions: Adding a SAO =&lt;br /&gt;
* provided by others&lt;br /&gt;
* build your own (linky here to our docs)&lt;br /&gt;
&lt;br /&gt;
= Extensions: Updating the software framework =&lt;br /&gt;
&lt;br /&gt;
Between when we ship the board and when it arrives, there might be some changes to the software framework (Aiko). Here&#039;s how to update it. Or perhaps you&#039;re interested in writing your own applications? &lt;br /&gt;
&lt;br /&gt;
[[Swagbadge2021_UpdatingSoftware|Updating the Software]]&lt;/div&gt;</summary>
		<author><name>BenLeslie</name></author>
	</entry>
	<entry>
		<id>http://www.openhardwareconf.org/index.php?title=Swagbadge2021_GettingStarted&amp;diff=1259</id>
		<title>Swagbadge2021 GettingStarted</title>
		<link rel="alternate" type="text/html" href="http://www.openhardwareconf.org/index.php?title=Swagbadge2021_GettingStarted&amp;diff=1259"/>
		<updated>2020-12-22T05:02:53Z</updated>

		<summary type="html">&lt;p&gt;BenLeslie: /* My package arrived in the mail, first steps. */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Getting started with the Swagbadge =&lt;br /&gt;
&lt;br /&gt;
== Support ==&lt;br /&gt;
* The [https://spectrum.chat/lca2021-swagbadge Swag Badge Spectrum chat] is a place where the badge team hangs out, ready to answer your questions.&lt;br /&gt;
&lt;br /&gt;
== My package arrived in the mail, first steps. ==&lt;br /&gt;
* Your package should contain your badge, and some other goodies! &lt;br /&gt;
** [[File:swagbadgepackage.jpg|400px|alt=Image showing the contents of the swagbag package]]&lt;br /&gt;
** Badge&lt;br /&gt;
** SAO headers (x 4)&lt;br /&gt;
** SAO proto boards (x 2)&lt;br /&gt;
** SAO tux board&lt;br /&gt;
** Lanyard&lt;br /&gt;
** Stickers&lt;br /&gt;
** Instructions&lt;br /&gt;
* Take off the protective cases to reveal the screens.&lt;br /&gt;
* Powering it up&lt;br /&gt;
** Insert a micro USB cable into the badge and connect the other end to a USB port on your computer or USB power source.&lt;br /&gt;
** A green light should glow on the rear of the board, and a title appear across the two screens.&lt;br /&gt;
* Turning it on and off again&lt;br /&gt;
** Plugging/unplugging it is fine. Usually the badge isn&#039;t running anything intensely enough that just unpowering it would cause a problem.&lt;br /&gt;
* On bootup, you should see:&lt;br /&gt;
** The OLED screens will display &amp;quot;Aiko&amp;quot; and a version number as a title&lt;br /&gt;
** It will also display something else to tell you to set up your wifi.&lt;br /&gt;
&lt;br /&gt;
== Getting it on your network ==&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Safety precautions we have provided&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
* When using any hardware ordered off the internet, you can&#039;t be quite certain what software might be present on it. Before shipping these badges to you, we reflashed a fresh copy of MicroPython onto the Lolin32.&lt;br /&gt;
* The framework running on the badge is Aiko, which is open source.&lt;br /&gt;
* The software on the badge is available on the CCHS repository, also all open source.&lt;br /&gt;
* The badges are designed to communicate over MQTT - a lightweight standard for messaging on IoT devices, but we are aware of privacy considerations: you don&#039;t want anybody able to control your badge from afar. The swagbadge protocol provides support for encrypted messages.&lt;br /&gt;
&lt;br /&gt;
=== Getting the device on your wifi - wireless ===&lt;br /&gt;
&lt;br /&gt;
* The first time you boot your device, it won&#039;t know how to talk to your network. If it can&#039;t detect a pre-existing set of network credentials, or connect to anything it knows about, it will establish a temporary access point and prompt you to navigate to it to enter your wifi details.&lt;br /&gt;
* &#039;&#039;Note: Your device can only talk to a 2.4GHz network: it is not compatible with 5GHz WiFi.&#039;&#039;&lt;br /&gt;
* The screens on your badge will say: &amp;lt;code&amp;gt;Configure WiFi: aiko1234a12341234. Try http://192.168.4.1&amp;lt;/code&amp;gt;&lt;br /&gt;
* Use your phone or computer to connect to the wifi network on the badge. Its name starts with &amp;lt;code&amp;gt;aiko&amp;lt;/code&amp;gt; followed by some numbers/letters.&lt;br /&gt;
* Once you&#039;re connected to the badge, open a web browser to the IP address on the screens. Something like &amp;lt;code&amp;gt;http://192.168.4.1&amp;lt;/code&amp;gt;&lt;br /&gt;
* You&#039;ll be prompted to enter your wifi SSID and wifi password.&lt;br /&gt;
* Once you&#039;ve saved that, the badge will restart using the credentials you&#039;ve provided and it will shut down its wifi access point.&lt;br /&gt;
&lt;br /&gt;
Note: If you are using an Android device to link the badge to your WiFi, it will pop up a dialog to say you are switching to a network that doesn&#039;t have Internet access and ask if you want to switch back. Select &amp;quot;Keep&amp;quot; to stay on the badge&#039;s temporary access point.&lt;br /&gt;
&lt;br /&gt;
=== Getting the device on your wifi - commandline with mpfshell ===&lt;br /&gt;
&lt;br /&gt;
* If setting up via the wifi AP (access point) doesn&#039;t work, you can put a configuration file onto the badge.&lt;br /&gt;
* You&#039;ll need to start by getting [[Swagbadge2021_UpdatingSoftware|a copy of the aiko firmware, and installing mpfshell]]&lt;br /&gt;
* &#039;&#039;Note: Your device can only talk to a 2G network: it is not compatible with 5g.&#039;&#039;&lt;br /&gt;
* Edit aiko_engine_mp/configuration/net.py and insert the details of your SSID and password.&lt;br /&gt;
* use mpfshell: &amp;lt;code&amp;gt;mpfshell -o COM3&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;put configuration/net.py configuration/net.py&amp;lt;/code&amp;gt;&lt;br /&gt;
* fire up repl to view the console log &lt;br /&gt;
* You can now restart your device&lt;br /&gt;
* On bootup it should now talk to your network and you can see it on the console log.&lt;br /&gt;
&lt;br /&gt;
On bootup you should now see...&lt;br /&gt;
&lt;br /&gt;
= Running pre-installed applications =&lt;br /&gt;
* Pre-installed things, how to access and run them.&lt;br /&gt;
&lt;br /&gt;
= Extensions: Adding a SAO =&lt;br /&gt;
* provided by others&lt;br /&gt;
* build your own (linky here to our docs)&lt;br /&gt;
&lt;br /&gt;
= Extensions: Updating the software framework =&lt;br /&gt;
&lt;br /&gt;
Between when we ship the board and when it arrives, there might be some changes to the software framework (Aiko). Here&#039;s how to update it. Or perhaps you&#039;re interested in writing your own applications? &lt;br /&gt;
&lt;br /&gt;
[[Swagbadge2021_UpdatingSoftware|Updating the Software]]&lt;/div&gt;</summary>
		<author><name>BenLeslie</name></author>
	</entry>
	<entry>
		<id>http://www.openhardwareconf.org/index.php?title=Swagbadge2021_GettingStarted&amp;diff=1258</id>
		<title>Swagbadge2021 GettingStarted</title>
		<link rel="alternate" type="text/html" href="http://www.openhardwareconf.org/index.php?title=Swagbadge2021_GettingStarted&amp;diff=1258"/>
		<updated>2020-12-22T05:00:06Z</updated>

		<summary type="html">&lt;p&gt;BenLeslie: /* My package arrived in the mail, first steps. */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Getting started with the Swagbadge =&lt;br /&gt;
&lt;br /&gt;
== Support ==&lt;br /&gt;
* The [https://spectrum.chat/lca2021-swagbadge Swag Badge Spectrum chat] is a place where the badge team hangs out, ready to answer your questions.&lt;br /&gt;
&lt;br /&gt;
== My package arrived in the mail, first steps. ==&lt;br /&gt;
* Your package should contain your badge, and some other goodies! &lt;br /&gt;
** [[File:swagbadgepackage.jpg|400px|alt=Image showing the contents of the swagbag package]]&lt;br /&gt;
** Badge&lt;br /&gt;
** SAO headers (x 4)&lt;br /&gt;
** SAO proto boards (x 2)&lt;br /&gt;
** SAO tux board&lt;br /&gt;
** Lanyard&lt;br /&gt;
** Stickers&lt;br /&gt;
** Instructions&lt;br /&gt;
 * Take off the protective cases to reveal the screens.&lt;br /&gt;
* Powering it up&lt;br /&gt;
** Insert a micro USB cable into the badge and connect the other end to a USB port on your computer or USB power source.&lt;br /&gt;
** A green light should glow on the rear of the board, and a title appear across the two screens.&lt;br /&gt;
* Turning it on and off again&lt;br /&gt;
** Plugging/unplugging it is fine. Usually the badge isn&#039;t running anything intensely enough that just unpowering it would cause a problem.&lt;br /&gt;
* On bootup, you should see:&lt;br /&gt;
** The OLED screens will display &amp;quot;Aiko&amp;quot; and a version number as a title&lt;br /&gt;
** It will also display something else to tell you to set up your wifi.&lt;br /&gt;
&lt;br /&gt;
== Getting it on your network ==&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Safety precautions we have provided&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
* When using any hardware ordered off the internet, you can&#039;t be quite certain what software might be present on it. Before shipping these badges to you, we reflashed a fresh copy of MicroPython onto the Lolin32.&lt;br /&gt;
* The framework running on the badge is Aiko, which is open source.&lt;br /&gt;
* The software on the badge is available on the CCHS repository, also all open source.&lt;br /&gt;
* The badges are designed to communicate over MQTT - a lightweight standard for messaging on IoT devices, but we are aware of privacy considerations: you don&#039;t want anybody able to control your badge from afar. The swagbadge protocol provides support for encrypted messages.&lt;br /&gt;
&lt;br /&gt;
=== Getting the device on your wifi - wireless ===&lt;br /&gt;
&lt;br /&gt;
* The first time you boot your device, it won&#039;t know how to talk to your network. If it can&#039;t detect a pre-existing set of network credentials, or connect to anything it knows about, it will establish a temporary access point and prompt you to navigate to it to enter your wifi details.&lt;br /&gt;
* &#039;&#039;Note: Your device can only talk to a 2.4GHz network: it is not compatible with 5GHz WiFi.&#039;&#039;&lt;br /&gt;
* The screens on your badge will say: &amp;lt;code&amp;gt;Configure WiFi: aiko1234a12341234. Try http://192.168.4.1&amp;lt;/code&amp;gt;&lt;br /&gt;
* Use your phone or computer to connect to the wifi network on the badge. Its name starts with &amp;lt;code&amp;gt;aiko&amp;lt;/code&amp;gt; followed by some numbers/letters.&lt;br /&gt;
* Once you&#039;re connected to the badge, open a web browser to the IP address on the screens. Something like &amp;lt;code&amp;gt;http://192.168.4.1&amp;lt;/code&amp;gt;&lt;br /&gt;
* You&#039;ll be prompted to enter your wifi SSID and wifi password.&lt;br /&gt;
* Once you&#039;ve saved that, the badge will restart using the credentials you&#039;ve provided and it will shut down its wifi access point.&lt;br /&gt;
&lt;br /&gt;
Note: If you are using an Android device to link the badge to your WiFi, it will pop up a dialog to say you are switching to a network that doesn&#039;t have Internet access and ask if you want to switch back. Select &amp;quot;Keep&amp;quot; to stay on the badge&#039;s temporary access point.&lt;br /&gt;
&lt;br /&gt;
=== Getting the device on your wifi - commandline with mpfshell ===&lt;br /&gt;
&lt;br /&gt;
* If setting up via the wifi AP (access point) doesn&#039;t work, you can put a configuration file onto the badge.&lt;br /&gt;
* You&#039;ll need to start by getting [[Swagbadge2021_UpdatingSoftware|a copy of the aiko firmware, and installing mpfshell]]&lt;br /&gt;
* &#039;&#039;Note: Your device can only talk to a 2G network: it is not compatible with 5g.&#039;&#039;&lt;br /&gt;
* Edit aiko_engine_mp/configuration/net.py and insert the details of your SSID and password.&lt;br /&gt;
* use mpfshell: &amp;lt;code&amp;gt;mpfshell -o COM3&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;put configuration/net.py configuration/net.py&amp;lt;/code&amp;gt;&lt;br /&gt;
* fire up repl to view the console log &lt;br /&gt;
* You can now restart your device&lt;br /&gt;
* On bootup it should now talk to your network and you can see it on the console log.&lt;br /&gt;
&lt;br /&gt;
On bootup you should now see...&lt;br /&gt;
&lt;br /&gt;
= Running pre-installed applications =&lt;br /&gt;
* Pre-installed things, how to access and run them.&lt;br /&gt;
&lt;br /&gt;
= Extensions: Adding a SAO =&lt;br /&gt;
* provided by others&lt;br /&gt;
* build your own (linky here to our docs)&lt;br /&gt;
&lt;br /&gt;
= Extensions: Updating the software framework =&lt;br /&gt;
&lt;br /&gt;
Between when we ship the board and when it arrives, there might be some changes to the software framework (Aiko). Here&#039;s how to update it. Or perhaps you&#039;re interested in writing your own applications? &lt;br /&gt;
&lt;br /&gt;
[[Swagbadge2021_UpdatingSoftware|Updating the Software]]&lt;/div&gt;</summary>
		<author><name>BenLeslie</name></author>
	</entry>
	<entry>
		<id>http://www.openhardwareconf.org/index.php?title=Swagbadge2021_GettingStarted&amp;diff=1257</id>
		<title>Swagbadge2021 GettingStarted</title>
		<link rel="alternate" type="text/html" href="http://www.openhardwareconf.org/index.php?title=Swagbadge2021_GettingStarted&amp;diff=1257"/>
		<updated>2020-12-22T04:56:49Z</updated>

		<summary type="html">&lt;p&gt;BenLeslie: /* My package arrived in the mail, first steps. */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Getting started with the Swagbadge =&lt;br /&gt;
&lt;br /&gt;
== Support ==&lt;br /&gt;
* The [https://spectrum.chat/lca2021-swagbadge Swag Badge Spectrum chat] is a place where the badge team hangs out, ready to answer your questions.&lt;br /&gt;
&lt;br /&gt;
== My package arrived in the mail, first steps. ==&lt;br /&gt;
* Your package should contain your badge!&lt;br /&gt;
&lt;br /&gt;
[[File:swagbadgepackage.jpg|400px]]&lt;br /&gt;
&lt;br /&gt;
* Take off the protective cases to reveal the screens.&lt;br /&gt;
* Powering it up&lt;br /&gt;
** Insert a micro USB cable into the badge and connect the other end to a USB port on your computer or USB power source.&lt;br /&gt;
** A green light should glow on the rear of the board, and a title appear across the two screens.&lt;br /&gt;
* Turning it on and off again&lt;br /&gt;
** Plugging/unplugging it is fine. Usually the badge isn&#039;t running anything intensely enough that just unpowering it would cause a problem.&lt;br /&gt;
* On bootup, you should see:&lt;br /&gt;
** The OLED screens will display &amp;quot;Aiko&amp;quot; and a version number as a title&lt;br /&gt;
** It will also display something else to tell you to set up your wifi.&lt;br /&gt;
&lt;br /&gt;
== Getting it on your network ==&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Safety precautions we have provided&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
* When using any hardware ordered off the internet, you can&#039;t be quite certain what software might be present on it. Before shipping these badges to you, we reflashed a fresh copy of MicroPython onto the Lolin32.&lt;br /&gt;
* The framework running on the badge is Aiko, which is open source.&lt;br /&gt;
* The software on the badge is available on the CCHS repository, also all open source.&lt;br /&gt;
* The badges are designed to communicate over MQTT - a lightweight standard for messaging on IoT devices, but we are aware of privacy considerations: you don&#039;t want anybody able to control your badge from afar. The swagbadge protocol provides support for encrypted messages.&lt;br /&gt;
&lt;br /&gt;
=== Getting the device on your wifi - wireless ===&lt;br /&gt;
&lt;br /&gt;
* The first time you boot your device, it won&#039;t know how to talk to your network. If it can&#039;t detect a pre-existing set of network credentials, or connect to anything it knows about, it will establish a temporary access point and prompt you to navigate to it to enter your wifi details.&lt;br /&gt;
* &#039;&#039;Note: Your device can only talk to a 2.4GHz network: it is not compatible with 5GHz WiFi.&#039;&#039;&lt;br /&gt;
* The screens on your badge will say: &amp;lt;code&amp;gt;Configure WiFi: aiko1234a12341234. Try http://192.168.4.1&amp;lt;/code&amp;gt;&lt;br /&gt;
* Use your phone or computer to connect to the wifi network on the badge. Its name starts with &amp;lt;code&amp;gt;aiko&amp;lt;/code&amp;gt; followed by some numbers/letters.&lt;br /&gt;
* Once you&#039;re connected to the badge, open a web browser to the IP address on the screens. Something like &amp;lt;code&amp;gt;http://192.168.4.1&amp;lt;/code&amp;gt;&lt;br /&gt;
* You&#039;ll be prompted to enter your wifi SSID and wifi password.&lt;br /&gt;
* Once you&#039;ve saved that, the badge will restart using the credentials you&#039;ve provided and it will shut down its wifi access point.&lt;br /&gt;
&lt;br /&gt;
Note: If you are using an Android device to link the badge to your WiFi, it will pop up a dialog to say you are switching to a network that doesn&#039;t have Internet access and ask if you want to switch back. Select &amp;quot;Keep&amp;quot; to stay on the badge&#039;s temporary access point.&lt;br /&gt;
&lt;br /&gt;
=== Getting the device on your wifi - commandline with mpfshell ===&lt;br /&gt;
&lt;br /&gt;
* If setting up via the wifi AP (access point) doesn&#039;t work, you can put a configuration file onto the badge.&lt;br /&gt;
* You&#039;ll need to start by getting [[Swagbadge2021_UpdatingSoftware|a copy of the aiko firmware, and installing mpfshell]]&lt;br /&gt;
* &#039;&#039;Note: Your device can only talk to a 2G network: it is not compatible with 5g.&#039;&#039;&lt;br /&gt;
* Edit aiko_engine_mp/configuration/net.py and insert the details of your SSID and password.&lt;br /&gt;
* use mpfshell: &amp;lt;code&amp;gt;mpfshell -o COM3&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;put configuration/net.py configuration/net.py&amp;lt;/code&amp;gt;&lt;br /&gt;
* fire up repl to view the console log &lt;br /&gt;
* You can now restart your device&lt;br /&gt;
* On bootup it should now talk to your network and you can see it on the console log.&lt;br /&gt;
&lt;br /&gt;
On bootup you should now see...&lt;br /&gt;
&lt;br /&gt;
= Running pre-installed applications =&lt;br /&gt;
* Pre-installed things, how to access and run them.&lt;br /&gt;
&lt;br /&gt;
= Extensions: Adding a SAO =&lt;br /&gt;
* provided by others&lt;br /&gt;
* build your own (linky here to our docs)&lt;br /&gt;
&lt;br /&gt;
= Extensions: Updating the software framework =&lt;br /&gt;
&lt;br /&gt;
Between when we ship the board and when it arrives, there might be some changes to the software framework (Aiko). Here&#039;s how to update it. Or perhaps you&#039;re interested in writing your own applications? &lt;br /&gt;
&lt;br /&gt;
[[Swagbadge2021_UpdatingSoftware|Updating the Software]]&lt;/div&gt;</summary>
		<author><name>BenLeslie</name></author>
	</entry>
	<entry>
		<id>http://www.openhardwareconf.org/index.php?title=Swagbadge2021_GettingStarted&amp;diff=1256</id>
		<title>Swagbadge2021 GettingStarted</title>
		<link rel="alternate" type="text/html" href="http://www.openhardwareconf.org/index.php?title=Swagbadge2021_GettingStarted&amp;diff=1256"/>
		<updated>2020-12-22T04:56:04Z</updated>

		<summary type="html">&lt;p&gt;BenLeslie: /* My package arrived in the mail, first steps. */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Getting started with the Swagbadge =&lt;br /&gt;
&lt;br /&gt;
== Support ==&lt;br /&gt;
* The [https://spectrum.chat/lca2021-swagbadge Swag Badge Spectrum chat] is a place where the badge team hangs out, ready to answer your questions.&lt;br /&gt;
&lt;br /&gt;
== My package arrived in the mail, first steps. ==&lt;br /&gt;
* Your package should contain your badge!&lt;br /&gt;
&lt;br /&gt;
[[File:swagbadgepackage.jpg]]&lt;br /&gt;
&lt;br /&gt;
* Take off the protective cases to reveal the screens.&lt;br /&gt;
* Powering it up&lt;br /&gt;
** Insert a micro USB cable into the badge and connect the other end to a USB port on your computer or USB power source.&lt;br /&gt;
** A green light should glow on the rear of the board, and a title appear across the two screens.&lt;br /&gt;
* Turning it on and off again&lt;br /&gt;
** Plugging/unplugging it is fine. Usually the badge isn&#039;t running anything intensely enough that just unpowering it would cause a problem.&lt;br /&gt;
* On bootup, you should see:&lt;br /&gt;
** The OLED screens will display &amp;quot;Aiko&amp;quot; and a version number as a title&lt;br /&gt;
** It will also display something else to tell you to set up your wifi.&lt;br /&gt;
&lt;br /&gt;
== Getting it on your network ==&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Safety precautions we have provided&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
* When using any hardware ordered off the internet, you can&#039;t be quite certain what software might be present on it. Before shipping these badges to you, we reflashed a fresh copy of MicroPython onto the Lolin32.&lt;br /&gt;
* The framework running on the badge is Aiko, which is open source.&lt;br /&gt;
* The software on the badge is available on the CCHS repository, also all open source.&lt;br /&gt;
* The badges are designed to communicate over MQTT - a lightweight standard for messaging on IoT devices, but we are aware of privacy considerations: you don&#039;t want anybody able to control your badge from afar. The swagbadge protocol provides support for encrypted messages.&lt;br /&gt;
&lt;br /&gt;
=== Getting the device on your wifi - wireless ===&lt;br /&gt;
&lt;br /&gt;
* The first time you boot your device, it won&#039;t know how to talk to your network. If it can&#039;t detect a pre-existing set of network credentials, or connect to anything it knows about, it will establish a temporary access point and prompt you to navigate to it to enter your wifi details.&lt;br /&gt;
* &#039;&#039;Note: Your device can only talk to a 2.4GHz network: it is not compatible with 5GHz WiFi.&#039;&#039;&lt;br /&gt;
* The screens on your badge will say: &amp;lt;code&amp;gt;Configure WiFi: aiko1234a12341234. Try http://192.168.4.1&amp;lt;/code&amp;gt;&lt;br /&gt;
* Use your phone or computer to connect to the wifi network on the badge. Its name starts with &amp;lt;code&amp;gt;aiko&amp;lt;/code&amp;gt; followed by some numbers/letters.&lt;br /&gt;
* Once you&#039;re connected to the badge, open a web browser to the IP address on the screens. Something like &amp;lt;code&amp;gt;http://192.168.4.1&amp;lt;/code&amp;gt;&lt;br /&gt;
* You&#039;ll be prompted to enter your wifi SSID and wifi password.&lt;br /&gt;
* Once you&#039;ve saved that, the badge will restart using the credentials you&#039;ve provided and it will shut down its wifi access point.&lt;br /&gt;
&lt;br /&gt;
Note: If you are using an Android device to link the badge to your WiFi, it will pop up a dialog to say you are switching to a network that doesn&#039;t have Internet access and ask if you want to switch back. Select &amp;quot;Keep&amp;quot; to stay on the badge&#039;s temporary access point.&lt;br /&gt;
&lt;br /&gt;
=== Getting the device on your wifi - commandline with mpfshell ===&lt;br /&gt;
&lt;br /&gt;
* If setting up via the wifi AP (access point) doesn&#039;t work, you can put a configuration file onto the badge.&lt;br /&gt;
* You&#039;ll need to start by getting [[Swagbadge2021_UpdatingSoftware|a copy of the aiko firmware, and installing mpfshell]]&lt;br /&gt;
* &#039;&#039;Note: Your device can only talk to a 2G network: it is not compatible with 5g.&#039;&#039;&lt;br /&gt;
* Edit aiko_engine_mp/configuration/net.py and insert the details of your SSID and password.&lt;br /&gt;
* use mpfshell: &amp;lt;code&amp;gt;mpfshell -o COM3&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;put configuration/net.py configuration/net.py&amp;lt;/code&amp;gt;&lt;br /&gt;
* fire up repl to view the console log &lt;br /&gt;
* You can now restart your device&lt;br /&gt;
* On bootup it should now talk to your network and you can see it on the console log.&lt;br /&gt;
&lt;br /&gt;
On bootup you should now see...&lt;br /&gt;
&lt;br /&gt;
= Running pre-installed applications =&lt;br /&gt;
* Pre-installed things, how to access and run them.&lt;br /&gt;
&lt;br /&gt;
= Extensions: Adding a SAO =&lt;br /&gt;
* provided by others&lt;br /&gt;
* build your own (linky here to our docs)&lt;br /&gt;
&lt;br /&gt;
= Extensions: Updating the software framework =&lt;br /&gt;
&lt;br /&gt;
Between when we ship the board and when it arrives, there might be some changes to the software framework (Aiko). Here&#039;s how to update it. Or perhaps you&#039;re interested in writing your own applications? &lt;br /&gt;
&lt;br /&gt;
[[Swagbadge2021_UpdatingSoftware|Updating the Software]]&lt;/div&gt;</summary>
		<author><name>BenLeslie</name></author>
	</entry>
	<entry>
		<id>http://www.openhardwareconf.org/index.php?title=File:Swagbadgepackage.jpg&amp;diff=1255</id>
		<title>File:Swagbadgepackage.jpg</title>
		<link rel="alternate" type="text/html" href="http://www.openhardwareconf.org/index.php?title=File:Swagbadgepackage.jpg&amp;diff=1255"/>
		<updated>2020-12-22T04:55:56Z</updated>

		<summary type="html">&lt;p&gt;BenLeslie: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>BenLeslie</name></author>
	</entry>
	<entry>
		<id>http://www.openhardwareconf.org/index.php?title=Swagbadge2021_UpdatingSoftware&amp;diff=1253</id>
		<title>Swagbadge2021 UpdatingSoftware</title>
		<link rel="alternate" type="text/html" href="http://www.openhardwareconf.org/index.php?title=Swagbadge2021_UpdatingSoftware&amp;diff=1253"/>
		<updated>2020-12-22T04:46:59Z</updated>

		<summary type="html">&lt;p&gt;BenLeslie: /* Setting up your Mac OS system for connecting to #swagbadge hardware */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Updating the software framework =&lt;br /&gt;
&lt;br /&gt;
Swagbadge owners might want to update the software framework (Aiko). Dagbadge owners will need to put the framework onto their badge before they can use it.&lt;br /&gt;
&lt;br /&gt;
Here&#039;s how to do that!&lt;br /&gt;
&lt;br /&gt;
== Requirements ==&lt;br /&gt;
&lt;br /&gt;
* #swagbadge or #dagbadge or any ESP32 with an OLED screen&lt;br /&gt;
* Micro-USB cable&lt;br /&gt;
* Linux, Mac OS or Linux system running Python 3&lt;br /&gt;
* Command line tools: git&lt;br /&gt;
&lt;br /&gt;
== Setting up your Windows 10 system for connecting to badge hardware ==&lt;br /&gt;
&lt;br /&gt;
How to find your serial COM port on Windows: &lt;br /&gt;
* Use the Device Manager. &lt;br /&gt;
* Under the &amp;quot;Ports&amp;quot; category, you&#039;ll see one or more entries. Hopefully one of which is your badge! It will tell you what Port it is on. &lt;br /&gt;
* If you can&#039;t see your badge, you might need to go up to the View menu and use &amp;quot;Show hidden devices&amp;quot; and see if that helps.&lt;br /&gt;
&lt;br /&gt;
Windows 10 may automatically discover your #swagbadge USB hardware and automatically install the correct USB serial hardware driver, or if nothing still shows up, you might need to update your USB drivers for supporting the USB hardware CP210x on your #swagbadge, please follow these instructions:&lt;br /&gt;
* Download the CP210x drivers from [https://www.silabs.com/developers/usb-to-uart-bridge-vcp-drivers Silicon Labs Windows Universal Driver]&lt;br /&gt;
* Unpack the zip file&lt;br /&gt;
* Follow the Silicon Labs instructions for [https://www.silabs.com/documents/public/application-notes/AN335.pdf INF only install] (Section 5 on page 9)&lt;br /&gt;
&lt;br /&gt;
By this point, you have know the serial COM port that your #swagbadge is connected to, e.g COM4&lt;br /&gt;
&lt;br /&gt;
== Setting up your Mac OS system for connecting to #swagbadge hardware ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
How to find your serial COM port on OS X: &lt;br /&gt;
&lt;br /&gt;
    $ ls /dev/tty.usb*&lt;br /&gt;
&lt;br /&gt;
Unless you have lot of dev boards (or maybe a phone) plugged in you should just see a single filename there.&lt;br /&gt;
Use this (without the `/dev/` prefix) when using the `open` command in `mpfshell`&lt;br /&gt;
&lt;br /&gt;
To get a working `mpfshell` install a recent version of Python (Python3.8 is known to work) using a installed DMG.&lt;br /&gt;
Then create a *venv* and install the necessary tools using pip.&lt;br /&gt;
For example:&lt;br /&gt;
&lt;br /&gt;
    $ mkdir swag&lt;br /&gt;
    $ cd swag&lt;br /&gt;
    $ python3.8 -m venv env&lt;br /&gt;
    $ ./env/bin/pip install esptool mpfshell&lt;br /&gt;
&lt;br /&gt;
You can then run `mpfshell` to connect:&lt;br /&gt;
&lt;br /&gt;
    $ ./env/bin/mpfshell&lt;br /&gt;
    mpfs [/]&amp;gt; open &amp;lt;your device node as found previously&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Setting up your Linux system for connecting to #swagbadge hardware ==&lt;br /&gt;
[Link other instructions here]&lt;br /&gt;
&lt;br /&gt;
== Setting up your Windows 10 system for installing #swagbadge firmware == &lt;br /&gt;
&lt;br /&gt;
* Install [https://docs.conda.io/en/latest/miniconda.html Miniconda3] to create a specific Python development environment. (Note we are using Python3 not Python2)&lt;br /&gt;
* Create specific Python 3 environment for playing around with your #swagbadge&lt;br /&gt;
** Start an Anaconda Powershell Prompt (aka Windows Terminal)&lt;br /&gt;
** &amp;lt;code&amp;gt;conda create --yes -n swagbadge python=3&amp;lt;/code&amp;gt;&lt;br /&gt;
** &amp;lt;code&amp;gt;conda activate swagbadge&amp;lt;/code&amp;gt;&lt;br /&gt;
* Your command prompt should now look like: &amp;lt;code&amp;gt;(swagbadge) C:\Users\[Username]&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Install some python tools to let us prepare and communicate with the badge&lt;br /&gt;
** &amp;lt;code&amp;gt;pip install esptool mpfshell&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* To test that the required tools are installed, trying running the following commands&lt;br /&gt;
** &amp;lt;code&amp;gt;esptool&amp;lt;/code&amp;gt;  # Should show you help on running the esptool&lt;br /&gt;
** &amp;lt;code&amp;gt;mpfshell&amp;lt;/code&amp;gt;  # Should show three lines of output&lt;br /&gt;
*** &amp;lt;code&amp;gt;exit&amp;lt;/code&amp;gt;  #  To exit mpfshell&lt;br /&gt;
&lt;br /&gt;
== Download #swagbadge (Aiko Engine) firmware ==&lt;br /&gt;
&lt;br /&gt;
Within your Anaconda Prompt session, change directory to where you’d like the #swagbadge software to be downloaded, for example:&lt;br /&gt;
* &amp;lt;code&amp;gt;cd $HOME/software&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Download #swagbadge firmware:&lt;br /&gt;
* &amp;lt;code&amp;gt;git clone https://github.com/geekscape/aiko_engine_mp.git&amp;lt;/code&amp;gt; # NOTE: this URL will change once we&#039;re live&lt;br /&gt;
* &amp;lt;code&amp;gt;cd aiko_engine_mp&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Install MicroPython&lt;br /&gt;
* Create a directory to hold the MicroPython firmware, such as aiko_engine_mp/firmware/&lt;br /&gt;
* &amp;lt;code&amp;gt;mkdir firmware&amp;lt;/code&amp;gt;&lt;br /&gt;
* Using your web browser, download: [http://micropython.org/resources/firmware/esp32-idf4-20200902-v1.13.bin esp32-idf4-20200902-v1.13.bin] (mouse right button click → [Save As …]  saving the MicroPython firmware in the firmware directory you just made.&lt;br /&gt;
** The [http://micropython.org/download/ MicroPython download list] has a link to a bunch of firmware drivers, we are using the one for the esp32 device, with the latest 1.4 generic&lt;br /&gt;
&lt;br /&gt;
Erase #swagbadge LoLin-Lite ESP32 flash memory&lt;br /&gt;
* &amp;lt;code&amp;gt;esptool --chip esp32 --port COM3 erase_flash&amp;lt;/code&amp;gt; # adjust the port to suit.&lt;br /&gt;
* You’ll know it’s worked, if the output finishes with “Hard resetting via RTS pin…”&lt;br /&gt;
&lt;br /&gt;
Install microPython on the badge&lt;br /&gt;
* &amp;lt;code&amp;gt;esptool --chip esp32 --port COM3 --baud 460800 write_flash -z 0x1000 firmware\esp32-idf4-20200902-v1.13.bin&amp;lt;/code&amp;gt; #adjust port and firmware location if necessary&lt;br /&gt;
* You’ll know it’s worked, if the output finishes with “Hard resetting via RTS pin…”&lt;br /&gt;
&lt;br /&gt;
Test that the software is installed correctly by using mpfshell&lt;br /&gt;
* &amp;lt;code&amp;gt;mpfshell -o COM3&amp;lt;/code&amp;gt; # Adjust port to suit&lt;br /&gt;
* If it has made a connection to your badge, you will see it say&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;Connected to esp32&lt;br /&gt;
** Micropython File Shell v0.9.1, sw@kaltpost.de **&lt;br /&gt;
-- Running on Python 3.8 using PySerial 3.4 --&lt;br /&gt;
mpfs [/]&amp;gt; &amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Using mpfshell ==&lt;br /&gt;
&lt;br /&gt;
mpfshell has two functions: it lets you put files on/off the device, and it can give you a python shell to execute code on the device.&lt;br /&gt;
* Getting files on/off the device is a bit like commandline ftp&lt;br /&gt;
** ls - looks at the files on your micropython device&lt;br /&gt;
** lls - looks at the files on your local computer in the current directory&lt;br /&gt;
** put - puts a file to the device&lt;br /&gt;
** cat - shows you the contents of the file&lt;br /&gt;
** help() - gives you more information on the commands&lt;br /&gt;
** repl - opens up the python shell on the badge&lt;br /&gt;
&lt;br /&gt;
Note: To get out of repl, use Ctrl-Q (on Windows) which drops you back into mpfshell&lt;br /&gt;
&lt;br /&gt;
A little program to say hello world!&lt;br /&gt;
* &amp;lt;code&amp;gt; &amp;gt;&amp;gt;&amp;gt; print(&amp;quot;hello world&amp;quot;)&amp;lt;/code&amp;gt;&lt;br /&gt;
* Output: &amp;lt;code&amp;gt;hello world&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A little program to turn the blue light on the board on and off (this is on the underside of the Swagbadge, visible through a circular cutout)&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&amp;gt;&amp;gt;&amp;gt; import machine&lt;br /&gt;
&amp;gt;&amp;gt;&amp;gt; pin22=machine.Pin(22, machine.Pin.OUT, machine.Pin.PULL_UP)&lt;br /&gt;
&amp;gt;&amp;gt;&amp;gt; pin22.value(0) &lt;br /&gt;
&amp;gt;&amp;gt;&amp;gt; pin22.value(1)&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Putting the Aiko framework onto the device, using mpfshell == &lt;br /&gt;
* &amp;lt;code&amp;gt;mpfshell COM5 -s scripts\aiko.mpf&amp;lt;/code&amp;gt; #run from within the aiko_framework_mp directory&lt;br /&gt;
&lt;br /&gt;
=== Windows only: Patch mpfshell ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Note!&#039;&#039; mpfshell needs a patch applied to let it run a script under Windows.&lt;br /&gt;
&lt;br /&gt;
* Inside &amp;lt;code&amp;gt;C:/users/USERNAME/Miniconda2/envs/swagbadge/Lib/site-packages/mp&amp;lt;/code&amp;gt;&lt;br /&gt;
* edit &amp;lt;code&amp;gt;mpfshell.py&amp;lt;/code&amp;gt;&lt;br /&gt;
* Search for &amp;lt;code&amp;gt;elif args.script is not None:&amp;lt;/code&amp;gt;, around line 796&lt;br /&gt;
* between that line and the next, insert two lines. It should look like:&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
    elif args.script is not None:&lt;br /&gt;
&lt;br /&gt;
        if platform.system() == &amp;quot;Windows&amp;quot;:  #INSERT THIS LINE&lt;br /&gt;
            mpfs.use_rawinput = True        #INSERT THIS LINE&lt;br /&gt;
&lt;br /&gt;
        f = open(args.script, &amp;quot;r&amp;quot;)&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
* Python is very particular about spacing. The rest of the code uses 4 spaces for indents so follow suit.&lt;br /&gt;
&lt;br /&gt;
= Reboot to shell / Force runaway code to stop =&lt;br /&gt;
&lt;br /&gt;
It&#039;s possible to write code that will leave your badge unresponsive. Rebooting just reruns the same bad code. What to do?&lt;br /&gt;
&lt;br /&gt;
* Place a finger on each of the bottom slider pads, either side of the microprocessor. &lt;br /&gt;
* Trigger a restart by using the button on the back of the badge, or Ctrl-D in repl (if you can get into repl)&lt;br /&gt;
&lt;br /&gt;
The badge will restart but not autorun any code, just drop you back at the repl prompt. From there you can &amp;lt;code&amp;gt;put&amp;lt;/code&amp;gt; bugfixed code back onto the device.&lt;/div&gt;</summary>
		<author><name>BenLeslie</name></author>
	</entry>
	<entry>
		<id>http://www.openhardwareconf.org/index.php?title=Swagbadge2021_UpdatingSoftware&amp;diff=1252</id>
		<title>Swagbadge2021 UpdatingSoftware</title>
		<link rel="alternate" type="text/html" href="http://www.openhardwareconf.org/index.php?title=Swagbadge2021_UpdatingSoftware&amp;diff=1252"/>
		<updated>2020-12-22T04:42:12Z</updated>

		<summary type="html">&lt;p&gt;BenLeslie: /* Setting up your Mac OS system for connecting to #swagbadge hardware */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Updating the software framework =&lt;br /&gt;
&lt;br /&gt;
Swagbadge owners might want to update the software framework (Aiko). Dagbadge owners will need to put the framework onto their badge before they can use it.&lt;br /&gt;
&lt;br /&gt;
Here&#039;s how to do that!&lt;br /&gt;
&lt;br /&gt;
== Requirements ==&lt;br /&gt;
&lt;br /&gt;
* #swagbadge or #dagbadge or any ESP32 with an OLED screen&lt;br /&gt;
* Micro-USB cable&lt;br /&gt;
* Linux, Mac OS or Linux system running Python 3&lt;br /&gt;
* Command line tools: git&lt;br /&gt;
&lt;br /&gt;
== Setting up your Windows 10 system for connecting to badge hardware ==&lt;br /&gt;
&lt;br /&gt;
How to find your serial COM port on Windows: &lt;br /&gt;
* Use the Device Manager. &lt;br /&gt;
* Under the &amp;quot;Ports&amp;quot; category, you&#039;ll see one or more entries. Hopefully one of which is your badge! It will tell you what Port it is on. &lt;br /&gt;
* If you can&#039;t see your badge, you might need to go up to the View menu and use &amp;quot;Show hidden devices&amp;quot; and see if that helps.&lt;br /&gt;
&lt;br /&gt;
Windows 10 may automatically discover your #swagbadge USB hardware and automatically install the correct USB serial hardware driver, or if nothing still shows up, you might need to update your USB drivers for supporting the USB hardware CP210x on your #swagbadge, please follow these instructions:&lt;br /&gt;
* Download the CP210x drivers from [https://www.silabs.com/developers/usb-to-uart-bridge-vcp-drivers Silicon Labs Windows Universal Driver]&lt;br /&gt;
* Unpack the zip file&lt;br /&gt;
* Follow the Silicon Labs instructions for [https://www.silabs.com/documents/public/application-notes/AN335.pdf INF only install] (Section 5 on page 9)&lt;br /&gt;
&lt;br /&gt;
By this point, you have know the serial COM port that your #swagbadge is connected to, e.g COM4&lt;br /&gt;
&lt;br /&gt;
== Setting up your Mac OS system for connecting to #swagbadge hardware ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
How to find your serial COM port on OS X: &lt;br /&gt;
&lt;br /&gt;
    $ ls /dev/tty.usb*&lt;br /&gt;
&lt;br /&gt;
Unless you have lot of dev boards (or maybe a phone) plugged in you should just see a single filename there.&lt;br /&gt;
Use this (without the `/dev/` prefix) when using the `open` command in `mpfshell`&lt;br /&gt;
&lt;br /&gt;
== Setting up your Linux system for connecting to #swagbadge hardware ==&lt;br /&gt;
[Link other instructions here]&lt;br /&gt;
&lt;br /&gt;
== Setting up your Windows 10 system for installing #swagbadge firmware == &lt;br /&gt;
&lt;br /&gt;
* Install [https://docs.conda.io/en/latest/miniconda.html Miniconda3] to create a specific Python development environment. (Note we are using Python3 not Python2)&lt;br /&gt;
* Create specific Python 3 environment for playing around with your #swagbadge&lt;br /&gt;
** Start an Anaconda Powershell Prompt (aka Windows Terminal)&lt;br /&gt;
** &amp;lt;code&amp;gt;conda create --yes -n swagbadge python=3&amp;lt;/code&amp;gt;&lt;br /&gt;
** &amp;lt;code&amp;gt;conda activate swagbadge&amp;lt;/code&amp;gt;&lt;br /&gt;
* Your command prompt should now look like: &amp;lt;code&amp;gt;(swagbadge) C:\Users\[Username]&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Install some python tools to let us prepare and communicate with the badge&lt;br /&gt;
** &amp;lt;code&amp;gt;pip install esptool mpfshell&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* To test that the required tools are installed, trying running the following commands&lt;br /&gt;
** &amp;lt;code&amp;gt;esptool&amp;lt;/code&amp;gt;  # Should show you help on running the esptool&lt;br /&gt;
** &amp;lt;code&amp;gt;mpfshell&amp;lt;/code&amp;gt;  # Should show three lines of output&lt;br /&gt;
*** &amp;lt;code&amp;gt;exit&amp;lt;/code&amp;gt;  #  To exit mpfshell&lt;br /&gt;
&lt;br /&gt;
== Download #swagbadge (Aiko Engine) firmware ==&lt;br /&gt;
&lt;br /&gt;
Within your Anaconda Prompt session, change directory to where you’d like the #swagbadge software to be downloaded, for example:&lt;br /&gt;
* &amp;lt;code&amp;gt;cd $HOME/software&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Download #swagbadge firmware:&lt;br /&gt;
* &amp;lt;code&amp;gt;git clone https://github.com/geekscape/aiko_engine_mp.git&amp;lt;/code&amp;gt; # NOTE: this URL will change once we&#039;re live&lt;br /&gt;
* &amp;lt;code&amp;gt;cd aiko_engine_mp&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Install MicroPython&lt;br /&gt;
* Create a directory to hold the MicroPython firmware, such as aiko_engine_mp/firmware/&lt;br /&gt;
* &amp;lt;code&amp;gt;mkdir firmware&amp;lt;/code&amp;gt;&lt;br /&gt;
* Using your web browser, download: [http://micropython.org/resources/firmware/esp32-idf4-20200902-v1.13.bin esp32-idf4-20200902-v1.13.bin] (mouse right button click → [Save As …]  saving the MicroPython firmware in the firmware directory you just made.&lt;br /&gt;
** The [http://micropython.org/download/ MicroPython download list] has a link to a bunch of firmware drivers, we are using the one for the esp32 device, with the latest 1.4 generic&lt;br /&gt;
&lt;br /&gt;
Erase #swagbadge LoLin-Lite ESP32 flash memory&lt;br /&gt;
* &amp;lt;code&amp;gt;esptool --chip esp32 --port COM3 erase_flash&amp;lt;/code&amp;gt; # adjust the port to suit.&lt;br /&gt;
* You’ll know it’s worked, if the output finishes with “Hard resetting via RTS pin…”&lt;br /&gt;
&lt;br /&gt;
Install microPython on the badge&lt;br /&gt;
* &amp;lt;code&amp;gt;esptool --chip esp32 --port COM3 --baud 460800 write_flash -z 0x1000 firmware\esp32-idf4-20200902-v1.13.bin&amp;lt;/code&amp;gt; #adjust port and firmware location if necessary&lt;br /&gt;
* You’ll know it’s worked, if the output finishes with “Hard resetting via RTS pin…”&lt;br /&gt;
&lt;br /&gt;
Test that the software is installed correctly by using mpfshell&lt;br /&gt;
* &amp;lt;code&amp;gt;mpfshell -o COM3&amp;lt;/code&amp;gt; # Adjust port to suit&lt;br /&gt;
* If it has made a connection to your badge, you will see it say&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;Connected to esp32&lt;br /&gt;
** Micropython File Shell v0.9.1, sw@kaltpost.de **&lt;br /&gt;
-- Running on Python 3.8 using PySerial 3.4 --&lt;br /&gt;
mpfs [/]&amp;gt; &amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Using mpfshell ==&lt;br /&gt;
&lt;br /&gt;
mpfshell has two functions: it lets you put files on/off the device, and it can give you a python shell to execute code on the device.&lt;br /&gt;
* Getting files on/off the device is a bit like commandline ftp&lt;br /&gt;
** ls - looks at the files on your micropython device&lt;br /&gt;
** lls - looks at the files on your local computer in the current directory&lt;br /&gt;
** put - puts a file to the device&lt;br /&gt;
** cat - shows you the contents of the file&lt;br /&gt;
** help() - gives you more information on the commands&lt;br /&gt;
** repl - opens up the python shell on the badge&lt;br /&gt;
&lt;br /&gt;
Note: To get out of repl, use Ctrl-Q (on Windows) which drops you back into mpfshell&lt;br /&gt;
&lt;br /&gt;
A little program to say hello world!&lt;br /&gt;
* &amp;lt;code&amp;gt; &amp;gt;&amp;gt;&amp;gt; print(&amp;quot;hello world&amp;quot;)&amp;lt;/code&amp;gt;&lt;br /&gt;
* Output: &amp;lt;code&amp;gt;hello world&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A little program to turn the blue light on the board on and off (this is on the underside of the Swagbadge, visible through a circular cutout)&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&amp;gt;&amp;gt;&amp;gt; import machine&lt;br /&gt;
&amp;gt;&amp;gt;&amp;gt; pin22=machine.Pin(22, machine.Pin.OUT, machine.Pin.PULL_UP)&lt;br /&gt;
&amp;gt;&amp;gt;&amp;gt; pin22.value(0) &lt;br /&gt;
&amp;gt;&amp;gt;&amp;gt; pin22.value(1)&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Putting the Aiko framework onto the device, using mpfshell == &lt;br /&gt;
* &amp;lt;code&amp;gt;mpfshell COM5 -s scripts\aiko.mpf&amp;lt;/code&amp;gt; #run from within the aiko_framework_mp directory&lt;br /&gt;
&lt;br /&gt;
=== Windows only: Patch mpfshell ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Note!&#039;&#039; mpfshell needs a patch applied to let it run a script under Windows.&lt;br /&gt;
&lt;br /&gt;
* Inside &amp;lt;code&amp;gt;C:/users/USERNAME/Miniconda2/envs/swagbadge/Lib/site-packages/mp&amp;lt;/code&amp;gt;&lt;br /&gt;
* edit &amp;lt;code&amp;gt;mpfshell.py&amp;lt;/code&amp;gt;&lt;br /&gt;
* Search for &amp;lt;code&amp;gt;elif args.script is not None:&amp;lt;/code&amp;gt;, around line 796&lt;br /&gt;
* between that line and the next, insert two lines. It should look like:&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
    elif args.script is not None:&lt;br /&gt;
&lt;br /&gt;
        if platform.system() == &amp;quot;Windows&amp;quot;:  #INSERT THIS LINE&lt;br /&gt;
            mpfs.use_rawinput = True        #INSERT THIS LINE&lt;br /&gt;
&lt;br /&gt;
        f = open(args.script, &amp;quot;r&amp;quot;)&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
* Python is very particular about spacing. The rest of the code uses 4 spaces for indents so follow suit.&lt;br /&gt;
&lt;br /&gt;
= Reboot to shell / Force runaway code to stop =&lt;br /&gt;
&lt;br /&gt;
It&#039;s possible to write code that will leave your badge unresponsive. Rebooting just reruns the same bad code. What to do?&lt;br /&gt;
&lt;br /&gt;
* Place a finger on each of the bottom slider pads, either side of the microprocessor. &lt;br /&gt;
* Trigger a restart by using the button on the back of the badge, or Ctrl-D in repl (if you can get into repl)&lt;br /&gt;
&lt;br /&gt;
The badge will restart but not autorun any code, just drop you back at the repl prompt. From there you can &amp;lt;code&amp;gt;put&amp;lt;/code&amp;gt; bugfixed code back onto the device.&lt;/div&gt;</summary>
		<author><name>BenLeslie</name></author>
	</entry>
</feed>