|
1 |
| -# JEM Micropython |
2 |
| -Micropython code for JEM core |
| 1 | +# JEM Micropython Overview |
| 2 | +- Micropython code for JEM core |
| 3 | +- This repo contains JEM specific drivers and libraries to interact with JEM ESP32 MCU as well as the sensors on board. |
| 4 | +- Code is written in micropython, as easy to use interpreted language |
3 | 5 |
|
4 | 6 | ## Quickstart
|
5 |
| -### Install Atom IDE + Pymakr plugin |
6 |
| -- [Atom IDE Download](https://atom.io/) |
7 |
| -- [Atom Pymakr Plugin](https://atom.io/packages/pymakr) |
8 |
| - + Used by Atom to talk to JEM Micropython |
| 7 | +### Use Arduino Micropython IDE |
| 8 | +- Download release https://github.com/arduino/lab-micropython-editor/releases |
| 9 | + + For mac, linux or windows just download the appropriate package and unzip |
| 10 | +- Then open Micropython IDE and click 'Connect' |
| 11 | + + assuming your JEM is plugged into computer and turned ON |
| 12 | +- You should see list of files / directories on your JEM
A3DB
code> |
| 13 | +- REPL terminal also available |
| 14 | +- You can edit a file and click the 'Save' button to flash the code to JEM |
| 15 | + |
| 16 | +### Interact with JEM via the Web IDE |
| 17 | +- [JEM Web IDE](https://kitlab.io/jem/ide) |
| 18 | + + Uses Bluetooth Low Energy (BLE) to flash code to JEM from Web Browser |
| 19 | + + Must use Google Chrome and have a computer with Bluetooth enabled (most do) |
| 20 | +- Step 1: Open [JEM Web IDE](https://kitlab.io/jem/ide) |
| 21 | +- Step 2: Make sure your JEM is turned on (Blue LED should be on) |
| 22 | +- Step 3: Navigate to th 'Pair' tab on the Web IDE and click 'Connect' and select JEM available |
| 23 | +- Step 4: Navigate to the 'REPL' tab and press enter a couple times to make sure you get a prompt '>>' |
| 24 | +- Step 5: Send a command to JEM |
| 25 | + + Type: print("hello world") |
| 26 | + + Make sure JEM echos this back in the terminal |
| 27 | +- Step 6: View JEM Board Files (make sure you are connected first) |
| 28 | + + Navigate to 'Editor' tab and verify you see the 'jem' folder |
| 29 | + + Click on it to expand and see files and sub-directories |
| 30 | + + These are files loaded directly from your board |
| 31 | + + Edit main.py by adding something like print("hello world") |
| 32 | + + Then click on the 'Flash' button on the bottom |
| 33 | + + Wait for flash to finish and then reconnect when prompted |
| 34 | + |
| 35 | +### Interact with JEM via iOS App |
| 36 | +- Go to iOS app store and search for 'KitLab.io' |
| 37 | +- Download App and open |
| 38 | +- Navigate to 'Pair' tab and click 'Connect' |
| 39 | +- Connect to JEM |
| 40 | +- Navigate to 'REPL' tab |
| 41 | + + Type: print("hello world") |
| 42 | + + Make sure JEM echos this back in the terminal |
| 43 | +- You can also edit files on JEM (like the WEB IDE) by navigating to the 'Editor' tab |
| 44 | +- Android app coming soon! |
9 | 45 |
|
10 | 46 | ### Flash latest Kitlab JEM Micropython to board
|
11 |
| -- Download / unzip latest Kitlab JEM micropython [release](https://github.com/kitlab-io/micropython/releases) |
12 |
| -- Open Atom IDE and open directory **./micropython/api/jem** |
13 |
| -- Turn on JEM board |
14 |
| -- Open Pymakr terminal which will appear at bottom of Atom IDE |
15 |
| -- Set Pymakr to upload all file types (not just python) by clicking on **Pymakr -> Settings -> Global -> Upload all file types** |
16 |
| -- Click 'Connect' to talk to JEM |
17 |
| -- Click 'Upload' to flash latest code to JEM |
18 |
| - |
19 |
| -### Run Demo application |
20 |
| -- JEM Micropython code comes installed with a simple demo app |
21 |
| - + After power up it takes about 10 seconds for JEM to initialize |
22 |
| - + Then you can press the JEM user button and the RGB LED should turn green |
23 |
| -- If you want to play around with the Demo, connect micro usb to JEM and open Pymakr terminal |
24 |
| -- Interact with JEM Demo App using following micropython commands from REPL |
25 |
| -```bash |
26 |
| -# initially a button press thread is running that turns led green if pressed |
27 |
| -# you can stop this by doing |
28 |
| ->> kit._run = False # |
29 |
| -# you can also stop the main demo thread that is collecting imu data to send to app by doing this |
30 |
| ->> kit._main_thread = False |
31 |
| -# now you can mess around |
32 |
| ->> kit.jem.led.set_color(0x880000) # jem red rgb led |
33 |
| ->> kit.jem.led.set_color(0x000088) # jem blue rgb led |
34 |
| ->> kit.jem.imu.orientation # show roll, pitch, yaw degrees |
35 |
| ->> kit.jem.buzzer.start(freq_hz = 100) # make buzzer sound |
36 |
| ->> kit.jem.buzzer.stop() |
37 |
| ->> kit.neopixel.sparkle(count=10) # randomly turns on ten leds, default color is white but you can change |
38 |
| ->> kit.neopixel.sparkle(count=10, c=(127,0,0)) # sparkle red |
39 |
| ->> kit.neopixel.sparkle(count=10, c=(0,0,127)) # sparkle blue |
40 |
| ->> kit.neopixel.rainbow() # do some fancy lantern led show (take about 15 seconds) |
41 |
| ->> kit.jem.btn.read() # read button value |
42 |
| -``` |
| 47 | +- Download / unzip latest [release](https://github.com/kitlab-io/micropython/releases) |
| 48 | +- Open Thonny IDE and open directory **/micropython/jem** |
| 49 | +- Turn on JEM board and Connect to computer |
| 50 | +- Restart connection on Thonny (red Stop button) |
| 51 | +- Now select all files in your computer **micropython/jem** directory and then right click and hit 'Upload to /' |
| 52 | +- This will update your JEM board with latest files |
43 | 53 |
|
44 |
| -### Demo Application using Neopixel + IMU |
45 |
| -```bash |
46 |
| ->> kit.start_sparkle_motion_thread(count=25, rainbow=True) |
47 |
| ->> # now move the jem around a bit (around the roll axis is best) |
48 |
| ->> demo.stop_sparkle_motion_thread() |
49 |
| -``` |
| 54 | +## General JEM ESP32 Micropython Tutorial |
| 55 | +- JEM uses the ESP32 Wrover IE with Micropython baked in |
| 56 | +- There is great documentation [here](https://docs.micropython.org/en/latest/esp32/tutorial/index.html) |
| 57 | + + Shows you how to control JEM GPIO, PWM, I2C, Flash ..etc |
| 58 | +- We recommend this tutorial highly! |
50 | 59 |
|
51 |
| -## Advanced |
52 |
| -Users can control JEM gpio, pwm, adc, dac, uart and read from sensors |
53 | 60 |
|
54 | 61 | ### Simple GPIO test
|
55 | 62 | ```python
|
@@ -96,28 +103,13 @@ btn.read() # should return 0 or 1 depending if pressed
|
96 | 103 | # add rgb led instructions
|
97 | 104 | ```
|
98 | 105 |
|
| 106 | +## Work with JEM ESP32 Bare Metial Firmware |
| 107 | +- If you want to get real fancy you can edit the ESP32 Firmware |
| 108 | +- See [here](https://docs.espressif.com/projects/esp-idf/en/latest/esp32/index.html) |
| 109 | + |
99 | 110 | ## Connect over WiFi
|
100 |
| -- Open Atom IDE and connect to JEM over Pymakr terminal |
101 |
| -- In REPL type |
102 |
| -```bash |
103 |
| ->> from jemwifi import * |
104 |
| ->> wifi = setup_wifi(name="JemWifi") # can use any name you want |
105 |
| -``` |
106 |
| -- Open your Wifi network and look for 'JemWifi' then connect |
107 |
| -- Now go back to Atom IDE and click 'Connect' |
108 |
| - + select '192.168.4.1' |
109 |
| - + If you don't see an IP Address option restart Atom |
110 |
| -- Now you can talk to JEM over Wifi and don't need USB cable |
111 |
| -- To keep this setting after reset, put the following code in main.py |
112 |
| -```python |
113 |
| -from jemwifi import * |
114 |
| -wifi = setup_wifi(name="JemWifi") |
115 |
| -``` |
116 |
| -- Then 'Upload' code to board |
| 111 | +- Coming soon! |
117 | 112 |
|
118 | 113 | ## JEM Board
|
119 |
| - |
| 114 | + |
120 | 115 |
|
121 |
| -## Update JEM Pycom WIPY 3.0 firmware |
122 |
| -- [pycom firmware update](https://docs.pycom.io/updatefirmware/device/) |
123 |
| - + Make sure to use firmware version specified in the JEM Micropython [Releases](https://github.com/kitlab-io/micropython/releases) |
0 commit comments