ESP8266 AT support in MMBasic


Author Message
lew247

Guru

Joined: 23/12/2015
Location: United Kingdom
Posts: 1584
Posted: 12:49pm 18 Jan 2022      

Following on from
  matherp said  I have said repeatedly that I will consider including specific ESP8266 AT support in MMBasic but  someone needs to come up with some proposals for commands/functions required and MMbasic compatible syntax - each time I issue this challenge there is a deafening silence.


Can people please post suggestions here?

I will start:  

WGET (but I've no idea what AT command you would use for this)

georgestheking
Newbie

Joined: 21/12/2021
Location: Belgium
Posts: 16
Posted: 01:27pm 18 Jan 2022      

Hi,

My propossal to open the debate.

Only 4 WIFI MQTT command :

connect(server_IP,id,Timeout .. )
publish(token,value)
subscribe(token)
disconnect()

Best regards

Georges
Belgium

JohnS
Guru

Joined: 18/11/2011
Location: United Kingdom
Posts: 2777
Posted: 01:37pm 18 Jan 2022      

  lew247 said  WGET (but I've no idea what AT command you would use for this)

Is far too high level.

Details of every part of how to get to that are required, I suspect.

John

georgestheking
Newbie

Joined: 21/12/2021
Location: Belgium
Posts: 16
Posted: 08:22pm 18 Jan 2022      

  georgestheking said  Hi,

My propossal to open the debate.

Only 4 WIFI MQTT command :

WIFI(ssid,psw)

connect(server_IP,id,Timeout .. )
publish(token,value)
subscribe(token)
disconnect()

Best regards

Georges
Belgium

MikeO
Senior Member

Joined: 11/09/2011
Location: Australia
Posts: 259
Posted: 08:22am 19 Jan 2022      

For those wanting to use wifi to send data by MQTT, UDP or HTTP to web APIs , the  simplest approach may be just to use ESPEasy. I have used such a combination mx170 etc with esp8266 to transmit UDP and HTTP message's with almost 100% relability for several years.
Edited 2022-01-19 18:23 by MikeO

Mixtel90

Guru

Joined: 05/10/2019
Location: United Kingdom
Posts: 2443
Posted: 08:49am 19 Jan 2022      

Wouldn't it make more sense to produce a FAQ on wireless communications for MMBasic along with a set of *documented* library routines? I'm not even sure that integrating this into MMBasic is even possible as there are a few variations. You will always end up in a situation where the built-in commands don't *quite* do what's required. There are probably no situations where several comms standards are wanted.

We need those who are knowledgeable to pool their resources on this. Create a working document, detailing what works and what doesn't - TESTED VERSIONS ONLY. It's no use detailing stuff that's so cutting edge that no-one has used it successfully on a 'mite yet. It doesn't matter if it works on XYZ hardware, make it work on a 'mite *then* document it.

Once that's done you can start to think about multi-platform libraries. It's no use writing only for the CMM2 or only for the PicoMite or only for the Armmite xx unless there are *very specific* reasons.

matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 6225
Posted: 10:17am 19 Jan 2022      

I've done a bit of research and IMHO the whole ESP space is now a complete nightmare. As far as I can see the latest AT firmware which supports MQTT won't run on a ESP-01(S) as it both needs 2MB of flash and uses different pins for the UART connection. Even if it could run then I can't find any way to actually flash it. There seems to be 12 different binaries that need downloading to different addresses.

Every community now runs their own versions of ESP firmware: NodeMCU, Arduino, Espruino, LUA, MicroPython etc and there are so many variants of the ESP32 chips and boards that providing any sensible support in MMBasic is a complete non-starter.

I'm running the, now no longer recommended by Expressif, V1.7.4 which provides reliable AT commands to allow TCP and UDP connections as per my previous example MMBasic programs(but not MQTT support). There is little advantage in including support for this as it is no longer current and is so simple to use from Basic anyway.

If Expressif ever provide an official version of AT IDF firmware for the 1MB ESP-01 then perhaps something could be done but until then any MMBasic ESP support is off the table.
Edited 2022-01-19 20:21 by matherp

flasherror
Senior Member

Joined: 07/01/2019
Location: United States
Posts: 155
Posted: 05:05pm 19 Jan 2022      

Although I haven't flashed ESP8266 in a long time, I agree that programming ESP devices with separate files/memory areas is a pain, and I'm not sure why the change was made from the real easy "flash this file and it works", although I'm sure there is a reason. Never understood why there isn't a config file included with firmware and the flash utility does the work.

I'm not sure about the requirement for 2MB ESP01 modules being a problem, apart from user might have to buy a new module in order to use MQTT firmware. I remember the early ESP01 modules had only 512K flash and was a problem once the AT command firmware got large enough, so looks like history repeats itself.

Also, this might be a mistake but https://docs.espressif.com/projects/esp-at/en/release-v2.2.0.0_esp8266/Compile_and_Develop/How_to_understand_the_differences_of_each_type_of_module.html lists the 8266 1MB as supporting MQTT (CTRL-F "ESP8266_1MB_AT_Bin" and see AT MQTT Command support). Not sure which 8266 version they are referring to.

Also about the different pins issue see https://github.com/jandrassy/WiFiEspAT
"The AT 2 binary for esp8266 build by Espressif requires at least 2 MB flash and uses pins 15 as TX and 13 as RX. To have the AT firmware communicating on usual pins 1 as TX and 3 as RX, you can use at flashing of the firmware AT2_esp8266_factory_param_tx1rx3.bin from extras folder of this library instead of factory_param.bin bundled with the AT firmware."
Edited 2022-01-20 03:22 by flasherror

Mixtel90

Guru

Joined: 05/10/2019
Location: United Kingdom
Posts: 2443
Posted: 05:17pm 19 Jan 2022      

2MB for a box that only converts RXD/TXD to RF?

When I were a lad we got the whole word processor and the document and the spelling checker in 48k or less....

Remember - AT commands were developed by Hayes to make it *easy* to control a modem. What went wrong?

flasherror
Senior Member

Joined: 07/01/2019
Location: United States
Posts: 155
Posted: 05:48pm 19 Jan 2022      

  Mixtel90 said  2MB for a box that only converts RXD/TXD to RF?
When I were a lad we got the whole word processor and the document and the spelling checker in 48k or less....
Remember - AT commands were developed by Hayes to make it *easy* to control a modem. What went wrong?


You sound like one of Monty Python's Four Yorkshiremen  

ESP AT firmware is more than an AT command parser, also has the WiFi firmware bits which are beyond my understanding.

Peter, also check out https://github.com/jandrassy/UnoWiFiDevEdSerial1/wiki/files/ESP8266-1MB-tx1rx3-AT_V2.2.zip which is a 1MB v2.2 firmware. Unknown whether it support MQTT (Found it at https://github.com/jondurrant/RPIPicoRTOSMQTT so I'm guessing it does)
Edited 2022-01-20 03:54 by flasherror

matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 6225
Posted: 06:05pm 19 Jan 2022      

  Quote  Peter, also check out


These are both A.N.Other doing their own builds. Not the basis for including in the firmware. Plus there is still the issue of 12 separate binaries and zero "simple" instructions as to how to flash. This sort of basis is incompatible with MMBasic being accessible to the average user =- sorry

bigfix
Senior Member

Joined: 20/02/2014
Location: Austria
Posts: 111
Posted: 06:39pm 19 Jan 2022      

I did not flash ESP8266 for quite some time
So my currrent knowledge is rather limited

Is there a chance to create a working unit from all the right code pieces ?
Then after verification read the whole flash as a single image and save it ?

Goal is to get a "frozen" stable single image to work with
This could be distributed together with a proven flash toolset to make it easy even for new users

The ultimate goal could be to flash a blank ESP directly from a MMbasic system with a trusted ESP flash image derived from the MMbasic distribution

JohnS
Guru

Joined: 18/11/2011
Location: United Kingdom
Posts: 2777
Posted: 06:57pm 19 Jan 2022      

  bigfix said  Is there a chance to create a working unit from all the right code pieces ?
Then after verification read the whole flash as a single image and save it ?

Should work.

John

Volhout
Guru

Joined: 05/03/2018
Location: Netherlands
Posts: 1409
Posted: 10:26pm 19 Jan 2022      

There was a basic progam to flash a pic16f1455 from the mx170, so it becomes a microbridge. Something similar to flash the esp8266. And the binary could be something that simply works, maybe Peters 1.7.4.

phil99

Guru

Joined: 11/02/2018
Location: Australia
Posts: 540
Posted: 10:38pm 19 Jan 2022      

Another example is MMflash which can be found on TassyJim's site that uses an MM2 or MM+ to flash any PIC32 using Pic32prog.exe and Peters Pic32prog CSub.

Mixtel90

Guru

Joined: 05/10/2019
Location: United Kingdom
Posts: 2443
Posted: 10:56pm 19 Jan 2022      

Of course, that's providing the ESP8266 supports having all its flash written at once. There may be a sound reason why it's segmented - like you can't address it as one block. I dunno... Only guessing.

flasherror
Senior Member

Joined: 07/01/2019
Location: United States
Posts: 155
Posted: 12:24am 20 Jan 2022      

One thing to consider is that there may be config data in flash (RF calibration, MAC address etc) which may be unique to each module.

Other things to think about for programming the 8266 using Picomite or other MMBASIC device:
v2.2 1MB esp-at.bin is nearly 800KB alone in size. This means firmware will have to be on SD card and read in chunks and sent to 8266. Is a Basic program fast enough?
What is the fastest reliable baudrate for Picomite to upload to 8266?
In case CRC has to be done on firmware file to compare with programmed checksum how long will it take for Pico to compute this?

I think maybe figuring out a step-by-step document on programming 8266 using PC might be easier than attempting to program using Picomite.
Edited 2022-01-20 10:25 by flasherror

lizby
Guru

Joined: 17/05/2016
Location: United States
Posts: 2092
Posted: 12:58am 20 Jan 2022      

  flasherror said  I think maybe figuring out a step-by-step document on programming 8266 using PC might be easier than attempting to program using Picomite.


And perhaps posted to fruitoftheshed so it doesn't just scroll off into oblivion, like this thread or this one.

phil99

Guru

Joined: 11/02/2018
Location: Australia
Posts: 540
Posted: 02:26am 20 Jan 2022      

Re programming speed, here is a comparable example.

C:\Temp\Micromite_Firmware50502>pic32prog.exe -d ascii:com6 Micromite_Plus_V5.05.02.hex
Programmer for Microchip PIC32 microcontrollers, Version 2.0.220
   Copyright: (C) 2011-2015 Serge Vakulenko
      (ascii ICSP coded by Robert Rozee)

     Adapter: ...... OK1 OK2 - ascii ICSP v1E
   Processor: MX470F512H
Flash memory: 512 kbytes
 Boot memory: 12 kbytes
        Data: 519988 bytes
       Erase: (90mS) done
  Loading PE: 1 2 3 4 (LDR) 5 6 7a (PE) 7b 8 v0201
Program flash: #################################################### done
Program boot: ######### done
Verify flash: #################################################### done
 Verify boot: ######### done
Program rate: 3849 bytes per second

total TDI/TMS pairs sent = 4703307 pairs
total TDO bits received  = 191736 bits
total ascii codes sent   = 1398843
total ascii codes recv   = 65934
maximum continuous write = 452 chars
O/S serial writes        = 130814
O/S serial reads (data)  = 6000
O/S serial reads (sync)  = 2539
XferFastData count       = 112518
10mS delays (E/X/R)      = 9/0/0
elapsed programming time = 2m 17s

At 2m 17s for a 1439kB HEX file an MX170 with MMBasic or Arduino Nano have no problems programming a PIC32 via serial from a PC.
Edited 2022-01-20 12:33 by phil99

JohnS
Guru

Joined: 18/11/2011
Location: United Kingdom
Posts: 2777
Posted: 08:04am 20 Jan 2022      

Perhaps it's simply to program faster so as to avoid people waiting.

E.g. 2 mins is ages lol

John