Skip to content

Commit

Permalink
new file: README.md
Browse files Browse the repository at this point in the history
	new file:   src/_C001_DomoHTTP.py
	new file:   src/_C002_DomoMQTT.py
	new file:   src/_C013_ESPEasyP2P.py
	new file:   src/_C014_GenMQTT.py
	new file:   src/_C020_LoraDirect.py
	new file:   src/_N001_Email.py
	new file:   src/_N006_Telegram.py
	new file:   src/_N008_MSTeams.py
	new file:   src/_P001_Switch.py
	new file:   src/_P002_Analog.py
	new file:   src/_P004_Dallas.py
	new file:   src/_P005_DHT.py
	new file:   src/_P010_BH1750.py
	new file:   src/_P014_SI7021.py
	new file:   src/_P023_OLED.py
	new file:   src/_P026_Sysinfo.py
	new file:   src/_P028_BMx280.py
	new file:   src/_P029_DomoOutput.py
	new file:   src/_P033_Dummy.py
	new file:   src/_P038_NeoPixel.py
	new file:   src/_P059_Rotary.py
	new file:   src/_P089_Ping.py
	new file:   src/_P097_ESP32Touch.py
	new file:   src/_P212_Dash.py
	new file:   src/_P259_Slider.py
	new file:   src/_P301_AXP192.py
	new file:   src/_P302_ST7735.py
	new file:   src/_P512_BLEMijia.py
	new file:   src/_P515_BLEMiFlora.py
	new file:   src/_P517_BLELYWSD03.py
	new file:   src/boot.py
	new file:   src/commands.py
	new file:   src/controller.py
	new file:   src/inc/bme280/bme280_float.py
	new file:   src/inc/datacontainer.py
	new file:   src/inc/esp32/axp192/LICENSE
	new file:   src/inc/esp32/axp192/axp192.py
	new file:   src/inc/esp32/lib_axp.py
	new file:   src/inc/esp32/lib_gpiohelper.py
	new file:   src/inc/esp32/lib_part.py
	new file:   src/inc/esp32/lib_plat.py
	new file:   src/inc/esp32/unet.py
	new file:   src/inc/fake/fakemachine.py
	new file:   src/inc/fake/faketime.py
	new file:   src/inc/fake/lib_gpiohelper.py
	new file:   src/inc/fake/lib_plat.py
	new file:   src/inc/fake/unet.py
	new file:   src/inc/helper_domoticz.py
	new file:   src/inc/initdata.py
	new file:   src/inc/lib_blehelper.py
	new file:   src/inc/lib_blescan.py
	new file:   src/inc/lib_gpiohelper.py
	new file:   src/inc/lib_miflora.py
	new file:   src/inc/lib_p2pbuffer.py
	new file:   src/inc/lib_plat.py
	new file:   src/inc/libhw.py
	new file:   src/inc/lora/LICENSE
	new file:   src/inc/lora/sx127x.py
	new file:   src/inc/machine.py
	new file:   src/inc/misc.py
	new file:   src/inc/mrtc.py
	new file:   src/inc/rp2/lib_gpiohelper.py
	new file:   src/inc/rp2/lib_plat.py
	new file:   src/inc/rp2/unet.py
	new file:   src/inc/ssd1306.py
	new file:   src/inc/st7735.py
	new file:   src/inc/suntime/LICENSE
	new file:   src/inc/suntime/Suntime.py
	new file:   src/inc/tinydns/LICENSE
	new file:   src/inc/tinydns/dns.py
	new file:   src/inc/uMail/LICENSE
	new file:   src/inc/uMail/README.md
	new file:   src/inc/uMail/umail.py
	new file:   src/inc/uRTC/LICENSE
	new file:   src/inc/uRTC/urtc.py
	new file:   src/inc/ubtle.py
	new file:   src/inc/umqtt/LICENSE
	new file:   src/inc/umqtt/simple.py
	new file:   src/inc/unet.py
	new file:   src/inc/uping.py
	new file:   src/inc/upyTime.py
	new file:   src/inc/upyrtttl/LICENSE
	new file:   src/inc/upyrtttl/rtttl.py
	new file:   src/inc/utime.py
	new file:   src/inc/writer/LICENSE
	new file:   src/inc/writer/WRITER.md
	new file:   src/inc/writer/courier20.py
	new file:   src/inc/writer/font14.py
	new file:   src/inc/writer/font17.py
	new file:   src/inc/writer/ufont10.py
	new file:   src/inc/writer/ufont12.py
	new file:   src/inc/writer/ufont16.py
	new file:   src/inc/writer/ufont21.py
	new file:   src/inc/writer/ufont31.py
	new file:   src/inc/writer/ufont8.py
	new file:   src/inc/writer/ufont9.py
	new file:   src/inc/writer/writer.py
	new file:   src/mpyeasy.py
	new file:   src/nplugin.py
	new file:   src/pglobals.py
	new file:   src/plugin.py
	new file:   src/settings.py
	new file:   src/urequests.py
	new file:   src/web.py
	new file:   src/webserver.py
	new file:   src/webserver_adv.py
	new file:   src/webserver_blescan.py
	new file:   src/webserver_command.py
	new file:   src/webserver_config.py
	new file:   src/webserver_contr.py
	new file:   src/webserver_csv.py
	new file:   src/webserver_dash.py
	new file:   src/webserver_dev.py
	new file:   src/webserver_devlist.py
	new file:   src/webserver_global.py
	new file:   src/webserver_hw.py
	new file:   src/webserver_i2cscan.py
	new file:   src/webserver_json.py
	new file:   src/webserver_log.py
	new file:   src/webserver_notif.py
	new file:   src/webserver_ota.py
	new file:   src/webserver_root.py
	new file:   src/webserver_rules.py
	new file:   src/webserver_sysinfo.py
	new file:   src/webserver_sysvars.py
	new file:   src/webserver_tools.py
	new file:   src/webserver_wifiscan.py
  • Loading branch information
enesbcs committed Jul 30, 2022
1 parent 9855025 commit b21a330
Show file tree
Hide file tree
Showing 128 changed files with 22,758 additions and 0 deletions.
67 changes: 67 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
[![Release downloads](https://img.shields.io/github/downloads/enesbcs/mpyeasy-async/total.svg)]() [![Code size](https://img.shields.io/github/languages/code-size/enesbcs/mpyeasy-async)]() [![Last commit](https://img.shields.io/github/last-commit/enesbcs/mpyeasy-async)]()

# To support the development you can:
- Be a patron at [Patreon](https://www.patreon.com/enesbcs)
- Buy a [coffee](https://ko-fi.com/I3I5UT4H)
- Donate by [PayPal](https://www.paypal.me/rpieasy)
- Adding Python code by [Pull Request](https://github.com/enesbcs/mpyeasy-async/pulls)

# mPyEasy-Async

microPythonEasy IoT firmware for [W5100S-EVB-Pico](https://www.wiznet.io/product-item/w5100s-evb-pico/), [Pico-W](https://www.raspberrypi.com/documentation/microcontrollers/raspberry-pi-pico.html#raspberry-pi-pico-w), ESP32-WROOM and ESP32-WROVER (with SPIRAM)

Based on MicroPython this project tries to mimic the magnificent [ESPEasy](https://www.letscontrolit.com/wiki/index.php/ESPEasy) project functions. Python code is heavily based on RPIEasy, partially rewritten from mPyEasy dropping threading and implementing AsyncIO with a very basic Web framework with minimal memory footprint.
Main goal is to create a multisensor device, that can be install and setup quickly.

:warning:THIS IS A BETA TEST VERSION!:warning:

Expect major changes in later versions that may cause incompatibility with earlier versions!

# ESP32 Installation

1/ Recommended method to write the firmware binary to the flash directly. It will run on either WROOM or WROVER variants.

Download image from: https://github.com/enesbcs/mpyeasy-async/releases/

- Erase flash at first time on ESP32:

`esptool.py --port /dev/ttyUSB0 erase_flash`
- Write firmware:

`esptool.py --port /dev/ttyUSB0 write_flash -z 0x1000 firmware.bin`

Or you can simply use [Thonny](https://thonny.org/) to install firmware!

2/ MicroPython source code from the src directory can be copied to the flash onto a WROVER module with 4MB PSRAM!
Without PSRAM it may run out of memory, i warned you!

https://github.com/enesbcs/mpyeasy-async/tree/main/src

# RP2 (Pico) Installation

- Download image from: https://github.com/enesbcs/mpyeasy-async/releases/
- Press the Bootsel button on Pico when connecting to USB, it will open a new Drive.
- Copy the .uf2 image to this drive (suitable for your device)

# Setup (WiFi modells)

- Connect to mpyEasy WIFI AP with configesp password.
- Setup your own wifi data at http://192.168.4.1/config
- Search it on your own network and configure at the obtained dhcp IP with a web browser.

# Setup (LAN modells)

- Connect to a router with LAN cable, it will request a DHCP address
- Search it on your own network and configure at the obtained dhcp IP with a web browser.

# Update

OTA is not supported yet on ESP32, and never will be on RP2

# Compiling

To create firmware image from python sources, follow instructions for compiling standard MicroPython and add mPyEasy source to micropython/ports/esp32/modules subdirectory before "make" command.

https://github.com/micropython/micropython/tree/master/ports/esp32

https://blog.horan.hk/micropythonesp32.html
83 changes: 83 additions & 0 deletions src/_C001_DomoHTTP.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
import controller
import pglobals
from inc.helper_domoticz import *
import inc.misc as misc
try:
import ubinascii as binascii
except ImportError:
import binascii
try:
import urequests
fake = False
except:
import urllib.request as urequests
fake = True

class Controller(controller.ControllerProto):
CONTROLLER_ID = 1
CONTROLLER_NAME = "Domoticz HTTP"

def __init__(self,controllerindex):
controller.ControllerProto.__init__(self,controllerindex)
self.usesID = True
self.usesAccount = True
self.usesPassword = True

def senddata(self,idx,taskobj,changedvalue=-1):
if self.enabled:
if int(idx) != 0:
if int(taskobj.vtype)==pglobals.SENSOR_TYPE_SWITCH:
url = "/json.htm?type=command&param=switchlight&idx="
url += str(idx)
url += "&switchcmd="
if round(float(taskobj.uservar[0])) == 0:
url += "Off"
else:
url += "On"
elif int(taskobj.vtype)==pglobals.SENSOR_TYPE_DIMMER:
url = "/json.htm?type=command&param=switchlight&idx="
url += str(idx)
url += "&switchcmd="
if float(taskobj.uservar[0]) == 0:
url += "Off"
else:
url += "Set%20Level&level="
url += str(taskobj.uservar[0])
else:
url = "/json.htm?type=command&param=udevice&idx="
url += str(idx)
url += "&nvalue=0&svalue="
url += formatDomoticzSensorType(taskobj.vtype,taskobj.uservar)
url += "&rssi="
url += mapRSSItoDomoticz(taskobj.rssi)
if taskobj.battery != -1 and taskobj.battery != 255: # battery input 0..100%, 255 means not supported
url += "&battery="
url += str(int(taskobj.battery))
else:
bval = misc.get_battery_value()
url += "&battery="
url += str(int(bval))
urlstr = self.controllerip+":"+self.controllerport+url+self.getaccountstr()
misc.addLog(pglobals.LOG_LEVEL_DEBUG,urlstr) # sendviahttp
self.urlget(urlstr)
else:
misc.addLog(pglobals.LOG_LEVEL_ERROR,"MQTT : IDX cannot be zero!")

def urlget(self,url):
global fake
url = "http://"+str(url)
try:
if fake:
content = urequests.urlopen(url,None,1)
else:
content = urequests.get(url)
except Exception as e:
misc.addLog(pglobals.LOG_LEVEL_ERROR,"Controller: "+self.controllerip+" connection failed "+str(e))

def getaccountstr(self):
retstr = ""
if self.controlleruser!="" or self.controllerpassword!="":
acc = binascii.b2a_base64(bytes(self.controlleruser))
pw = binascii.b2a_base64(bytes(self.controllerpassword))
retstr = "&username="+ str(acc) +"&password="+ str(pw)
return retstr
Loading

0 comments on commit b21a330

Please sign in to comment.