Place to put your Basic demos and examples

Moderator: Mmiscool

User avatar
By tayfun
#35778 bla = 0
timer 5000 [update.Values]
wprint |<meta http-equiv="refresh" content="10; url=./input" />|
wprint htmlvar(bla)
button "this is a test" [test.1]
wait
[test.1]
wprint "test 1 was clicked"
wait
[update.Values]
input "enter value" bla -----------------------------> when i clear this word runing but , this word not runing?
wait


what you thing abaut ?
User avatar
By peridot
#35785 The attached code interfaces to a uMite plus MCU via a serial port and provides a simple web page , access to NTP and email. A data update is requested periodically by the ESP and each time a command may also be made by the MCU currently for email, Info and NTP. The MCU responds to the ESP data request via the serial port with a data string supplying a data update for the web page and a command. Currently 10 update fields sent but more may be sent , they are parsed by a routine in the ESP. The data strings are constructed as follows, the last field is the command.
Sync: 45:66:10:1008:17:89:12.4:19.2:106:89:ntp:
Sync: 45:66:10:1008:17:89:12.4:19.2:106:89:info:
Sync: 45:66:10:1008:17:89:12.4:19.2:106:89:email:
Sync: "emailaddress":"replyaddress":"test from ESP8266":"test"

Code: Select allmemclear
serialprintln "uMite SNS Initialising......"
ver$ = "ESP8266 uMite SNS WUI 0.5b"
'connect "SSID" "password" "192.168.0.30" "192.168.0.1" "255.255.255.0"
'baudrate 38400
timesetup(11,0)
setupemail "mail.smtp2go.com" 2525 "username" "password"
gosub [getinfo]
let otemp = 23.3
let ohum = 78
let ows = 10
let opres = 1008
let gtemp = 23.3
let ghum = 78
let bv = 12.6
let pvv = 18.6
let bp = 120
let pvp = 90


wprint "<head>"
wprint "<meta http-equiv='refresh' content='15;URL=/input?'>"
wprint "</head>"

print "uMite Serial Network Server"
print
wprint "<br>"
wprint "Weather Station"
wprint "<br>"
wprint "Temperature="
wprint htmlvar(otemp)
wprint " 'C "
wprint " Humidity="
wprint htmlvar(ohum)
wprint " %RH"
wprint "<br>"
wprint " Avg Wind Speed="
wprint htmlvar(ows)
wprint " km/h"
wprint " Pressure="
wprint htmlvar(opres)
wprint " hpa"
wprint "<br>"
wprint "<br>"
wprint "GreenHouse"
wprint "<br>"
wprint "Temperature="
wprint htmlvar(gtemp)
wprint " 'C "
wprint " Humidity="
wprint htmlvar(ghum)
wprint " %RH"
wprint "<br>"
wprint "<br>"

wprint "Garden Solar"
wprint "<br>"
wprint "Battery="
wprint htmlvar(bv)
wprint " VDC "
wprint " PV Panels="
wprint htmlvar(pvv)
wprint " VDC"
wprint "<br>"
wprint "Battery Power Used="
wprint htmlvar(bp)
wprint " wHrs "
wprint " PV Power Gen="
wprint htmlvar(pvp)
wprint " wHrs "
wprint "<br>"
wprint "<br>"


button "Exit" [quit]
timer 5000 [update]
wait

[update]
'str$ = "Sync: 45:66:10:1008:17:89:12.4:19.2:106:89:ntp:"  'testing
input "getdata:" str$
delay 5
gosub [parse]
sstatus = field$
gosub [parse]
otemp = field$
gosub [parse]
ohum = field$
gosub [parse]
ows = field$
gosub [parse]
opres = field$
gosub [parse]
gtemp = field$
gosub [parse]
ghum = field$
gosub [parse]
bv = field$
gosub [parse]
pvv = field$
gosub [parse]
bp = field$
gosub [parse]
pvp = field$
gosub [parse]
cmd = field$
if cmd == "ntp" then gosub [gettime] else [exitupdate]
if cmd == "email" then gosub [sendemail] else [exitupdate]
if cmd == "info" then gosub [getinfo] else [exitupdate]
[exitupdate]
wait

[sendemail]
input "getemail:" str$
gosub [parse]
sstatus = field$
gosub [parse]
address$ = field$
gosub [parse]
reply$ = field$
gosub [parse]
subject$ = field$
gosub [parse]
body$ = field$
email address$ reply$ subject$ body$
return

[getinfo]
serialprintln ""
serialprintln ver$
serialprint "Connected to:"
serialprintln ip()
read "WIFIname" blaWIFIssid
serialprint "SSID:"
serialprintln blaWIFIssid
serialprint "FlashFree:"
serialprintln flashfree()
serialprint "RamFree:"
serialprintln ramfree()
return

[gettime]
ntp$ = time()
ntp$ = "NTP:" & ntp$
serialprintln ntp$
return

[parse]
field$ = ""
'serialprintln "parse this"
'serialprintln str$
[search]
delim = instr(str$,":")
'serialprintln delim
[found]
field = delim - 1
delim = delim + 1
rest = len(str$) - delim
field$ = left(str$,field)
rest$ = right(str$,rest)
str$ = rest$
'serialprintln field$
'serialprintln str$
[exitparse]
return


[quit]
timer 0
wprint "<a href='/'>Menu</a>"
end


Cheers Mike
User avatar
By heckler
#35804 peridot,

That looks pretty awesome. Thanks for sharing! I haven't tried it yet, but I will.
A quick video or a couple of screen shots wold be nice.

A caution when using print or wprint...
(And this is from my own experience so MMISCOOL (or others) may need to correct me here)
You may need to include somewhere in your code a "cls".
CLS:
Will clear the screen and GUI buffer
cls

Other wise your module MAY run out of memory.
Code: Select allprint ramfree()
print flashfree()

During some code testing I had put these two statements in to see how much memory I was using.
And it looked like one of the basic code statements might have a memory leak causing my ramfree to keep going down.
Then I realized it was probably just the fact that the web gui kept getting bigger and bigger as I was printing to the web page repeatedly with out clearing it (cls).

thanks again for sharing
dwight
User avatar
By viscomjim
#35809 Hi Peridot, would you be willing to share the uMite code that you are running with the esp? I would like to give this a try. Thanks for posting this, will open a few doors now!!!!