From 0e13444e0b431191ba0bde8cb96d7342dc044ad9 Mon Sep 17 00:00:00 2001 From: AdityaSingh17 Date: Fri, 4 Oct 2019 21:55:56 +0530 Subject: [PATCH] Added Node as Access point (hotspot). --- 04_ACCESS_POINT/accesspoint.py | 14 ++++++++++++++ 04_ACCESS_POINT/readme.md | 12 ++++++++++++ 2 files changed, 26 insertions(+) create mode 100644 04_ACCESS_POINT/accesspoint.py create mode 100644 04_ACCESS_POINT/readme.md diff --git a/04_ACCESS_POINT/accesspoint.py b/04_ACCESS_POINT/accesspoint.py new file mode 100644 index 0000000..9a220b8 --- /dev/null +++ b/04_ACCESS_POINT/accesspoint.py @@ -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() \ No newline at end of file diff --git a/04_ACCESS_POINT/readme.md b/04_ACCESS_POINT/readme.md new file mode 100644 index 0000000..38b66cb --- /dev/null +++ b/04_ACCESS_POINT/readme.md @@ -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 +```