From b1ce1f2348657a315c0611d8d82c251c8fab0c3d Mon Sep 17 00:00:00 2001 From: Zontex Date: Thu, 15 Jul 2021 14:23:57 +0800 Subject: [PATCH] update to 1.0.8 --- README.md | 54 ++++++++++++++++--- eduponics/__init__.py | 2 +- eduponics/ads1x15.py | 2 +- eduponics/tds.py | 2 +- examples/eduponics_mqtt/boot.py | 35 ++++++++---- extensions/extension_board/mcp23017_relays.py | 2 +- .../extension_board/mcp23017_soil_moisture.py | 2 +- setup.py | 4 +- 8 files changed, 78 insertions(+), 25 deletions(-) diff --git a/README.md b/README.md index e7ea699..e756ba1 100644 --- a/README.md +++ b/README.md @@ -39,22 +39,39 @@ First, connect the ESP32 board to the WiFi by creating boot.py file and writing ```python import network import esp +import time esp.osdebug(None) import gc gc.collect() -ssid = 'WIFI_NAME' -password = 'WIFI_PASSWORD' +# set WiFi credentials +ssid = '' +password = '' -station = network.WLAN(network.STA_IF) +# check if there is username and password for wifi +if(ssid != '' and password != ''): -station.active(True) -station.connect(ssid, password) + station = network.WLAN(network.STA_IF) -while station.isconnected() == False: - pass + station.active(True) + station.connect(ssid, password) -print('Connected to WiFi successfully, IP: %s' % station.ifconfig()[0]) + timeout_interval = 10 + + # try to connect with timeout interval + for i in range(0,timeout_interval): + if(station.isconnected() == False): + time.sleep(1) + pass + else: + break; + + if(station.isconnected()): + print('Connected to WiFi successfully, IP: %s' % station.ifconfig()[0]) + else: + print("Something went wrong, connection timeout, try again!") +else: + print("Please add WiFi credentials properly") ``` Make sure to change WiFi ESSID and Password. Once the ESP32 is connected to the Wifi, run the following commands: @@ -68,6 +85,27 @@ This will install the latest version of micropython-eduponics package through up Examples are available in the examples/ directory. +## Using firmwares + +Alternatively, you can burn a ready made firmware which located under the repository firmwares directory +currently 2 firmware available: + +1. 4M-eduponics-micropython.bin - firmware includes micropython-eduponics library pre-installed (without the MQTT client). +2. 4M-eduponics-MQTT.bin - firmware includes the MQTT library and everything you need to get started with the Eduponics mobile app. + +To flash the firmware, run the following command using esptool.py +``` +esptool.py --baud 115200 --port write_flash 0x0 .bin +``` +Where is the file name (the bin file you want to flash) and is the port name to flash through. + +Current firmware version: MicroPython v1.13 on 2020-09-02; ESP32 module with ESP32 + +## Changing MQTT broker + +In order to change the MQTT broker, change the umqttsimple.py file inside the [/Eduponics/](/Eduponics/umqttsimple.py) directory +Make sure to properly mark whenever you use SSL or not. + ## License MIT License diff --git a/eduponics/__init__.py b/eduponics/__init__.py index 9e604c0..e13bd59 100644 --- a/eduponics/__init__.py +++ b/eduponics/__init__.py @@ -1 +1 @@ -__version__ = "1.0.7" +__version__ = "1.0.8" diff --git a/eduponics/ads1x15.py b/eduponics/ads1x15.py index 625104d..35eb88f 100644 --- a/eduponics/ads1x15.py +++ b/eduponics/ads1x15.py @@ -23,7 +23,7 @@ # THE SOFTWARE. import utime as time -from eduponics import mcp23017 +from Eduponics import mcp23017 _REGISTER_CONVERT = const(0x00) _REGISTER_CONFIG = const(0x01) diff --git a/eduponics/tds.py b/eduponics/tds.py index 93cb165..38b3c81 100644 --- a/eduponics/tds.py +++ b/eduponics/tds.py @@ -24,7 +24,7 @@ ''' import time -from eduponics import ads1x15 +from Eduponics import ads1x15 from ulab import array,numerical from machine import I2C, Pin import time diff --git a/examples/eduponics_mqtt/boot.py b/examples/eduponics_mqtt/boot.py index e1c2e92..c24a2c3 100644 --- a/examples/eduponics_mqtt/boot.py +++ b/examples/eduponics_mqtt/boot.py @@ -21,23 +21,38 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. """ - -from umqttsimple import MQTTClient import network import esp +import time esp.osdebug(None) import gc gc.collect() -ssid = 'WIFI_NAME' -password = 'WIFI_PASSWORD' +# set WiFi credentials +ssid = '' +password = '' + +# check if there is username and password for wifi +if(ssid != '' and password != ''): + + station = network.WLAN(network.STA_IF) -station = network.WLAN(network.STA_IF) + station.active(True) + station.connect(ssid, password) -station.active(True) -station.connect(ssid, password) + timeout_interval = 10 -while station.isconnected() == False: - pass + # try to connect with timeout interval + for i in range(0,timeout_interval): + if(station.isconnected() == False): + time.sleep(1) + pass + else: + break; -print('Connected to WiFi successfully, IP: %s' % station.ifconfig()[0]) + if(station.isconnected()): + print('Connected to WiFi successfully, IP: %s' % station.ifconfig()[0]) + else: + print("Something went wrong, connection timeout, try again!") +else: + print("Please add WiFi credentials properly") diff --git a/extensions/extension_board/mcp23017_relays.py b/extensions/extension_board/mcp23017_relays.py index 7bc46ef..0d38621 100644 --- a/extensions/extension_board/mcp23017_relays.py +++ b/extensions/extension_board/mcp23017_relays.py @@ -38,7 +38,7 @@ i2c = I2C(scl=Pin(33), sda=Pin(32)) # initialize relay object -relays = mcp23017.Relays(i2c, address=0x20) +relays = mcp23017.Relays(i2c, address=0x27) # open relays one by one for i in range(0,4): diff --git a/extensions/extension_board/mcp23017_soil_moisture.py b/extensions/extension_board/mcp23017_soil_moisture.py index 28c1317..54bb719 100644 --- a/extensions/extension_board/mcp23017_soil_moisture.py +++ b/extensions/extension_board/mcp23017_soil_moisture.py @@ -39,7 +39,7 @@ # setup adc for the extension board ads_address = 0x48 -mcp_address = 0x20 +mcp_address = 0x27 gain = 1 adc = ads1x15.ADS1115(i2c=i2c, address=ads_address,mcp_address=mcp_address, gain=gain) diff --git a/setup.py b/setup.py index ef33de4..f471135 100755 --- a/setup.py +++ b/setup.py @@ -5,7 +5,7 @@ from setuptools import setup, find_packages from setuptools.command.test import test as TestCommand -sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__),'eduponics'))) +sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__),'Eduponics'))) from eduponics import __version__ sys.path.pop(0) @@ -20,7 +20,7 @@ packages=find_packages(), include_package_data=True, version=__version__, - download_url = 'https://github.com/STEMinds/micropython-eduponics/archive/1.0.7.tar.gz', + download_url = 'https://github.com/STEMinds/micropython-eduponics/archive/1.0,8.tar.gz', keywords = ["STEMinds",'MicroPython','uPython', 'Eduponics-Mini', 'Eduponics', 'ESP32', 'ADS1x15', 'MCP23017', 'TDS', 'pH', 'bh1750', 'BME280', 'DS1307', 'AT24C02'], description='STEMinds Eduponics Mini MicroPython library', long_description=long_description,