mirror of
https://github.com/sascha-hemi/pycom-documentation.git
synced 2026-03-21 10:05:56 +01:00
updated getting started pages
This commit is contained in:
@@ -16,36 +16,20 @@ In this section, we will explain how to create widgets for data visualisation an
|
||||
|
||||
```python
|
||||
# Import what is necessary to create a thread
|
||||
import _thread
|
||||
from time import sleep
|
||||
import time
|
||||
import math
|
||||
|
||||
# Increment index used to scan each point from vector sensors_data
|
||||
def inc(index, vector):
|
||||
if index < len(vector)-1:
|
||||
return index+1
|
||||
else:
|
||||
return 0
|
||||
# Send data continuously to Pybytes
|
||||
while True:
|
||||
for i in range(0,10):
|
||||
|
||||
# Define your thread's behaviour, here it's a loop sending sensors data every 5 seconds
|
||||
def send_env_data():
|
||||
idx = 0
|
||||
sensors_data = [0, -0.2, -0.5, -0.7, -0.8, -0.9, -0.9, -0.9, -0.8, -0.6, -0.4, -0.2, 0, 0.3, 0.5, 0.7, 0.8, 0.9, 0.9, 0.9, 0.8, 0.6, 0.4, 0.1]
|
||||
|
||||
while True:
|
||||
# send one element from array `sensors_data` as signal 1
|
||||
pybytes.send_signal(1, sensors_data[idx])
|
||||
print('sent {} to Pybytes'.format(sensors_data[idx]))
|
||||
idx = inc(idx, sensors_data)
|
||||
sleep(5)
|
||||
|
||||
# Start your thread
|
||||
_thread.start_new_thread(send_env_data, ())
|
||||
pybytes.send_signal(math.sin(i*math.pi))
|
||||
print('sent signal {}'.format(i))
|
||||
time.sleep(10)
|
||||
```
|
||||
|
||||
2. Press *Upload* button to upload the code into your device.
|
||||
|
||||
3. After the upload is done, the device will reboot and start sending data to Pybytes. In the Pymakr terminal, you should see messages send to Pybytes.
|
||||

|
||||
|
||||
## Step 2: Add a signal from your device
|
||||
|
||||
|
||||
@@ -49,36 +49,10 @@ After creation, you will land on the provisioning page. This is where we 'inform
|
||||
## Step 4: Your first signal
|
||||
|
||||
1. Reset your Pycom device using the reset button. This will reboot the device and activate the Pybytes connection automatically. The output will look similar to this. You should see the `Last Connection` status in Pybytes change from `Never` to `Seconds ago`
|
||||
```
|
||||
>>> ets Jun 8 2016 00:22:57
|
||||
|
||||
rst:0x1 (POWERON_RESET),boot:0x13 (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
|
||||
WMAC: {redacted}
|
||||
Firmware: {latest version}
|
||||
Pybytes: {latest version}
|
||||
Initialized watchdog for WiFi and LTE connection with timeout 1260000 ms
|
||||
WiFi connection established
|
||||
Connected to MQTT mqtt.pybytes.pycom.io
|
||||
Pybytes connected successfully (using the built-in pybytes library)
|
||||
Pybytes configuration read from /flash/pybytes_config.json
|
||||
|
||||
```
|
||||
|
||||
> If you get any kind of error message, check the WiFi credentials you entered are correct and that you are in range of this WiFi network
|
||||
|
||||
2. Use the opportunity to define a signal in Pybytes. The signal number can be anywhere from 0-254 (255 is reserved)
|
||||
|
||||

|
||||
|
||||
3. Now, in the REPL, you can type:
|
||||
2. Now, in the REPL, you can type:
|
||||
```python
|
||||
>>> pybytes.send_signal(1, "hello world")
|
||||
```
|
||||
@@ -86,11 +60,13 @@ After creation, you will land on the provisioning page. This is where we 'inform
|
||||
|
||||

|
||||
|
||||
> Next to `pybytes.send_signal(...)`, we can use ...
|
||||
|
||||
|
||||
You can continue to [display data from your device into the Pybytes dashboard](/pybytes/dashboard/)
|
||||
|
||||
## Final remarks
|
||||
If you wish to disable Pybytes, you can use `pycom.pybytes_on_boot(False)` will permanently
|
||||
If you wish to disable Pybytes, you can use `pycom.pybytes_on_boot(False)` will permanently. It is also possible to start Pybytes in a later stage (not on boot) by importing the module:
|
||||
```python
|
||||
from _pybytes import Pybytes
|
||||
pybytes = Pybytes
|
||||
```
|
||||
|
||||
|
||||
Continue to [display data from your device into the Pybytes dashboard](/pybytes/dashboard/)
|
||||
|
||||
Reference in New Issue
Block a user