![]() |
Forum Index : Microcontroller and PC projects : 4 $ WiFi Serial Transceiver Module
![]() ![]() ![]() ![]() |
|||||
Author | Message | ||||
paceman Guru ![]() Joined: 07/10/2011 Location: AustraliaPosts: 1329 |
Wow, this is a bit surprising. I just added OPTION autorun ON at the top of the current code and then pulled the power plug on it. Turned the power back on and after a second or two in came the data again - so looks like its pretty quick. My module and the MicroMite are both on the same supply, but even if the module took a while to connect properly you could always put a PAUSE loop after the AUTORUN. You do get Geoff's MicroMite intro data ahead of it of course but that can be programmed around. Actually I thought Geoff said something about how to stop that but can't remember about it. Also, there's another AT command in the new V0.92 firmware that implements a watchdog of its own that could be useful. The Change Log is pretty cryptic, it just says: • Supports watchdog auto restart when program errors occur. AT command is: Turn on watchdog: AT+CSYSWDTENABLE Turn off watchdog: AT+CSYSWDTDISABLE Greg |
||||
viscomjim Guru ![]() Joined: 08/01/2014 Location: United StatesPosts: 925 |
I am amazed that it gets on the wife network so quickly. I'm going to have to try that one. |
||||
cwilt Senior Member ![]() Joined: 20/03/2012 Location: United StatesPosts: 147 |
I had started working on a wifi based remote sensor and control system a long time ago using WiFly's and mites with OTA updates but put it away because of the cost of each node. This could be an inexpensive alternative. |
||||
viscomjim Guru ![]() Joined: 08/01/2014 Location: United StatesPosts: 925 |
I meant WIFI, Not wife |
||||
BobD![]() Guru ![]() Joined: 07/12/2011 Location: AustraliaPosts: 935 |
Jim I'm glad you clarified that. When I saw your previous post I was a bit concerned. Those WIFE networks can be a real problem. They are fast, cunning, and the individual nodes go for the wallet (aka pocket book). |
||||
viscomjim Guru ![]() Joined: 08/01/2014 Location: United StatesPosts: 925 |
Ha Ha. But you are correct.... |
||||
jman![]() Guru ![]() Joined: 12/06/2011 Location: New ZealandPosts: 711 |
Hi I have been playing with this a little and it looks like there is a small error in the line below PRINT #1,"GET /api/2b4e1c4572808d14/geolookup/conditions/forcast/q/Austral ia/Melbourne.json HTTP/1.1"+CHR$(13)+CHR$(10)+"Host: "+SERVER$+CHR$(13)+CHR$(10) The word forcast should be forecast When I make this change I get lot of garbage for the first few returned lines. If I use a browser and notepad to look at the output there is no garbage the spelling change also removes the error below "error": { "type": "unknownfeature" If you get no weather data for your given city look at the output and get the zmw:xxxxx.x.XXXXX from the output for your city ie for Christchurch New Zealand it looks like this /forecast/q/zmw:00000.1.WNZCH.json Can somebody else try the spelling change and post the results ? Regards Jman |
||||
jman![]() Guru ![]() Joined: 12/06/2011 Location: New ZealandPosts: 711 |
Hi I have managed to get clean data by changing the baud rate and increasing the buffer size Open "Com1:230400,10240" As #1 'ESP module must be set to same rate You will need to set the ESP82666's baud rate to 230400 this is done with [code] AT+CIOBAUD=230400 [/code] I have attached a clean output now all we need some way of parsing the file to extract the data we want 2014-10-19_075226_weather.zip Regards Jman |
||||
viscomjim Guru ![]() Joined: 08/01/2014 Location: United StatesPosts: 925 |
Hi Jman, I am going to try and decipher how the json parsing library works for the arduino to see if I can "convert" it to work with MMbasic. Wish me luck.... |
||||
MicroBlocks![]() Guru ![]() Joined: 12/05/2012 Location: ThailandPosts: 2209 |
JSON is very hard to parse in non object oriented languages. The Arduino uses C++ so it is relatively easy to do. In C or Basic it is practically impossible as both languages do not have the required datatypes to store the parsed information. Theoretically it can be done with huge amounts of effort, and comparably lots of processing time and memory use. A library, as the name suggests, should be able to parse any kind of json, that means you have to somehow simulate dynamic properties. Using recursion would make parsing easier but again not really Basic strong point. Also memory is limited. The only way it can be used easily is with Javascript as JSON is a direct respresentation of an object (JavaScript Object Notation) Then finally Basic does not have a way to access the information by using the property names. This has to be simulated as well. You can not create variables on the fly, i mean variable names with values, so you will need lookup tables that point to entries in arrays. An array element should be able to hold an array (another thing not possible in basic). I would say: Forget about it! :) Treat the JSON for your project as a big string and just walk through it and extract the values you need. That is well within Basic's capabilities and does not need too much resources. Once you have done that it would be relatively easy to adapt it for other specific JSON results. Microblocks. Build with logic. |
||||
WhiteWizzard Guru ![]() Joined: 05/04/2013 Location: United KingdomPosts: 2944 |
but that is the issue - you are limited to 255 characters ![]() Let the challenge continue . . . |
||||
MicroBlocks![]() Guru ![]() Joined: 12/05/2012 Location: ThailandPosts: 2209 |
Maybe i should say read the characters one by one from the comport. You can increase the buffer size so for many short JSON results it would be possible to retrieve it without loss of characters. Microblocks. Build with logic. |
||||
viscomjim Guru ![]() Joined: 08/01/2014 Location: United StatesPosts: 925 |
Hi TZA, thanks for that info before I went totally bald. I guess I will now go back to the method I previously tried. Due to the string size limitation, I am trying to use the method that Geoff uses in reading the com port into an array like the GPS clock example. I think this may work for this situation and then we can look for the info that is desired. Again I thank you, and my barber does too, you have kept him employed for a little longer. |
||||
jman![]() Guru ![]() Joined: 12/06/2011 Location: New ZealandPosts: 711 |
@ viscomjim Have you tried it with xml instead of json the output look a bit nicer just change the .json to .xml in the GET line Regards Jman |
||||
viscomjim Guru ![]() Joined: 08/01/2014 Location: United StatesPosts: 925 |
Trying it now... stay tuned |
||||
MicroBlocks![]() Guru ![]() Joined: 12/05/2012 Location: ThailandPosts: 2209 |
Remember to increase the buffer size of the comport. Otherwise you have the risk of loosing or corrupting data because when the buffer is full it starts overwriting from the start. Ideally the whole response should fit in the buffer. I did not see a maximum buffer size mentioned in the manual, so you have to experiment with that. Microblocks. Build with logic. |
||||
plasma Guru ![]() Joined: 08/04/2012 Location: GermanyPosts: 437 |
why not send the buffer to a server with a php json parser and get the parsing back ? i mean we have wifi on and php will solve this with easy. i know a mmbasic solution is fine but the stringlength is to short even if you use an array. i trying to read some http headers but here you have /n so its not hard to decrypt. |
||||
plasma Guru ![]() Joined: 08/04/2012 Location: GermanyPosts: 437 |
here is the pinout for the version esp8266-05 . beware you cant update this version because lack of gpio ![]() |
||||
jman![]() Guru ![]() Joined: 12/06/2011 Location: New ZealandPosts: 711 |
Hi Plasma Could you post the code you used to query the NTP server Thanks Jman |
||||
plasma Guru ![]() Joined: 08/04/2012 Location: GermanyPosts: 437 |
@jman i am using my own server which sends the time and date with echo in my big clock project, because its easy to use. internet latency , decrypt the ntp bytes and the delays which you need to handle the Esp module give not the "real" time . also the server handles the summer /wintertime here in germany so i not needing calculate this also. |
||||
![]() ![]() ![]() ![]() |
![]() |
![]() |
The Back Shed's forum code is written, and hosted, in Australia. | © JAQ Software 2025 |