NodeMCU Projects: Difference between revisions
Content added Content deleted
Line 4: | Line 4: | ||
= Micropython = |
= Micropython = |
||
== Basics == |
|||
*Installing: |
*Installing: |
||
sudo pip install esptool |
sudo pip install esptool |
||
Line 19: | Line 22: | ||
import webrepl |
import webrepl |
||
webrepl.start() |
webrepl.start() |
||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
pin.on() |
|||
pin.off() |
|||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
toggle(pin) |
|||
⚫ | |||
⚫ | |||
<syntaxhighlight lang="python"> |
|||
import machine |
|||
import time |
|||
pin = machine.Pin(2, machine.Pin.OUT) |
|||
def toggle(p): |
|||
p.value(not p.value()) |
|||
while True: |
|||
⚫ | |||
time.sleep_ms(i) |
|||
toggle(pin) |
|||
</syntaxhighlight> |
|||
*Checking filesystem: |
*Checking filesystem: |
||
Line 81: | Line 51: | ||
print(ap.config('essid')); |
print(ap.config('essid')); |
||
== Projects == |
|||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
Revision as of 14:16, 26 November 2017
Micropython
Basics
- Installing:
sudo pip install esptool esptool.py --port /dev/ttyUSB0 erase_flash esptool.py --port /dev/ttyUSB0 --baud 460800 write_flash --flash_size=detect 0 ~/Desktop/esp8266-20171101-v1.9.3.bin
- Connecting via Terminal:
sudo apt install picocom picocom /dev/ttyUSB0 -b115200
- Connecting via REPL(web):
import webrepl_setup
If you disabled automatic start-up on boot, you may run configured daemon on demand using:
import webrepl webrepl.start()
- Checking filesystem:
import os os.listdir()
- Create directories:
os.mkdir('dir')
- Remove entries:
os.remove('data.txt')
- Checking Machine Frequency & Overclocking:
import machine machine.freq() # get the current frequency of the CPU machine.freq(160000000) # set the CPU frequency to 160 MHz
- Check AP Name:
import network; ap = network.WLAN(network.AP_IF); print(ap.config('essid'));
- Change AP name and password:
import network; ap = network.WLAN(network.AP_IF); ap.active(True); ap.config(essid='MyESP8266', authmode=network.AUTH_WPA_WPA2_PSK, password='mypassword'); print(ap.config('essid'));
Projects
- Playing with GPIO:
import machine
import time
pin = machine.Pin(2, machine.Pin.OUT)
def toggle(p):
p.value(not p.value())
while True:
for i in range(100,999):
time.sleep_ms(i)
toggle(pin)
- References
{{#widget:DISQUS
|id=networkm
|uniqid=NodeMCU Projects
|url=https://aman.awiki.org/wiki/NodeMCU_Projects
}}