![]() |
Forum Index : Microcontroller and PC projects : ESP8266 - uMite JSON weather data
Author | Message | ||||
MikeO Senior Member ![]() Joined: 11/09/2011 Location: AustraliaPosts: 275 |
JSON weather data from http://openweathermap.org/ uMite routines snippets to parse data received from ESP8266 running ESP Basic. '*** start main program loop
Do 'StartTime = Timer Watchdog 8000 esp$=Input$(1,#2) 'Print esp$; buff$=buff$+esp$ if esp$=chr$(10) or esp$=chr$(62) or esp$=chr$(125) then if esp$=chr$(10) then 'terminator is line feed if instr(buff$,"NTP:") then time$=parse$(buff$,4," ") 'set the clock from NTP endif elseif esp$=chr$(62) then 'terminator is > if instr(buff$,"getdata:>") then 'print "Queue items:";r SendEsp 'send next item in the queue, success is in r endif ' else 'terminator is } 'json parseJson endif sub parseJson 'print "Parse Json from: "; buff$ if instr(buff$,"temp") then print "Temperature: " + jsonValue$(buff$,"temp",6) endif if instr(buff$,"humidity") then print "Humidity:";jsonValue$(buff$,"humidity",10) endif if instr(buff$,"pressure") then print "Pressure:";jsonValue$(buff$,"pressure",10) endif if instr(buff$,"speed") then print "Wind Speed:";jsonValue$(buff$,"speed",7) endif end sub function jsonValue$(json$,jsonParam$,b) local a,c 'print "json$:";json$ 'print "jsonparam$:";jsonparam$ 'print b 'locate parameter a=instr(json$,jsonparam$) 'print "A is:";a if a>0 then 'retrieve value c=instr(a+b,json$,",") if c>0 then jsonvalue$=mid$(json$,a+b,c-(a+b)) endif endif end function ![]() Latest version of ESP8266-uMite firmware 2016-01-03_064337_ESP8266-Mcu_07_post.pdf Mike Codenquilts |
||||
viscomjim Guru ![]() Joined: 08/01/2014 Location: United StatesPosts: 925 |
FREAKIN' AWESOME!!!!!!!!!!!! Thanks MikeO! |
||||
lew247![]() Guru ![]() Joined: 23/12/2015 Location: United KingdomPosts: 1702 |
deleted - figured out my stupid mistake Tried it and it didn't work, I'd used the wrong api* |
||||
viscomjim Guru ![]() Joined: 08/01/2014 Location: United StatesPosts: 925 |
Thanks again for providing. Can't wait to try it all out and display it on a color lcd. |
||||
MikeO Senior Member ![]() Joined: 11/09/2011 Location: AustraliaPosts: 275 |
Hey Jim, Thanks for your interest! Today is Australia Day and I am President of the local community group so have so things to do until later in the day. Later today I will post some updated code, things have moved on somewhat! 7" LCD Weather from OpenWeatherMap.org , local data comprising of weather station, Greenhouse, house temp/hum and garden solar power. Codenquilts |
||||
viscomjim Guru ![]() Joined: 08/01/2014 Location: United StatesPosts: 925 |
Wow Mike, that looks awesome. I want to do something like this also. Bringing the uMite and esp8266 together is something that opens a lot of doors. The power of the uMite and all the great graphic capabilities available are just incredible. I have been pouring over your code and keep finding very cool methods that you implement to make things work. Still a lot to learn, but nice to know that basic is very capable! |
||||
MikeO Senior Member ![]() Joined: 11/09/2011 Location: AustraliaPosts: 275 |
Hi Jim, sorry for the delay, I have now posted all my latest code on my website if you want to take a look here. There is also a direct live link to the ESP8266 web page , I don't think its the most robust interface but its working, showing live data from my sensors. I am please with the UMite Plus part of the project , it works great , thanks to Geoff! It interfaces nicely with the ESP8266 fetching NTP time updates and weather forecast data from Openweathermap.org. See previous post. Enclosure by the way was purpose built to fit the 7" SSD1963 LCD from black acrylic on my CNC mill, then parts glued together. Some sensor input "fixing" , I have noticed some are missing, is next then interfacing the data to IOT primarily to monitor greenhouse sensors. Mike Codenquilts |
||||
akashh Senior Member ![]() Joined: 19/01/2014 Location: IndiaPosts: 115 |
Looks cool! I couldn't help but notice the EC reading, and was wondering how you are getting that, and are you running a hydroponic system? I am in the process of creating a fully automated hydroponic controller using the Wattmon and a micromite with touch tft screen as the Hmi. I was wondering whether anyone built an Hmi that could be interfaced via simple serial commands such as: Button x,y,action React x,y,x2,y2 Etc. etc. If and when I get to it I would be happy to share back the code but perhaps it's been done already. |
||||
viscomjim Guru ![]() Joined: 08/01/2014 Location: United StatesPosts: 925 |
Hi MikeO, I took a look at your code for both the esp and uMite. There is a lot going on there. It is a great example of interfacing different things. Going through your code is kind of making my head spin, but I am chopping it up a piece at a time to see how it works, mostly how you are communicating between the esp and uMite. Awesome code work there, and great looking project also! Allowing others to look at your code is a very kind thing to do. This is how I have learned the most so far, by others here allowing us to peruse their code. It is invaluable to knowledge hungry people like myself. I am curious as to how you are showing the data on your website, the data that updates every 15 seconds. This is a very cool feature also. I guess I need to start wrapping my head around html. As you have clearly shown here, Geoffs uMite, internet access using the esp and a bit of awesome code, the sky is really the limit. Thank you for sharing your project with the rest of us!!!!!! |
||||
atmega8![]() Guru ![]() Joined: 19/11/2013 Location: GermanyPosts: 724 |
Hello, the ESP8266-Mcu 1.3.bas is running on the esp8266?! Is this Lua language in NodeMcu ?? THX |
||||
viscomjim Guru ![]() Joined: 08/01/2014 Location: United StatesPosts: 925 |
Hi atmega8, the esp is running a BASIC port. HERE is the link for the basic port. There is also a link on the top of the page for the forum. |
||||
MikeO Senior Member ![]() Joined: 11/09/2011 Location: AustraliaPosts: 275 |
@ akashh Yes I have dabbled in Hydroponics, I don't currently have a conductivity sensor running. Not sure I understand your serial commands question , is this from the hmi to some device? @ viscomjim, Hi Jim , probably the simplest thing to do is just to program up a ESP module and talk to it direct with a terminal program , works well that way, I use CoolTerm as it has a terrific sendstring function by way of pop up windows that remain available so its easy to repeat commands. You can then view the received data. There are also quite a few serialprint lines in the ESP code that are commented out , if you invoke them again you will get quite a bit more info if you need to look at any of the routines in any more detail. The Web page is simply refreshed every 15 secs by this section in the html code. cls wprint "<head>" wprint "<meta http-equiv='refresh' content='15;URL=/input?'>" wprint "</head>" @ atmega8 No its not Lua, its a version of basic from ESP8266 Basic Codenquilts |
||||
akashh Senior Member ![]() Joined: 19/01/2014 Location: IndiaPosts: 115 |
MikeO, it was actually a more general question that probably deserves a thread of its own. The idea was to use a mite and TFT touch as an Hmi interface to another mcu over serial. The display widgets could then be remotely programmed and feedback such as clicks or value changes could be fed back to the host controller, thus making it possible for the host to focus on other things or even be something like a raspberry PI or atmega and still benefit from Goeff's cool features. |
||||
MikeO Senior Member ![]() Joined: 11/09/2011 Location: AustraliaPosts: 275 |
akashh, Oh I see now, what a good idea, achievable very easily I would imagine. Actually if you had a look at the code in my project you will find a library (of sorts) that receives the data from my remote sensors, it uses RF serial modules for the communications but it doesn't need to be, it is also 2 way. Mike Codenquilts |
||||
paulychen Newbie ![]() Joined: 25/02/2017 Location: AustraliaPosts: 1 |
Hi, Has anyone used Micromite and esp8266 to send email out if the temp. sensor reach certain value? I 'd like to have the code for it. It has to to be written in MMBASIC for Micromite though. I know it has code for arduino for doing just that. Thanks. |
||||
MikeO Senior Member ![]() Joined: 11/09/2011 Location: AustraliaPosts: 275 |
@ paulychen, I have written complementary code for ESP8266 and micromiteII/Plus to communicate and use the internet. There is some information on my website you might like to look at , its not completely up to date but will give you some idea of its capabilities. If you would like more specific information and help please send me a PM. Codenquilts |
||||
![]() |
![]() |
The Back Shed's forum code is written, and hosted, in Australia. | © JAQ Software 2025 |