Home
JAQForum Ver 20.06
Log In or Join  
Active Topics
Local Time 09:34 29 Apr 2024 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : wifi for the cmm2! esp8266 library now available

Author Message
datawiz

Newbie

Joined: 10/08/2020
Location: United States
Posts: 26
Posted: 11:29pm 21 Aug 2020
Copy link to clipboard 
Print this post

Hello everyone!
I got my cmm2 last month from circuitgizmos and have been lurking around, reading and tinkering on my CMM2, and generally having a blast.

I've connected my CMM2 via COM2 to an ESP-01S unit, which is based on the Espressif esp8266, and written a library and a set of utilities which I hope will be useful for the community.

esp8266lib-v1.0.00.zip

In the zip file, I've included the the .inc files, documentation, and several programs and utilities I've written.
However, the most interesting may be the files "server.bas" and "sendfile.py". server.bas runs on the cmm2 and waits for a tcp connection from a client running the sendfile.py program. It will receive a file from the client, and optionally attempt to run the program once the transfer is complete.

sendfile.py is a python script that runs on my PC and accepts 2 command line arguments-- a flag to tell the server to RUN after transfer, and the name of the file to send. I have sendfile.py set up as a macro in Notepad++ so I can edit an MM-Basic program, save it, and hit the macro key combo to run sendfile.py and Notepad++ passes the name of the file I'm editing to the script.
I have 2 macros set in Notepad++: one macro sets the flag to Run after transfer ON, and a second macro sets it OFF. This allows me to send programs I want to run/test, and other files that don't need to run (data files, for instance).

As soon as the transfer is complete, the server.bas file checks to see if the RUNFLAG was set and if so, it will run the program immediately. In the program that I just sent to the CMM2, instead of ending the program with an END statement, I can use: RUN "SERVER.BAS" and once the program has finished running, it will start up the server again to wait for the next program to be sent.
This makes for an efficient programming workflow where I write code in Notepad++ on my PC, hit a key combo to send it to the CMM2, and it is run and tested.  

Feel free to reach out if you have questions or run into any problems!
Rich/dw


In regards to the hardware I'm using and how it is wired up--
I had some ESP-01 units (non-S) but had problems getting them working on the CMM2, even though they worked on my PC via a USB adapter. I may go back and revisit those units, but since the ESP-01S units worked without any issues, I moved forward with those.
ESP-01S on Amazon

I used these breakout boards to make them breadboard friendly:
ESP-01S breakout board on Amazon

The ESP-01S won't power from the GPIO pins, so I used these usb voltage regulators to give it the 3.3v it needs. I used the on-board USB port and an external power supply and both worked fine.
USB adjustable voltage regulator on Amazon

Here are some images of how it is wired up:


 
Womble

Senior Member

Joined: 09/07/2020
Location: United Kingdom
Posts: 267
Posted: 12:17am 22 Aug 2020
Copy link to clipboard 
Print this post

Well done Datawiz ... this looks really interesting.

I have some ESP8266 modules, which I have been using with RS232 Maxim ttl serial converters as WiFi modems on retro computers.  Looks like you have found a new use for these devices with the CMM2.

I look forward to testing this  
 
HellbentHorse
Regular Member

Joined: 08/07/2020
Location: Australia
Posts: 55
Posted: 12:27am 22 Aug 2020
Copy link to clipboard 
Print this post

Wow this is great. Nice work. Look forward to tinkering around with it once I get my kit together.
 
Carnifex
Newbie

Joined: 02/07/2020
Location: United States
Posts: 10
Posted: 10:23pm 27 Aug 2020
Copy link to clipboard 
Print this post

I tested out the terminal program, I was able to connect to Level 29 BBS without any issues. I am curious what issue you are having powering the ESP8266 from the GPIO? It seems to work just fine for me, although I have not remained connected for any significant amount of time either, just a couple of minutes at a time. The only difference I see between our wiring is, I have CHPD as well as VCC attached to 3.3V.
 
datawiz

Newbie

Joined: 10/08/2020
Location: United States
Posts: 26
Posted: 11:28pm 27 Aug 2020
Copy link to clipboard 
Print this post

  Carnifex said  I tested out the terminal program, I was able to connect to Level 29 BBS without any issues. I am curious what issue you are having powering the ESP8266 from the GPIO? It seems to work just fine for me, although I have not remained connected for any significant amount of time either, just a couple of minutes at a time. The only difference I see between our wiring is, I have CHPD as well as VCC attached to 3.3V.


I'm glad its working! Try out the flashback.bas for a nostalgic trip back in time... I admit to having too much fun writing that.

Did you configure your esp from a mac/pc or were you able to do it via the setupwifi.bas program?

When I tried to power it up from the GPIO pins, my cmm2 would power on, but wouldn't boot up, and the monitor remained blank. I figured the gpio couldn't provide the power needed for the esp-01s and powered it externally. I admit, i didn't spend any time trying to troubleshoot it. I'll have a look at it again this weekend, as I'd prefer to have it powered that way for simplicity.

Thanks for reporting back. I plan on writing a couple more example programs this weekend, and tweaking some of the minor library calls, so maybe another release next week.

Thanks,
Rich/dw
 
Carnifex
Newbie

Joined: 02/07/2020
Location: United States
Posts: 10
Posted: 01:27am 28 Aug 2020
Copy link to clipboard 
Print this post

  datawiz said  
I'm glad its working! Try out the flashback.bas for a nostalgic trip back in time... I admit to having too much fun writing that.

I did try it, but for whatever reason the ALT-keys were not working for me. I was messing with it over lunch. so I did not have time to look into it, so I just went with terminal. BTW, your terminal program is much better than the one I wrote a couple of weeks ago.

  datawiz said  
Did you configure your esp from a mac/pc or were you able to do it via the setupwifi.bas program?

My esp is one I have had laying around for a few years, it was already configured from an arduino project I put together awhile back. My intent is to try them all this weekend and look over your code and see how your libraries work.

  datawiz said  
When I tried to power it up from the GPIO pins, my cmm2 would power on, but wouldn't boot up, and the monitor remained blank. I figured the gpio couldn't provide the power needed for the esp-01s and powered it externally. I admit, i didn't spend any time trying to troubleshoot it. I'll have a look at it again this weekend, as I'd prefer to have it powered that way for simplicity.

From your code, I assume you are using COM2, I wired mine to COM1. The only other thing I can think of is perhaps I have have an older version esp.



  datawiz said  
Thanks for reporting back. I plan on writing a couple more example programs this weekend, and tweaking some of the minor library calls, so maybe another release next week.

I look forward to it.
 
datawiz

Newbie

Joined: 10/08/2020
Location: United States
Posts: 26
Posted: 02:06am 28 Aug 2020
Copy link to clipboard 
Print this post

  Quote  I did try it, but for whatever reason the ALT-keys were not working for me. I was messing with it over lunch. so I did not have time to look into it, so I just went with terminal. BTW, your terminal program is much better than the one I wrote a couple of weeks ago.

Were you using the USB keyboard, or the usb/console connection? It won't work with the usb/console connection.

If you were using the usb keyboard and the alt keys didn't work, I'd like to investigate that a little further, as I wrote my own input routine using keydown(), and while I got it working on my keyboard, I didn't feel like it was as solid as I felt like it could be. For instance, I don't think I handled key down repeat rate well (there's a definable value for the delay), nor did I handle multiple keys at all. However, i thought the alt/win key handling worked fine. Eventually, I want to take another swing at that.

I was using COM2, but I'll switch over to test on COM1 and follow your wiring. Thanks for sharing it!

Regards,
Rich/dw
 
Carnifex
Newbie

Joined: 02/07/2020
Location: United States
Posts: 10
Posted: 02:40am 28 Aug 2020
Copy link to clipboard 
Print this post

  datawiz said  
Were you using the USB keyboard, or the usb/console connection? It won't work with the usb/console connection.


I am using a USB keyboard, but it might be something dumb. On line 298, keydown(7) was giving me an error, so I changed it to keydown(6) with no thought at all to what it would do to the program. When I run the program with keydown(7), I get this error.

[298] Error: 7 is invalid (valid is 0 to 6)

It may just be my cranky old mechanical keyboard, I have not tried it with a different keyboard. I hope that helps.
 
datawiz

Newbie

Joined: 10/08/2020
Location: United States
Posts: 26
Posted: 02:48am 28 Aug 2020
Copy link to clipboard 
Print this post

  Quote  [298] Error: 7 is invalid (valid is 0 to 6)


I'm thinking this might be a difference in firmware versions. I wrote this on version 5.05.05b8 and I'm currently using version 5.05.05b20. I'm running flashback.bas on it now and it's accepting keydown(7), which is how you detect the modifier keys according to the docs.

Can you verify which firmware you're running on your CMM2?

Thanks,
Rich/dw
 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 5905
Posted: 03:06am 28 Aug 2020
Copy link to clipboard 
Print this post

keydown(7) and keydown(8) were added in Version 5.05.04

I really must dig out my ESP8266 modules and have a play.

Jim
VK7JH
MMedit   MMBasic Help
 
Carnifex
Newbie

Joined: 02/07/2020
Location: United States
Posts: 10
Posted: 08:25am 28 Aug 2020
Copy link to clipboard 
Print this post

  TassyJim said  keydown(7) and keydown(8) were added in Version 5.05.04

I really must dig out my ESP8266 modules and have a play.

Jim


So there is my issue, I am still on 5.05.03, I never bothered to update it after I bought it, I suppose I should get around to that now.
 
thwill

Guru

Joined: 16/09/2019
Location: United Kingdom
Posts: 3845
Posted: 03:41pm 01 Sep 2020
Copy link to clipboard 
Print this post

I've got this working.

I first had to diagnose and fix the fact that my breakout board was missing the ground trace - WTF - must have been running along the edge of the board and got sliced out when the boards were cut up.

But once that was done it was plain sailing.

1. MMBasic 5.0.5.05 release
2. Using COM2
3. CHPD connected to 3.3V - monkey see, monkey do approach from Carnifex's post, I don't actually know what I'm doing
4. Powered by the GPIO
5. Configured using setupwifi.bas - the ESP-01S was new and not configured for my network before

Two issues:

1. Alt-? doesn't seem to work in "flashback.bas" but otherwise very amusing.
2. After power-cycling the CMM2 with the ESP-01S connected I now have to wait a few moments for the ESP-01S to do its "flashy thing" before I can connect to the CMM2 serial console ... but I may just be making that up, needs more investigation.

Haven't tried file transfer with Pi yet.

Thanks,

Tom
Edited 2020-09-02 01:42 by thwill
Game*Mite, CMM2 Welcome Tape, Creaky old text adventures
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 8583
Posted: 04:24pm 01 Sep 2020
Copy link to clipboard 
Print this post

  Quote  4. Powered by the GPIO


I hope you don't mean this. The ESP-01 can take a huge current when it is transmitting and there is a high likelyhood it will kill the I/O pin if not the whole processor.

The ESP8266 power consumption is between 15µA and 400mA depending on different use cases.!!
 
datawiz

Newbie

Joined: 10/08/2020
Location: United States
Posts: 26
Posted: 04:32pm 01 Sep 2020
Copy link to clipboard 
Print this post

  Quote  I've got this working.

Brilliant! I'm happy to hear that.

  Quote  1. Alt-? doesn't seem to work in "flashback.bas" but otherwise very amusing.

Make sure you hit the shift key as well. So, really it's ALT+SHIFT+? hopefully that's the missing piece.  I'm happy you found it amusing, thus the name. If you look at the source, I also included the appropriate ring tones for the UK and other regions of the world. I couldn't figure out a way to derive this from code and enable a specific DTMF set for a matching country. (I thought maybe the keyboard setting, but I didn't spend much time trying to figure out how to read that data)

  Quote  2. After power-cycling the CMM2 with the ESP-01S connected I now have to wait a few moments for the ESP-01S to do its "flashy thing" before I can connect to the CMM2 serial console ... but I may just be making that up, needs more investigation.


Maybe this is due to the initial power draw of the ESP-01S? I don't see this at all when I use external power or even power off of the USB keyboard port.

I'm looking forward to seeing you get the Rpi working with the python script.

Thanks,
Rich/dw
 
thwill

Guru

Joined: 16/09/2019
Location: United Kingdom
Posts: 3845
Posted: 05:26pm 01 Sep 2020
Copy link to clipboard 
Print this post

  matherp said  
  Quote  4. Powered by the GPIO


I hope you don't mean this. The ESP-01 can take a huge current when it is transmitting and there is a high likelyhood it will kill the I/O pin if not the whole processor.

The ESP8266 power consumption is between 15µA and 400mA depending on different use cases.!!


Recall that as well as not being a lawyer I am also not a hardware/electronics guy ... and my attempt to learn something about this was derailed by the arrival of the CMM2 - so if I've broken something it's definitely your fault

I have connected the 3.3V pin of the ESP-01 to pin 1 (3.3V power) and the Ground of the ESP-01 to pin 39 (Ground) of the CMM2 GPIO. Is this inadvisable ?

If it is advisable then what phrase should I have used other than "Powered by the GPIO" ... what does "Powered by the GPIO" imply if not this ?

Since we're discussing this, if I want an independent 3.3V supply then should the output of a bench power supply be stable enough to provide that directly without any interventing electronics (regulators) ? I assume so, otherwise what's the point of a bench power supply.

Thanks,

Tom
Game*Mite, CMM2 Welcome Tape, Creaky old text adventures
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 8583
Posted: 05:38pm 01 Sep 2020
Copy link to clipboard 
Print this post

  Quote  I have connected the 3.3V pin of the ESP-01 to pin 1 (3.3V power) and the Ground of the ESP-01 to pin 39 (Ground) of the CMM2 GPIO. Is this inadvisable ?


You post read that you were using an I/O pin to power the ESP.
Setpin ESPpin,DOUT
pin(ESPpin)=1

Given that is not the case then you should be OK although you are really pushing the voltage regulator 1.7V drop @ 600mA (400+200) = >1W
Also the ESP power jumps all over the place depending on whether it is transmitting so it may be unreliable as there is only limited reservoir capacitance on the CMM2 in order to meet USB specs

A bench supply should be fine. Personally I would use this for the ESP and leave the CMM2 as-is then just connect the negative rails
Edited 2020-09-02 03:40 by matherp
 
datawiz

Newbie

Joined: 10/08/2020
Location: United States
Posts: 26
Posted: 05:49pm 01 Sep 2020
Copy link to clipboard 
Print this post

Tom,
I'm powering using THIS puny USB Power Regulator from Amazon, so your bench power supply will be more than suitable for the job. I power it using a generic external USB charging device plugged into "mains" (thats how you Brits say it, right?) power. :-)

I tie grounds from the CMM2 GPIO pin together to the ESP8266 pin and the power supply ground, if I didn't do this, i was unable to read data from the serial connection.

Rich/dw
 
thwill

Guru

Joined: 16/09/2019
Location: United Kingdom
Posts: 3845
Posted: 09:08pm 01 Sep 2020
Copy link to clipboard 
Print this post

  datawiz said  Tom,
I'm powering using THIS puny USB Power Regulator from Amazon, so your bench power supply will be more than suitable for the job.


I have a similar, but even cheaper piece of Chinese junk that seems to do the trick. Its display within a day of acquiring it ... or I killed it, but it still works. It seems to power the ESP8266 anyway, and is less ridiculous than powering a device the size of a thumbnail with a power supply twice the size of a house brick.

I do notice since switching to an external power supply that the indicator LED on the ESP8266 is very active when I'm not obviously using it, and then largely dormant when I am using "terminal" or "flashback" ... any explanation/ideas?

  Quote  I power it using a generic external USB charging device plugged into "mains" (thats how you Brits say it, right?) power. :-)


Yep, it's the "mains".

  Quote  I tie grounds from the CMM2 GPIO pin together to the ESP8266 pin and the power supply ground, if I didn't do this, i was unable to read data from the serial connection.


Yes ... I was under the impression that all the grounds being common was just standard for everything in electronics ?

Best wishes,

Tom
Game*Mite, CMM2 Welcome Tape, Creaky old text adventures
 
thwill

Guru

Joined: 16/09/2019
Location: United Kingdom
Posts: 3845
Posted: 09:10pm 01 Sep 2020
Copy link to clipboard 
Print this post

  matherp said  You post read that you were using an I/O pin to power the ESP.
Setpin ESPpin,DOUT
pin(ESPpin)=1


I'm not quite that daft ... or to be more precise our antipodean friends have already taught me enough to know those should only be used for signals or *carefully* powering an LED.

Best wishes,

Tom
Game*Mite, CMM2 Welcome Tape, Creaky old text adventures
 
thwill

Guru

Joined: 16/09/2019
Location: United Kingdom
Posts: 3845
Posted: 09:18pm 01 Sep 2020
Copy link to clipboard 
Print this post

  datawiz said  
  Quote  2. After power-cycling the CMM2 with the ESP-01S connected I now have to wait a few moments for the ESP-01S to do its "flashy thing" before I can connect to the CMM2 serial console ... but I may just be making that up, needs more investigation.


Maybe this is due to the initial power draw of the ESP-01S? I don't see this at all when I use external power or even power off of the USB keyboard port.


I'm not sure this is the ESP8266 at all, I've removed it and the delay (only a few seconds) still exists between the CMM2 getting power and the Raspberry Pi being able to make a serial connection to it using Putty - I guess I just didn't notice before because normally I just reset the Waveshare board rather than power cycle the whole CMM2.

Tom
Game*Mite, CMM2 Welcome Tape, Creaky old text adventures
 
Print this page


To reply to this topic, you need to log in.

© JAQ Software 2024