Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 5 of 5

Thread: Values get cut short from esp8266 Huzzah to Teensy 3.6

Hybrid View

  1. #1
    Junior Member
    Join Date
    Feb 2019
    Location
    Netherlands
    Posts
    11

    Values get cut short from esp8266 Huzzah to Teensy 3.6

    Hi

    I'm working on a project that needs to send values from my esp8266 HUZZAH to my Teensy 3.6.
    I got the communication working between the two but there is a slight problem.
    The values get "cut".

    I send 200 and 50

    But the result on the monitor of the Teensy is:

    205205205205205205

    How can I fix this issue?



    This is the code on the Teensy:

    void setup() {

    Serial1.begin(115200);

    }

    void loop() {

    // Send bytes from Teensy to computer
    if ( Serial1.available() ) {
    Serial.write( Serial1.read() );
    analogWrite (13, Serial1.read() );
    }

    }

    This is the code on the Esp8266 HUZZAH

    void setup() {

    // Setup computer to Arduino serial
    Serial.begin(115200);

    // Setup Arduino to ESP8266 serial
    // Use baud rate 115200 during firmware update
    Serial1.begin(115200);

    }

    void loop() {

    Serial.write ("200");

    delay (1000);

    Serial.write ("50");

    delay (1000);

    }


    Thank you for reading! Please comment if you have any idea that could help
    Last edited by Ko de Beer; 02-08-2020 at 09:18 PM.

  2. #2
    Junior Member
    Join Date
    Feb 2019
    Location
    Netherlands
    Posts
    11
    Update:

    When I remove

    analogWrite (14, Serial1.read() );

    From the code it sends over the complete value like this:

    502005020050200

    So that is a slight improvement.
    But I would like to control a led with the value. So I Tried to store the value like this:

    void loop() {
    char val = 0;
    // Send bytes from ESP8266 to computer
    if ( Serial1.available() ) {
    val = Serial1.read();
    Serial.write( Serial1.read() );
    analogWrite (13, val);
    }

    Which results to this on the serial monitor:

    0⸮00⸮00⸮00

    What am I overlooking?

  3. #3
    Senior Member+ defragster's Avatar
    Join Date
    Feb 2015
    Posts
    11,534
    The value read is into a char - so it will print as a char ? Should that be uint8_t val=0; ?

    Also is this intended to read Serial1 twice ? Alternate readings with Print one then analog write the other:
    Code:
    val = Serial1.read();
    Serial.write( Serial1.read() );
    analogWrite (13, val);
    Or should it be:
    Code:
    val = Serial1.read();
    Serial.write( val );
    analogWrite (13, val);

  4. #4
    Junior Member
    Join Date
    Feb 2019
    Location
    Netherlands
    Posts
    11
    Thank you that did the trick! It is now sending over the values in the correct way.
    But the led is not turning on.
    Any clue why that is not happening?

  5. #5
    Senior Member
    Join Date
    Nov 2017
    Location
    Belgium
    Posts
    215
    Quote Originally Posted by Ko de Beer View Post
    Thank you that did the trick! It is now sending over the values in the correct way.
    But the led is not turning on.
    Any clue why that is not happening?
    teensy code:
    In setup() you need to add the pinMode command to configure pin 13 as an output or the led will not work.
    In loop() change Serial.write to Serial.println(to send an ASCII representation of the binary value).

    esp8266 code:
    Remove the double quotation marks used in the Serial.write commands(to send a binary value instead of an ASCII representation).

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •