Parallax-ESP Module Latest Hack
iseries
Posts: 1,492
in Accessories
I took the liberty of updating the Parallax-ESP firmware code to fix some bugs and add some functions.
New functions:
1) Can hide and unhide the WiFi module from the programmer without rebooting module.
2) Can set IP address, Gateway, Mask and DNS server.
3) Can send and receive UDP packets.
Here is a sample program that demonstrates setting IP address and a UDP packet.
This firmware is based on Expressif NONOS_SDK version 2.2.1. This is the same version that is used for their Arduino libraries.
To use the firmware just install this OTA file. If things don’t work out you can always load the original firmware back from Parallax’s website.
Mike
Parallax-ESP108.ota
New functions:
1) Can hide and unhide the WiFi module from the programmer without rebooting module.
2) Can set IP address, Gateway, Mask and DNS server.
3) Can send and receive UDP packets.
Here is a sample program that demonstrates setting IP address and a UDP packet.
#include "wifi.h" #include "simpletools.h" fdserial *fd; int handle; char *reply; char Buffer[1024]; unsigned char NTP[48]; char *Data; char rqs[] = "time.windows.com"; int Port = 123; time_t t; struct tm *x; int i; unsigned long t1; int main() { fd = wifi_start(3, 4, 115200, USB_PGM_TERM); wifi_command("SET:station-ipaddr,101.1.1.42&101.1.1.4&255.255.255.0&101.1.1.1\r"); wifi_join("<your ssid>", "<your password>"); printi("Joined\r"); //build udp connect sprintf(Buffer, "%c%s,%d\r", 0xDE, rqs, Port); reply = wifi_command(Buffer); handle = -1; if (reply[1] == 'S') handle = reply[3] - '0'; printi("handle: %d\r", handle); NTP[0] = 0x1b; wifi_send(handle, NTP, 48); pause(1000); wifi_recv(handle, NTP, 1024); wifi_disconnect(handle); for (i=0;i<48;i++) printi("%02x ", NTP[i]); t1 = NTP[40] << 24 | NTP[41] << 16 | NTP[42] << 8 | NTP[43]; t1 = t1 - (25567 * 24 * 60 * 60); x = localtime(&t1); print("Date: %d/%d/%d\n", x->tm_mon+1, x->tm_mday, x->tm_year+1900); print("Time: %02d:%02d:%02d\n", x->tm_hour, x->tm_min, x->tm_sec); while(1) { pause(1000); } }Since there is no function to do a UDP connection I had to hand code one. Setting the IP address has the following order IP, Gateway, Mask, and DNS.
This firmware is based on Expressif NONOS_SDK version 2.2.1. This is the same version that is used for their Arduino libraries.
To use the firmware just install this OTA file. If things don’t work out you can always load the original firmware back from Parallax’s website.
Mike
Parallax-ESP108.ota
Comments
Mike,
All of these functions are very useful.
Thanks
Shawn
The OTA is not that useful for many that customize the module.
Or you could make a git copy of the original with your changes on your git profile...
(this makes it easier for users to see the changes also)
https://github.com/parallaxinc/Parallax-ESP
I created a pull request which should show all the changes.
Mike
I was hoping to give it a try before it was the master on Parallax-Esp.
The changes cause problems with my compile instructions, I was hoping you would simply put it on your own git, did @"David Betz" know this would happen?
I do not know how to fix it, so if you would like to provide instructions on how to compile the Parallax-Esp master, please, tell me what to do.
For now I will change the instructions I provide to use the old master WORKING copy.
The 'espmissingincludes.h' needs to have a number of function prototypes removed before a clean compile will work.
Here is an updated file that should work.
Mike
Mike
It should return: 'HEAD detached at v2.2.1'
Mike
Wrong link on github so that will need to get fixed.
Mike
Ok.
It compiles ok now.
It works now! (for me)
I did do a 'make clean' before make.
I'm not, you can see what I am doing in my thread, super basic.
https://forums.parallax.com/discussion/comment/1452980/#Comment_1452980
Except for this test, I am not changing my head. I just do the stuff shown here at that point.
When I run into issues like that I start deleting entire directories and re getting it all.
Now I gotta flash it and run it around the block.
Thanks you guyz.
Heres the working script.
Removed old version, new one below.
Do I just use the latest versions?
/Parallax-ESP/ESP8266_NONOS_SDK/bin/boot_v1.7.bin
/Parallax-ESP/ESP8266_NONOS_SDK/bin/blank.bin
/Parallax-ESP/ESP8266_NONOS_SDK/bin/esp_init_data_default_v08.bin
Or does this cause problems? none so far.
And if so, this is the new new flash-all.sh
So far so good.
I see the hide from loader option.
Still good, I have uploaded programs to the prop using SimpleIDE, FlexGUI both in windows.
I uploaded the val-from-micro.html along with its c-code and it works properly.
I have also uploaded my own test code, working fine.
The debug port works good, so does changing the reset line to cts...
AP mode works good, I have yet to test other modes.
STA + AP scans for networks properly, sees them.
...
So looks like using the new version of flash files is A GO!
I used esp-open-sdk.
And I always forget to do:
Because I am too lazy to look up where to put it so it runs at boot.
It compiles on a raspberrypi running raspbian, if you have one. (it just takes many hours to compile)
Mike
/Parallax-Esp/release/Makefile
(which i guess is why my old flash-all.sh was not working.
Also is there a way to make the Makefile get the esptool.py file in the repo and copy it into /Parallax-Esp/release/ ?
Then it can be copied to the /Parallax-Esp/release/release/ folder so the flash-all.sh works.
https://raw.githubusercontent.com/espressif/esptool/master/esptool.py
I am pretty new to all this...
Makefile
Need to be changed for 4M???
Or is that not for RAM...
Oh it is RAM, I just tried to test for versioning, and it talked about ram.
So perhaps that needs to be changed also.
So it uses all the new files, uses 4M for flash size (but is that needed?, since @"David Betz" has previously said that only 2M is required for OTA updates)
That would just make the users be forced to purchase a ParallaxWx module (MWAHAHAHAHAH)
For now I will just keep it 2M
I changed the makefile so it looks for esptool the same way it looked for "../../esp_iot_sdk_v1.5.2" previously.
This means the users would need to run Before running the Parallax-Esp git, in the same directory that the Parallax-Esp is git from.
That seems acceptable due to the sdk needing to be run like that.
Heres the new /Parallax-Esp/release/Makefile
Someone can put this on github, I am not familiar on how to suggest/do it, I don't need credit. Its here.
The readme file should be updated to tell users to GIT esptool.
And the flashing of the module.
Time for a ROOT beer.
If someone could push this new makefile to github along with the fixes that @iseries found in this thread to make the new sdk work, along with any mac issues @"David Betz" can resolve, then I can change my instructions page to be much more simplified, and don't forget the readme needs to tell users to git the esptool also.
I would do it, but I have never done that before.