Using JSON Api via serial

Hi there,
I’ve connected an SAM E7 µc via serial connection to the GPIO 1(TX) and GPIO3(RX) of an Wemos D1 Mini (With WLED #2405180) and tried to send JSON Api trough to control a led stripe attached to the Wemos.
I’ve already analyzed the data coming from the SAM E7 to the Wemos and it looked as I expected, its the same command I’m sending via USB.
Curiously it seems the Wemos doesn’t care about the instruction I send.
If I connect the Wemos via USB to my computer and send the same command with a terminal the instructions gets process and I get a response.

What am I missing? Do I need to enable the PINs in WLED before able to use them? Sadly I couldn’t find anything related to pin configuration in the sources…but I think I’m just blind.

Regards

hi @Elodin the D1 reacts on 3,3V did you use a Levelshifter
the onboard CH340 is not connected to the REAL Serial it gots its own at the ESP8266
there is a USERMOD that cares on the REAL serial

Hi @Magig_Wled thanks for the response.
I assumed since the USB is labeled with the 5V its also whats required to use the D1, so there is no levelshifter, but I can use 3,3V from the E7.
Wemos Pinout

Regarding the REAL serial I guessed it would work “out of the box”

WLED 0.13.0 supports multiple protocols over Serial. Serial is available via USB, and on most boards, GPIO1 for TX and GPIO3 for RX.

Pin usage limitation

If GPIO3 is allocated (e.g. for LED output), all Serial functionality except debug output is unavailable.
If GPIO1 is allocated, all Serial output is disabled, including the JSON API response, Improv, and tpm2 output.

Serial
But your hint with the UserMod is a good one, I will try and fine an appropriate one.

Ok i got you @Elodin did you flash a version lower then the 0,14
and just for confirming you know that SAME7 RX goes to TX on the D1
and the SAME7 TX goes to the RX on the D1
also GND needs to be connected/shared between the 2 uC

Hi @Magig_Wled ,
thanks for the hints, but…

and just for confirming you know that SAME7 RX goes to TX on the D1
and the SAME7 TX goes to the RX on the D1
also GND needs to be connected/shared between the 2 uC
can confirm :sweat_smile:…I also tried to switched them just in case, but it didn’t helped.

did you flash a version lower then the 0,14
I just tried it and loaded Version 0.13.3, but its the same behavior. So I’m back at 0.14.4

I think the problem will be the PIN allocation, since the output signal is fine.

Decoding this is the Json I’m sending as example

curl -d '{“state”:{“on”:true,“bri”:255,“transition”:0},“seg”:[{“id”:0,“fx”:78,“sx”:100,“col”:[[255,255,255],[0,0,255]]}]}

Currently I’m trying to find the USERMOD you mentioned, is this part of the official commited ones?

In Version 0.13.3. I didn’t get versioning of WLED, so i was at first a bit confused.

@Elodin did you try the Example here

Hi @Magig_Wled ,
I’m finaly able to compile WLED, had some issues with my virus scanner…
But looking into the sources of the example
wled-json-api-over-serial
, I´m confused, because this is only for the “Master” so it would be my E7 to send files, isn’t it?

I tried the wled version: “WLED-0.13.0-b6” miwied mentioned, but it doensnt changed anything.

Might there be an issue so WLED is sending the Version (Currently WLED 2406290), because I only get the Version while I also try to send the JSON String.

@Elodin Im sorry im not working over Serial
the master slave is as serial workes
but in both ways as the example showes you snd the 'v ’ to get access to the port it response in returning the Version
then you can send a json command try to send the same command that the API Preset got in the Window frame as on preset set
YOU need to have some presets at least 2 in the Browser
as well you need to have at least 2 segments seg0 most alll available seg1 a fragment
this settings set the internal running build to a usable E131 and DDf state
so i assume then the serial api is also responding via JSON
did you set the E7 to the correct serial format as the example showes it is not the standard Serial of an arduino

@Magig_Wled

but in both ways as the example showes you snd the 'v ’ to get access to the port it response in returning the Version

I didn’t realized I was sending the request for the version with “-d”, so I thought it was kind of debug message that could gave me a hint.

After sending only the payload of the JSON
{"state":{"on":true,"bri":255,"transition":0},"seg":[{"id":0,"fx":78,"sx":100,"col":[[180,180,0],[0,150,255]]}]}
I received that the Baud was changed, that message didn’t appear before.

I set for example the Baudrate with the App to 115200, then disconnect from the app again and send the JSON Command with the same Baud of 115200. Then the ESP is sending me
Baud is now 460800
If I then change the E7 Baud to 460800 I received from ESP that it has changed it to 500000 and then it repeats to change it.
Imgur

Do you maybe know why its changing the whole time?