PIC18F25K22 UART ERROR

For general Flowcode discussion that does not belong in the other sections.
Post Reply
chipfryer27
Valued Contributor
Posts: 1177
http://meble-kuchenne.info.pl
Joined: Thu Dec 03, 2020 10:57 am
Has thanked: 287 times
Been thanked: 417 times

Re: PIC18F25K22 UART ERROR

Post by chipfryer27 »

Hi

Attached are two Flowcode charts that will allow 2 x ESP8266 modules to pass data into Excel (or whatever). Please just consider this a framework to illustrate how it could be done and it can easily be tailored to suit. I broke it down into Macro sections in an attempt to make it easier to read. I'm not a programmer, I am a Flowcoder.... :lol:

In this example they both connect to a WiFi router and communicate via the router. It should be a simple matter to have the receive module be an AP too, to allow direct ESP to ESP connection. If I get time later I'll perhaps provide a further example. However based on my experience with ESPs, it may help extend your range between modules by connecting via a WiFi router.

The receive has a LCD display, the ESP8266 component, a Circular Buffer and a UART component. The chip is a PIC18F46K22 simply because it's the only one I had with 2 x UARTS. Using Flowcode it's a simple matter to change the target chip. The chip doesn't need to be particularly powerful but does need two UART ports, one for the ESP Module and the other to connect to your PC (or whatever) and I suppose it could be a software port but I haven't tested.

You will need to enter your own WiFi credentials (SSID, Password) and for the Send module the IP address of the Receive ESP. This can either be obtained from your router or read from the display. You could of course omit the receive LCD entirely but then you would need to get the IP from router logs or force the ESP to have a fixed IP.

In the receiver, UART Ch1 is Port C pins 6 and 7 (tx/rx) and this connects to the ESP module. Use level shifting on ESP Rx if necessary.
UART Ch2 is Port D pins 6 and 7 (tx/rx) and this connects via a TTL-USB Serial Converter to your PC (or whatever).

To test/use either connect the receiver UART output to your PC running "Terminal" or to Excel DataStreamer and have that running.

The receiver will upon booting send out a "Test OK" message on the UART and you should receive that on your PC. It will then, if successfully connected to your WiFi display it's IP address.

Upon receipt of data it will display the data on the bottom line and pass it on to your PC.

Run the Receiver first and all being well it will display (amongst other info) it's IP address. Take note of this.

Not much more to say about it really.

The Send chart only has the ESP component, but of course you can add in whatever sensors you like. I again broke the chart into Macros in an attempt to make it easier to read.

Upon booting, all being well the ESP will connect to your Wifi, then open a connection to your Receive module. (if monitoring the Rx with "Terminal" it should display "connect"). It will then Loop transmitting your data every x-seconds.

I have used Dummy Data in CSV format (12.34,56.78) but what is important is how this is obtained and processed for transmission.

Whatever data you want to send needs to be in String format (e.g. "Test" or "123.456" or suchlike). To send this we first obtain it's length and tell the ESP we are about to send a string of length "x" before sending our data.

The chart loops around this get data / send data every x-seconds and in the example it is five seconds. In testing I've had it sending every 250mS but I haven't really explored this aspect.

Hopefully this will be of help, and I'll look at having the receive ESP be an AP too, eliminating the need for a WiFi router.

Regards
ESP-ESP_Receive.fcfx
(28.52 KiB) Downloaded 37 times
ESP-ESP_Send.fcfx
(20.15 KiB) Downloaded 36 times

SILVESTROS
Posts: 90
Joined: Tue Dec 13, 2022 9:04 pm
Has thanked: 24 times
Been thanked: 1 time

Re: PIC18F25K22 UART ERROR

Post by SILVESTROS »

Hi,
before of anything else, I would like to thank you very much for your help, for time that you spend, for your patience in that not easy for non programmers project..my specialty is hardware , and I have only basic knowledge about programming..FC and similar software gives big help to us to gain time...
I'll make some tests, hoping that my ESP haven't damaged ...
It will be very useful to avoid to use pc router, and set 2 ESP as AP/STA..but for now this is a good start ..thanks again.
Regards

chipfryer27
Valued Contributor
Posts: 1177
Joined: Thu Dec 03, 2020 10:57 am
Has thanked: 287 times
Been thanked: 417 times

Re: PIC18F25K22 UART ERROR

Post by chipfryer27 »

Hi

You are welcome.

I've modified the receiver to be an AP point thereby eliminating the need for WiFi, that wasn't very difficult really, just some minor changes.

However I thought the Tx ESP would be easy, just change the SSID it will connect to...........

Using "Terminal" I could connect and send data by issuing AT commands but for whatever reason I can't get FC to create a connection to the far end (it connects to the module OK though). It is frustrating....

Previously I had a version of Send using AT commands and I did get this to work after far more modifications were made than I thought would be needed.

So, yes, we can have them talking directly but I need to look at the send side of things more.

Incidentally, everywhere I read it says the default IP address of a module in AP mode is 192.168.4.0 but mine appears to be 28.0.0.0. Just guessing that perhaps I didn't wipe this module completely before installing latest AT/SDK.

Regards

SILVESTROS
Posts: 90
Joined: Tue Dec 13, 2022 9:04 pm
Has thanked: 24 times
Been thanked: 1 time

Re: PIC18F25K22 UART ERROR

Post by SILVESTROS »

Hi,
I made a short test but I have no data in PC..I'm afraid that I've damaged ESP...I'll bye some new modules..in that case is necessary to load new firmware?
regards

chipfryer27
Valued Contributor
Posts: 1177
Joined: Thu Dec 03, 2020 10:57 am
Has thanked: 287 times
Been thanked: 417 times

Re: PIC18F25K22 UART ERROR

Post by chipfryer27 »

Hi

Do you have any TTL-USB Serial adapters ?

If so use them to connect a PC to your ESP module (level shift if necessary) and run a Terminal program. Default speed for mine is 115200.

You should then be able to issue AT commands.

When you type you should see an echo being returned (remember to include CR LF)

typing AT <enter> should return OK

If that isn't happening either connections or settings aren't correct or perhaps the module is broken.

New modules may not necessarily be at current Firmware levels (or even close). I posted earlier about updating.

Running (send using AT) over ESP AP for the last couple of hours hasn't shown any issue, however I still need to look at my FC version.

Regards

chipfryer27
Valued Contributor
Posts: 1177
Joined: Thu Dec 03, 2020 10:57 am
Has thanked: 287 times
Been thanked: 417 times

Re: PIC18F25K22 UART ERROR

Post by chipfryer27 »

Hi

Attached are another two charts. This time we create our own AP using the ESP8266 and connect directly to it, thereby eliminating the need for any existing WiFi infrastructure.

Again, you will need to preset a few variables such as the SSID & Password the Rx ESP will create and use, you will also need to enter these in the Tx chart too, as well as the AP server IP Address. You will need to either read this off of the Rx display (if used) or connect with a phone / laptop and obtain from there.

These are just basic frameworks to show how it could be done and leaves plenty of room for improvement. For instance clients can remember the last AP they joined and automatically connect, so you could test for this and if already connected move on. Similarly if WiFi connection is lost it will automatically reconnect, but the server connection will be lost. You could test for such before each transmission and if lost reconnect etc. The AP server IP address could be sent out on the UART eliminating the need for an LCD etc.

I'm keen to hear what range you manage to obtain using these modules.

ESP-ESP_AP_Rx.fcfx
(30.33 KiB) Downloaded 37 times
ESP-ESP_AP_Tx.fcfx
(20.17 KiB) Downloaded 36 times
Regards

SILVESTROS
Posts: 90
Joined: Tue Dec 13, 2022 9:04 pm
Has thanked: 24 times
Been thanked: 1 time

Re: PIC18F25K22 UART ERROR

Post by SILVESTROS »

Hi,
3 of 4 used ESP are damaged...I get some new and I was tried to install firmware with Flash Download Tool (v 2.3)
..when I press START to check ESP , I get "chip sync error", so I have no info about ESP...I check settings and hardware , but nothing found..
about firmware update, four files are needed :
1. esp_init_data_default.bin
2. blank.bin
3. boot.bin
4. user1.bin
that must be transferred with addresses to Download Path Config ...is that correct?
I'll try to load ESP codes to some new modules without update firmware, to see if it works..
regards

chipfryer27
Valued Contributor
Posts: 1177
Joined: Thu Dec 03, 2020 10:57 am
Has thanked: 287 times
Been thanked: 417 times

Re: PIC18F25K22 UART ERROR

Post by chipfryer27 »

Hi

The ESP8266 runs on +3.3v and depending on module, the ESP pins may not be 5v tolerant so level-shifting may be required.

Sounds like you might not have put the ESP into programming mode.

Reset pin and GPIO-0, depending on module, are held high by pull-ups. CH_PD (enable) needs to be high for the chip to do anything. High = +3.3v

Hold Reset Low
Hold GPIO-0 Low
Wait a few seconds
Release reset
Release GPIO-0
Press "Start" on the download tool. That should begin the download.

Once complete cycle power on the ESP.

I used ESP8266_NONOS_SDK-Master and the following files within:-

1 = esp_init_data_default_v08
2 = blank
3 = boot_v1.7
4 = user1.1024.new.2

Regards

EDIT
Forgot to mention in previous post that the password needs to be at least eight characters in length.

chipfryer27
Valued Contributor
Posts: 1177
Joined: Thu Dec 03, 2020 10:57 am
Has thanked: 287 times
Been thanked: 417 times

Re: PIC18F25K22 UART ERROR

Post by chipfryer27 »

Hi

Attached is a SDK update guide
ESP8266-PC Programming Connections.pdf
(75.83 KiB) Downloaded 42 times
Also attached is a connection guide PC-PIC-ESP8266 based on previous Rx charts, which also shows some test positions if required. Guides are basic and do not show full schematics etc.
ESP8266 Connections.pdf
(135.75 KiB) Downloaded 39 times
Regards

SILVESTROS
Posts: 90
Joined: Tue Dec 13, 2022 9:04 pm
Has thanked: 24 times
Been thanked: 1 time

Re: PIC18F25K22 UART ERROR

Post by SILVESTROS »

Hi,
Today I get some new ESP8266 ..I was changed serial/usb module ..I made a test to send data to excel with a test code (TEST2N-A)..data sent ok with PIC16F1939, but not with PIC18F25K22..code runs, but uart1 don't sent data to pc...in simulator data send is ok in both chip..I can't proceed to check ESP , before I'm sure that sending data to pc from PIC18F25K22 is ok...config of chip error ?
Attachments
TEST2N-A.fcfx
(16.8 KiB) Downloaded 36 times

Post Reply