Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions 01_LED_BLINK/led_blink.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Code to blink the LED on NodeMCU (ESP8266).

import machine, time

led = machine.Pin(2, machine.Pin.OUT)

for i in range(20):
led.off()
time.sleep_ms(500)
led.on()
time.sleep_ms(500)
12 changes: 12 additions & 0 deletions 01_LED_BLINK/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# 01_LED_BLINK
To run the program use the following ampy command

## MAC OS
```bash
ampy --port /dev/tty.SLAB_USBtoUART run led_blink.py
```

## Linux
```bash
ampy --port /dev/ttyUSB0 run wifi_connect.py
```
8 changes: 8 additions & 0 deletions 02_Connecting to Wifi/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# 02_Connecting_to_Wifi
This program is to connect to WiFi using NodeMCU
To run the program use the following ampy command


```bash
ampy --port /dev/tty.SLAB_USBtoUART run wifi_connect.py
```
9 changes: 9 additions & 0 deletions 02_Connecting to Wifi/wifi_connect.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import network
sta_if = network.WLAN(network.STA_IF)
if not sta_if.isconnected():
print('Connecting to network...')
sta_if.active(True)
sta_if.connect('<Your ESSID>', '<Password>')
while not sta_if.isconnected():
pass
print('Network config:', sta_if.ifconfig())
12 changes: 12 additions & 0 deletions 02_WiFi_CONNECT/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# 02_WiFi_CONNECT
To run the program use the following ampy command

## MAC OS
```bash
ampy --port /dev/tty.SLAB_USBtoUART run wifi_connect.py
```

## Linux
```bash
ampy --port /dev/ttyUSB0 run wifi_connect.py
```
24 changes: 24 additions & 0 deletions 02_WiFi_CONNECT/wifi_connect.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Code to connect the NodeMCU (ESP8266) to a WiFi network.

import network # The network module is used to configure the WiFi connection.

sta_if = network.WLAN(network.STA_IF) # Station interface.
ap_if = network.WLAN(network.AP_IF) # Access point interface.

# Checking if interfaces are active.
"""
Upon a fresh install the ESP8266 is configured in access point mode, so ap_if interface is active and sta_if interface is inactive.
"""
print(sta_if.active()) # Prints (on Terminal) FALSE.
print(ap_if.active()) # Prints (on Terminal) TRUE.

sta_if.active(True) # Activate the station interface.

sta_if.connect('ESSID', 'PASSWORD') # Replace ESSID with the network name, and PASSWORD with the password for the network.


print(sta_if.isconnected()) # Prints (on Terminal) TRUE if connection is established properly.

print(sta_if.ifconfig()) # Prints (on Terminal) the IP address, netmask, gateway, DNS.

ap_if.active(False) # To disable the access point when not in use.
10 changes: 10 additions & 0 deletions 03_RGB_LED/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# 02_RGB_LED_COLOUR_VARIATIONS
- This program is for controlling RGB LED using NodeMCU
- Run this program after setting up the hardware part. For more information visit :
[Controlling RGB LED using NOdeMCU](https://blog.thepodnet.com/nodemcu-rgb-led-using-micropython/)

After setting up the circuit, run the program by using following ampy command in terminal

```bash
ampy --port /dev/tty.SLAB_USBtoUART run rgb_led.py
```
20 changes: 20 additions & 0 deletions 03_RGB_LED/rgb_led.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import machine
import time

blue = machine.Pin(14, machine.Pin.OUT)
red = machine.Pin(12, machine.Pin.OUT)
green = machine.Pin(13, machine.Pin.OUT)

while True:
green.on()
time.sleep_ms(500)
green.off()
time.sleep_ms(500)
blue.off()
time.sleep_ms(500)
blue.on()
time.sleep_ms(500)
red.on()
time.sleep_ms(500)
red.off()
time.sleep_ms(500)
14 changes: 14 additions & 0 deletions 04_ACCESS_POINT/accesspoint.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Code to make the NodeMCU (ESP8266) an access point, so that other devices can connect to it.

import network

ap = network.WLAN(network.AP_IF) # Access point interface, this will be used to make the Node into a hotspot.

ap.active(True) # Activate the Access Point interface.

ap.config(essid="ESSID", password="PASSWORD") # Replace ESSID with the network name, and PASSWORD with the password for other devices to connect.

print(ap.ifconfig()) # Prints (on Terminal) the IP address, netmask, gateway, DNS.

# The following command returns True if devices are connected to the NodeMCU.
# ap_if.active()
12 changes: 12 additions & 0 deletions 04_ACCESS_POINT/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# 04_ACCESS_POINT
To run the program use the following ampy command

## MAC OS
```bash
ampy --port /dev/tty.SLAB_USBtoUART run accesspoint.py
```

## Linux
```bash
ampy --port /dev/ttyUSB0 run accesspoint.py
```