Skip to content

Commit 5c5dd1d

Browse files
committed
Update reference.md
1 parent 8eb2543 commit 5c5dd1d

File tree

1 file changed

+27
-21
lines changed

1 file changed

+27
-21
lines changed

content/micropython/01.basics/08.reference/reference.md

Lines changed: 27 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -77,17 +77,17 @@ For example:
7777
- [detachInterrupt()](#detachinterrupt)
7878
- [Communication](#communication)
7979
- [Serial (USB)](#serial-usb)
80-
- [print()](#print)
81-
- [Serial (UART)](#serial-uart)
82-
- [begin()](#begin)
83-
- [available()](#available)
84-
- [read()](#read)
85-
- [write()](#write)
80+
- [Serial.print()](#serialprint)
81+
- [Serial1 (UART)](#serial1-uart)
82+
- [Serial1.begin()](#serial1begin)
83+
- [Serial1.available()](#serial1available)
84+
- [Serial1.read()](#serial1read)
85+
- [Serial1.write()](#serial1write)
8686
- [SPI](#spi)
87-
- [begin()](#begin-1)
88-
- [read()](#read-1)
89-
- [transfer()](#transfer)
90-
- [read() \& write()](#read--write)
87+
- [SPI.begin()](#spibegin)
88+
- [SPI.read()](#spiread)
89+
- [SPI.write()](#spiwrite)
90+
- [SPI.transfer()](#spitransfer)
9191
- [Bit Size](#bit-size)
9292
- [Wire / I2C](#wire--i2c)
9393
- [Wire.begin()](#wirebegin)
@@ -929,7 +929,7 @@ The same API is used for sending and receiving data over UART, using `Serial1`.
929929
In MicroPython, to send data over USB, we can use the `print()` function, which prints the content to the REPL. As MicroPython is implemented a bit differently, the REPL also allows you to write commands inside it. The REPL is therefore in many ways, different from the Serial Monitor we are used to in the Arduino IDE.
930930

931931

932-
### print()
932+
### Serial.print()
933933

934934
`print(content)`
935935

@@ -946,11 +946,13 @@ print(58) # prints a numeric value
946946
print(f"The value is {variable}") # prints a string with a value inserted
947947
```
948948

949-
## Serial (UART)
949+
## Serial1 (UART)
950950

951-
UART communication is initialized using the `UART` object from the `machine` module.
951+
UART communication is initialized using the `UART` object from the `machine` module.
952952

953-
### begin()
953+
***When sending & receiving data on a hardware UART port on an Arduino board, we use the `Serial1` class.***
954+
955+
### Serial1.begin()
954956

955957
`machine.UART(port, baudrate=baud)`
956958

@@ -967,7 +969,7 @@ uart = machine.UART(1, baudrate=57600)
967969

968970
***Baud rate `57600` is used as using the common `115200` and `9600` interfered with the Arduino IDE's Serial Monitor.***
969971

970-
### available()
972+
### Serial1.available()
971973

972974
`uart.any()`
973975

@@ -987,7 +989,7 @@ while True:
987989
```
988990

989991

990-
### read()
992+
### Serial1.read()
991993

992994
`uart.read(1)`
993995

@@ -1017,7 +1019,7 @@ while True:
10171019
time.sleep(0.1)
10181020
```
10191021

1020-
### write()
1022+
### Serial1.write()
10211023

10221024
`uart.write(message)`
10231025

@@ -1043,7 +1045,7 @@ while True:
10431045

10441046
SPI communication is initialized using the `SPI` object from the `machine` module.
10451047

1046-
### begin()
1048+
### SPI.begin()
10471049

10481050
`spi = machine.SPI(port, baudrate, polarity, phase)`
10491051

@@ -1057,7 +1059,9 @@ import machine
10571059
spi = machine.SPI(0, baudrate=1000000, polarity=0, phase=0)
10581060
```
10591061

1060-
### read()
1062+
### SPI.read()
1063+
1064+
***Note that `SPI.read()` is not in the Arduino API, as the `SPI.transfer()` handles both outgoing and incoming data.***
10611065

10621066
`spi.readinto(data_in)`
10631067

@@ -1077,7 +1081,9 @@ spi.readinto(data_in)
10771081
print("Received Data:", data_in)
10781082
```
10791083

1080-
### transfer()
1084+
### SPI.write()
1085+
1086+
***Note that `SPI.write()` is not in the Arduino API, as the `SPI.transfer()` handles both outgoing and incoming data.***
10811087

10821088
`spi.write(data_out)`
10831089

@@ -1095,7 +1101,7 @@ data_out = b'\x01\x02\x03'
10951101
spi.write(data_out)
10961102
```
10971103

1098-
### read() & write()
1104+
### SPI.transfer()
10991105

11001106
`spi.write_readinto(data_out, data_in)`
11011107

0 commit comments

Comments
 (0)