Place to put your Basic demos and examples

Moderator: Mmiscool

User avatar
By peridot
#39869 Update, Esp8266 - Micromite ended up turning into a complete project

IMG_3454 (Medium) (Small).JPG
.

NTP clock corrections and Weather forecast updates via Openweathermap.org are provided by the Esp8266 to the Micromite mcu. The Micromite mcu takes care of sensor data collection around the home via RF links , data display is a 7" LCD. There is also a very simple web page but that is something that needs a lot more work, html is not my strong point unfortunately but its functional at least! here http://203.147.99.198/input?

The Esp8266 can be accessed via a terminal program to test out commands and receive data, I use a program called Coolterm as it has an excellent Sendstring function via pop up windows which make it very easy to repeat commands.

All the code for both the platforms are on my web site http://codenquilts.com.au but the ESP8266 basic program is also below.

Code: Select allmemclear
serialprintln ""
serialprintln "Esp8266-Mcu Initialising......"
ver$ = "ESP8266-Mcu 1.3"
prompt$ = "getdata:"
serialflush
serialtimeout 2000
timesetup(11,0)
setupemail "mail.smtp2go.com" 2525 "Youremail" "yourpassword"
f1 = 23.3
f2 = 78
f3 = 10
f4 = 1008
f5 = 23.3
f6 = 78
f7 = 12.6
f8 = 18.6
f9 = 120
f10 = 90
f11 = "0"
f12 = "0"
f13 = "0"
f14 = "0"
f15 = "0"
'default town and parameters for OWMap
owmparam = "&units=metric&mode=json&appid=yourAPI"
owmtown = "Melbourne,AU" & owmparam
'WEB Page here
cls
wprint "<head>"
wprint "<meta http-equiv='refresh' content='15;URL=/input?'>"
wprint "</head>"
wprint "uMite SNS  Melb,AU "
wprint htmlvar(f11)
wprint ":"
wprint htmlvar(f12)
wprint "<br>"
wprint "Weather Station"
wprint "<br>"
wprint "<br>"
wprint "Temperature="
wprint htmlvar(f1)
wprint " 'C "
wprint " Humidity="
wprint htmlvar(f2)
wprint " %RH"
wprint "<br>"
wprint " Avg Wind Speed="
wprint htmlvar(f3)
wprint " km/h"
wprint " Pressure="
wprint htmlvar(f4)
wprint " hpa"
wprint "<br>"
wprint "<br>"
wprint "GreenHouse"
wprint "<br>"
wprint "Temperature="
wprint htmlvar(f5)
wprint " 'C "
wprint " Humidity="
wprint htmlvar(f6)
wprint " %RH"
wprint "<br>"
wprint "<br>"
wprint "Garden Solar"
wprint "<br>"
wprint "Battery="
wprint htmlvar(f7)
wprint " VDC "
wprint " PV Panels="
wprint htmlvar(f8)
wprint " VDC"
wprint "<br>"
wprint "Battery Power Used="
wprint htmlvar(f9)
wprint " wHrs "
wprint " PV Power Gen="
wprint htmlvar(f10)
wprint " wHrs "
wprint "<br>"
wprint "<br>"
'button "Exit" [quit]
timer 1000 [update]
wait

[update]
'goto [exitupdate]
input prompt$ str$
'serialprintln "length of Input:"
'serialprintln len(str$)
if len(str$) = 0 then goto [exitupdate]
if instr(str$,"sync:") > 0 then goto [parsedata]
gosub [parse]
cmd = field$
goto [command]
[parsedata]
gosub [parse]
sstatus = field$
gosub [parse]
f1 = field$
gosub [parse]
f2 = field$
gosub [parse]
f3 = field$
gosub [parse]
f4 = field$
gosub [parse]
f5 = field$
gosub [parse]
f6 = field$
gosub [parse]
f7 = field$
gosub [parse]
f8 = field$
gosub [parse]
f9 = field$
gosub [parse]
f10 = field$
gosub [parse]
f11 = field$
gosub [parse]
f12 = field$
goto [exitupdate]
[command]
if cmd == "time" then gosub [gettime]
if cmd == "email" then gosub [sendemail]
if cmd == "info" then gosub [getinfo]
if cmd == "quit" then goto [quit]
if cmd == "reboot" then reboot
if cmd == "net" then gosub [setnet]
if cmd == "ts" then gosub [thingspeak]
if cmd == "owm" then gosub [weather]
if cmd == "town" then gosub [changetown]
[exitupdate]
wait

[thingspeak]
input "gettsdata:" str$
gosub [parse]
sstatus = field$
gosub [parse]
ts.key$ = field$
gosub [parse]
ts.fieldnum$ = field$
gosub [parse]
ts.fielddata$ = field$
sendts(ts.key$,ts.fieldnum$,ts.fielddata$)
return

[setnet]
input "getnetwork:" str$
gosub [parse]
sstatus = field$
gosub [parse]
net.name$ = field$
gosub [parse]
net.password$ = field$
gosub [parse]
net.ip$ = field$
gosub [parse]
net.gateway$ = field$
gosub [parse]
net.mask$ = field$
if net.ip$ == "" then [auto] else [static]
[static]
connect net.name$ net.password$ net.ip$ net.gateway$ net.mask$
goto [exitsetnet]
[auto]
connect net.name$ net.password$
[exitsetnet]
gosub [getinfo]
return

[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 ""
serialprint "Version:"
serialprintln ver$
serialprint "IP:"
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$ = ""
delim = instr(str$,":")
field = delim - 1
rest = len(str$) - delim
field$ = left(str$,field)
str$ = right(str$,rest)
'serialprintln "Parse"
'serialprintln field$
'serialprintln str$
'serialprintln
return

[changetown]
input "gettown:" str$
gosub [parse]
owmtown = field$ & owmparam
return

[weather]
owmbla = "api.openweathermap.org/data/2.5/weather?q=" & owmtown
serialprint wget(owmbla)
return

[quit]
timer 0
wprint "<a href='/'>Menu</a>"
end
You do not have the required permissions to view the files attached to this post.
User avatar
By cwilt
#39872 Nicely done. I have plans to do something similar with just the ESP but JSON support has not been added yet.

I am curious though just how much you spent on the server/display portion? The esp, micromite, and display.
User avatar
By peridot
#39896
cwilt wrote:Nicely done. I have plans to do something similar with just the ESP but JSON support has not been added yet.

I am curious though just how much you spent on the server/display portion? The esp, micromite, and display.


Hi cwilt, I guess the most expensive items were the Micromite and the display, the ESP8266 is the least at only a few dollars.

The Micromite , the are a few versions around but I use the one from CircuitGizmo http://circuitgizmos.com/gizmo-store/#!/CGMICROBOARD2-Micromite-Board/p/53821336 as its reasonably priced and arduino style I find useful.
The LCD was a SSD1963 7"" format but the micromite will inteface to several sizes of this lcd type as well as some SPI displays , so there is plenty of choice and price range. The one I use I think cost around AUD 70.00 from china.

The rest of it is how you want to want to package it , I constructed a specific enclosure out of acrylic.
User avatar
By cwilt
#39908 My question is one of economics. I have thought about building something similar but the cost just doesn't make sense for me. An android tablet can be purchased for less than $40 us and programmed with droidscript.