Any suggestions please (WiFi)?
Chris Hall (132) 3554 posts |
I am just completing my ‘smallest portable’ by adding full battery management. One thing still missing is the ability to communicate externally (I need to do WiFi with a current budget of about 20mAh per hour). I thus have a portable RISC OS unit about 4″ × 2″ × 3″ with an OLED display, GPS and battery that will automatically (and tidily) shut down on low battery. I am just adding the ability to display remaining battery life (counting down from 18 hours to zero by measuring battery voltage via an ADC). I have seen a device – the Particle Photon – which can be switched on and off remotely, only consumes any significant power whilst on, uses a serial interface to send and receive data and thus can be programmed to send the data to the cloud on demand, using WiFi. The device is programmed via a web interface and is not (of course) RISC OS. Has anyone got any experience of using a Particle Photon please? My plan is to use a push button (or known proximity to a hot spot from GPS readings) to initiate an attempt to ‘talk to the cloud’ which would (1) disable the GPS module (which uses the serial port); (2) enable the Photon; (3) send a smallish text file to the Photon via the serial port; (4) wait for the Photon to try to upload it and respond with a ‘success’ or ‘fail’ message over the serial port; (5) disable the Photon (to free up the serial port again); (6) re-enable the GPS unit. |
Rick Murray (539) 13841 posts |
I got myself one of these: https://amzn.to/2Hw9Q6m Dirt cheap and is supposed to do WiFi with a simple serial link and modem like AT commands. For the more adventurous it’s programmable in some manner. Haven’t played with it yet. Soon… |
Chris Hall (132) 3554 posts |
Many thanks for the reply. I also saw an adafruit module – (a later development of the adafruit version of the link you gave, still based on ESP8266) the problem with all of these items is that you can play interactively with them over a serial connection using serial terminal software. I need to programme it to do a task when given some serial data (upload it to the cloud and respond with a ‘success’ or ‘fail’ reply). As soon as they describe the software, they expect you to know something about Linux or Arduino rather than RISC OS. |
Colin Ferris (399) 1814 posts |
By the way – with ref to thunderstorms – Rick – have you thought about using a modem with a mobile stick. If you are far from a mobile tower – you can use USB extender cable (to gain height) – and perhaps a directional Aerial – for the Stick itself. |
Tristan M. (2946) 1039 posts |
Hey, Rick! The Esp8266 is a very versatile little module. I have an unknown quantity of variants of them on various boards. However, if you want to get really adventurous, and possibly implement a homebrew ethernet to WiFi bridge or whatever the esp32 is a better bet. There may already be source out there for it. |
Dave Higton (1515) 3526 posts |
I’ve played a bit with an ESP8266-based module. Its firmware implemented an AT command set. The experiments were entirely successful, so I was very pleased and would use it again. The ESP8266 has become very popular, and there’s a significant user community that offers lots of knowledge, experience and help. Having said that mine had AT command firmware, I’m also aware that it can be programmed with custom firmware, which would normally be written in C. If you’re happy writing C, this could give you a good solution, because its interface protocol would be specific to your application. Contrast that with AT commands, where, if I’ve understood your description of your requirements, you would need another micro to translate between protocols. (This is what I did in my experiments, using an LPC1114.) |
Raik (463) 2061 posts |
I also play around with a Pretzelboard/NanoESP/ESP8266 with a bit success… |
Rick Murray (539) 13841 posts |
We have a wonderful Linky smart meter. That ought to say all that needs said about our connectivity. :-)
I’m not sure a twenty metre cable on a big metal pole would be good for either the USB signals or thunderstorm proofing. I’m also noting the sky outside turning a very peculiar colour. It’s 22C and extremely humid/close/heavy so I’d be surprised if I wasn’t shutting down “soon”.
Would it not be possible to insert some sort of “interface” in between? The WiFi module expects AT commands and provides formatted data. It seems like your software wants to send something and get a yea/nay back. Perhaps you could implement a module or something to sit between the two? The AT command set of the ESP widget looks to be fairly simple… connect to the WiFi access point, then connect to a remote server, then send data and notice when received data comes in. Something like this… AT+RST AT+CWMODE=1 AT+CWJAP="MyRouter","password" The first two will reply “OK”. The last one should give a running status, with an “OK” when it is connected. Then: AT+CIPSTART="TCP","www.heyrick.co.uk",80 Should reply “CONNECT” and then “OK”. Then: AT+CIPSEND=X GET /index.html HTTP/1.0 Host: zzz.heyrick.co.uk Where ‘X’ is the length of the data that follows – in this case ‘53’ as you should remember that HTTP line endings are properly CRLF. And, of course “zzz” should be “www” but Textile is rubbish and tries (and fails!) to make it a URL in a pre block… The device will reply with a number of blocks like: +IPD,X:<data> Where X is the length (in bytes) of the data that follows. AT+CIPCLOSE Closes the connection. There’s also a “transparent mode” where you can set it to simply send all data presented to the serial port (no need for the AT+CIPSEND stuff). Like with modems, use “+++” with a guard delay around it to break out of that and return to command mode. This may be wrong – I hope Dave/Tristan will point out stuff I’ve mucked up. I’m taking this purely from reading datasheets and such. At any rate, it shouldn’t be too hard to cobble together a simple BBC BASIC program to say “go fetch this” and have it assemble the right set of commands to get the job done, and paste the replies back together to have the correct info back. It looks like there is no SSL support “out of the box”, but others have added support for this, should it be required.
Why another micro? Surely some code sitting between the client software and the serial port ought to do the job? |
Dave Higton (1515) 3526 posts |
I should read the OP more carefully. Of course, it’s a portable RISC OS unit, so it’s capable of running the code needed. I somehow switched to thinking of a GPS unit or some such, which would not be capable of running BASIC. |
Tristan M. (2946) 1039 posts |
https://github.com/espressif/esp-iot-solution/tree/master/examples/eth2wifi I’m not saying to use this. More just posting it as inspiration. But really, reading the requirements more closely, the Esp8266 may be fine. They can also be programmed with their native SDK, there’s also Lua, and I’m not sure what else. In terms of chipset weaknesses, there’s only a few things. Not a huge number of IO pins. Only 1.5 UARTs, and there’s something a bit funny with either iic or SPI possibly, but I don’t recall. I use IIC a lot with them though and it works fine so no worries there. |
Chris Hall (132) 3554 posts |
With no serial handshaking and no user intervention, I think just powering it on, using the modem commands to send data, waiting a few tens of seconds (or receiving an ‘ok’ or ‘fail’ response within this time) and then powering off the device again looks problematic. If the Arduino software adds overheads in terms of power consumption then I’ll avoid it. What is the opposite of ‘GET’ – is it ‘PUT’? I would use something like:
|