Arduino mega to esp8266 communication via TX RX

still the same thing unfortunately,

image

Need to get the Passthough running first so put aside the json code for now and try to get the simple passthrough sketches running in both directions

Can you post a photo of your voltage divider that you are using for Mega TX to ESP RX?

sure one second

this is the result I’m getting
image

A bit hard to read, can you post the text from the both monitors

for Mega

18:13:17.965 ->  104 10 9 8 7 6 5 4 3 2 1
18:13:22.953 -> MegaToESP8266 Setup finished.
18:13:22.987 -> Set IDE monitor to Newline or Both NL & CR
18:13:27.136 -> hi
18:13:33.053 -> hello
18:13:39.822 -> hi mega
18:13:46.007 -> hi esp

for esp

18:13:19.689 ->  5 4 3 2 1
18:13:22.207 -> ESP8266toMegaPassThrough Setup finished.
18:13:22.207 -> Set IDE monitor to Newline or Both NL & CR
18:13:33.055 -> hello
18:13:39.814 -> hi mega

ok still no good. do you have the photo the divider?

I only put one resistor of 51ohm

image

try putting in the voltage divider circuit I posted earlier OR a diode like I have in my circuit above

voltage divider in place

image

Ok try the passthough sketches again

it's working now :wink:

mega side

18:13:46.007 -> hi esp
18:26:43.769 ->  10 10 9 8 7 6 5 4 3 2 1
18:26:48.753 -> MegaToESP8266 Setup finished.
18:26:48.753 -> Set IDE monitor to Newline or Both NL & CR
18:27:26.593 -> hi mega
18:27:31.860 -> hi esp
18:27:45.535 -> yayy I got a message from esp
18:27:54.510 -> and I got a message from mega

esp side

18:24:28.084 ->  9 8 7 6 5 4 3 2 1
18:27:21.830 -> ESP8266toMegaPassThrough Setup finished.
18:27:21.830 -> Set IDE monitor to Newline or Both NL & CR
18:27:26.628 -> hi mega
18:27:31.866 -> hi esp
18:27:45.569 -> yayy I got a message from esp
18:27:54.544 -> and I got a message from mega

great, now for json code
Remember to change the RXpin to pin 12

const int RX_pin = 12; // for ESP8266 use 12  D6 on wemos-d1-esp8266
const int TX_pin = 13; // for ESP8266 use 13  D7  on wemos-d1-esp8266
SoftwareSerial toESP(RX_pin, TX_pin);

it’s receiving but there are some errors.

18:32:59.471 ->  10 9 8 7 6 5 4 3 2 1
18:33:04.488 -> Jelka Bisa MPPT Project V, I and P measurements
18:33:04.488 ->  SerialComs -  started
18:33:04.488 -> ESP8266 Setup finished.
18:33:04.727 -> Prompt other side to connect
18:33:04.967 -> Prompt other side to connect
18:33:05.241 -> Prompt other side to connect
18:33:05.480 -> Prompt other side to connect
18:33:05.720 -> Prompt other side to connect
18:33:05.994 -> Prompt other side to connect
18:33:06.231 -> Prompt other side to connect
18:33:06.335 ->  Made Connection.
18:33:06.335 -> Received Data '{"Vin":16.24193,"Iin":0.118887,"Pin":1.930957,"Vout":1.803519,"Iout":1.53959,"Pout":2.776681}78'
18:33:06.335 -> Deserialized to -> PV module : Supply V = 16.242V Supply I = 0.119A P = 1.931W Battery charging : Output V=1.804V Ouput I = 1.540A P = 2.777W
18:33:06.575 -> Lost Connection
18:33:06.816 -> Prompt other side to connect
18:33:07.091 -> Prompt other side to connect
18:33:07.331 -> Prompt other side to connect

how can we fix this?

remove the delay( )s
With all the delays’s commented out, in both sketches, out I get

02:34:25.162 -> Deserialized to -> PV module : Supply V = 1.811V Supply I = -11.770A P = -21.313W Battery charging : Output V=0.318V Ouput I = -22.019A P = -6.995W
02:34:25.264 -> Received Data '{"Vin":2.061584,"Iin":-11.42638,"Pin":-23.55644,"Vout":0.391007,"Iout":-21.48094,"Pout":-8.399194}4A'
02:34:25.264 -> Deserialized to -> PV module : Supply V = 2.062V Supply I = -11.426A P = -23.556W Battery charging : Output V=0.391V Ouput I = -21.481A P = -8.399W
02:34:25.398 -> Received Data '{"Vin":1.225806,"Iin":-12.32464,"Pin":-15.10763,"Vout":0.224829,"Iout":-22.84946,"Pout":-5.13722}7A'

Lost connection and prompt are because the Mega has delays and is not responding
Not a problem really. The data still comes though as fast as you create it on the Mega side, allowing for the delays in the loop()

One ‘fix’ is to comment out

  SafeString::setOutput(Serial); // enable error messages and debugging

in setup, so you don’t see these messages just the deserialization output.
But I suggest you leave it in until you are finished

I’m getting this

18:39:44.685 -> Received Data '{"Vin":13.67889,"Iin":-0.4095,"Pin":-5.601504,"Vout":1.769306,"Iout":1.490715,"Pout":2.63753}77'
18:39:45.681 -> Received Data '{"Vin":13.67889,"Iin":-0.145306,"Pin":-1.98763,"Vout":1.764418,"Iout":1.441839,"Pout":2.544007}75'
18:39:46.675 -> Received Data '{"Vin":13.65103,"Iin":-0.145306,"Pin":-1.983582,"Vout":1.764418,"Iout":1.53959,"Pout":2.716481}7D'
18:39:47.706 -> Received Data '{"Vin":13.67889,"Iin":-0.198145,"Pin":-2.710405,"Vout":1.764418,"Iout":1.441839,"Pout":2.544007}47'
18:39:48.695 -> Received Data '{"Vin":13.67889,"Iin":-0.01321,"Pin":-0.180694,"Vout":1.769306,"Iout":1.53959,"Pout":2.724006}41'
18:39:49.721 -> Received Data '{"Vin":13.67889,"Iin":-0.145306,"Pin":-1.98763,"Vout":1.764418,"Iout":1.441839,"Pout":2.544007}75'
18:39:50.718 -> Received Data '{"Vin":13.70675,"Iin":0.01321,"Pin":0.181062,"Vout":1.769306,"Iout":1.441839,"Pout":2.551054}73'
18:39:51.708 -> Received Data '{"Vin":13.70675,"Iin":-0.092468,"Pin":-1.267432,"Vout":1.769306,"Iout":1.490715,"Pout":2.63753}71'

Thank you so much for your help <3!

I will do the web set up and let you know how it came out.

again Thank you mn!

The web stuff may add delays back in but that is OK, because the SerialComs will just Lose Connection, Prompt and Re-connect and continue.
Look forward to hearing of your completed project, tomorrow.

:wink: well noted

all good, displayed on the web. It is a bit lagging behind but it is working.

Thank you so much!