Notifications
Clear all

[Solved] How To Parse Text string into smaller, equal size, strings?

5 Posts
3 Users
2 Likes
825 Views
billd01
(@billd01)
Member
Joined: 4 years ago
Posts: 7
Topic starter  

Hi, I have a project where I use a Wemos D1R2 ESP8266 board to run WiFiScan.ino, it creates this output to serial monitor:

4 networks found
1: GoTigers!_2GEXT_EX6100 (-46)*
2: GoTigers!_2GEXT (-69)*
3: SNS/AhEDASAAALjpN6h6LgA= (-83)
4: Biden2020 (-72)*

I have an MCUFriend 3.2" TFT shield that works well on Arduino Mega . . . I want to display the scan results on the TFT. The excellent I2C tutorial here https://dronebotworkshop.com/i2c-arduino-arduino/ has the Wemos (with some minor modification to the code) communication reliably with the Arduino Mega . . . but . . . any ANSWER_SIZE string greater than about 25 characters results in garbled output on the receive device (I'm using the Mega with the TFT as the MASTER to request data from the WEMOS slave).

It could be timing, logic levels or any number of issues, but I know it works perfect with ANSWER_SIZE limited to 16. So If I could 'simply' break the WiFiScan output into equal 16 -char strings it would work.

I've found dozens of examples of how to split strings by looking for a delimiter character (\n, ".", ":" etc), but can't find anything to simply count to 16 characters, save that as a string, then count another 16, save that etc . . .

Thoughts, help, guidance much appreciated.

thnx

billd


   
Quote
triform
(@triform)
Member
Joined: 5 years ago
Posts: 324
 

Hi @billd01,

I assume you are using the string class.  See the substring method in the string class.

Also, you may want to look at pullup resistors on the I2C bus if you don't already have them, a floating I2C line can cause issues.  If you have long wires connecting the two devices, try to shorten them.  Noise from induction should be lessened (somewhat).


   
billd01 reacted
ReplyQuote
robotBuilder
(@robotbuilder)
Member
Joined: 5 years ago
Posts: 2042
 

   
ReplyQuote
robotBuilder
(@robotbuilder)
Member
Joined: 5 years ago
Posts: 2042
 

   
billd01 reacted
ReplyQuote
billd01
(@billd01)
Member
Joined: 4 years ago
Posts: 7
Topic starter  

@robotbuilder Yes, that's it, works perfectly.

 

Thnx All for the suggestions, since the original post I did some testing and determined that the maximum ANSWERSIZE is 32 characters, I2C comms between the WEMOS slave and MEGA master is rock solid up to 32 characters, and fails at 33 or above.

image

This suggests 5 available data bits in the 8-bit I2C byte structure (perhaps start, stop & parity for the other 3?).

32 characters is ample to display SSID, RSSI info my my project, which saves me having to go down the rabbit hole of parseing strings . . .

Thnx again for the feedback

cul

billd 


   
ReplyQuote