How to see if any data if coming out of tx lines?

I have made a wireless automatic programmer for all esp8266 boards!!! :slight_smile: Everything was going great except I ran out of room on my atTiny85 as soon as I included the SoftwareSerial library.

My prototyping setup is a Wemos d1 mini(esp8266 version), an Hc-05 Bluetooth module, and an Arduino Uno(which acts like the atTiny85)

I was planning on reading the Serial to check if any character/vodoo/ shitty data/ crappy morse code was coming from the tx line of an esp8266. The reason why I say “shitty data” is because I only care if data is coming from the line when the Bluetooth module uploads code to the Wemos board(This way I know that code is being uploaded). The other annoying reason why I need to detect the tx line is that Whenever I open the Serial monitor to connect to the Bluetooth module, the Wemos board thinks its receiving code(But it isn’t, so it crashes >:( ) This is why I need an Attiny85 to tell the Wemos the difference :), otherwise the serial monitor would be useless :frowning:

I only have 1k bytes of memory left. Taking SoftwareSerial out frees over 50% :o

Could someone tell me a simpler approach to detect whether data is streaming in the tx lines of the Wemos(esp8266) board? My current (inefficient) code is this But of course, I won’t show you all the code.

if(check){
    if(count<300){
      if (mySerial.available()) {
        count=-1;
        check=false;
        Serial.println("esp8266 is receiving code");
        resetted=false;
      }
      count++;
      delay(5);
    }
    else{
      digitalWrite(GPIOPin, HIGH);
      delay(100);
      digitalWrite(resetPin, LOW);
      delay(100);   //500
      digitalWrite(resetPin, HIGH);
      Serial.println("Serial Monitor opened");
      resetted=true;
      count=0;
      check=false;
    }
  }

I’m basically checking if the Serial is available(or spitting crap) over a period of 1.5 seconds.

Yeah, yeah, I hear ya…Why Am I using delay, when I should be avoiding it

Unfortunately I can’t use Millis() cause that would take up more memory. :frowning:

Note: My code works perfectly. The goal is to shrink my code, to make it more efficient. Taking SoftwareSerial out frees over 50% :o

I need an alternative to softwareSerial or a better way to determine if the code is being uploaded to the Wemos.

Try using the F() macro in your print statements to keep your prompts and labels in flash instead of the default copying to RAM.

You can't use millis() why? For 100ms delays you could use two unsigned 8 bit time variables, you don't have to use unsigned longs, I don't when debouncing buttons. Instead you have check and count with delay() to make a clunky/blocky wait for serial data.

Smarter move is to have serial input have its own section of code that -runs every time that loop() does and passes the data to the rest of the sketch in a variable that is zero if no new char and the ASCII value of any char received.

Since you want to play snippets-r-us I can't tell so I have to ask, do you actually read the serial data that arrives?

If all you want to do is watch a line then a logic probe may be the easy way to do that.

I used the Serial.println() instead of F() because I was testing it on Arduino to see if the Wemos(esp8266) knew if it was about to uploaded or be read by serial monitor. I will comment out these serial prints in the final stage. But I should get used to using sprintf() for debugging :wink:

“snippets-r-us” I <3 you. I’ll use that phrase for my coworkers. XD

And yes, I don’t care what characters are coming in through the serial, I just need a sign to tell the Wemos that “Code is about to approach, get ready to accept it” or “Yo, a Bluetooth device wants to connect to you to control some LEDs”

So basically I am uploading a blink sketch to the Wemos, and the Arduino monitors whats going on and aids the Wemos. So I’m pretty much creating a bootloader for the stubborn esp8266.

I don’t know if I have enough pins for a logic probe. There’s only 5 IO pins on the atTiny85(the Arduino Uno is taking place of the atTiny85 for testing) And already, 3 IO pins are taken (If you include the softwareSerial that would be 4 IO pins, since I don’t use the TX line)

1) you don't know what the F() macro is/does. That was your look it up moment, a habit to develop is looking things up when there's any doubt at all. Every reference check reinforces your knowledge, not checking when you're wrong only leaves you with misleading notions to unknowingly wander around lost while feeling confident, the Dunning-Kreuger Syndrome in action.

Serial.println( "this text is stored in RAM" );

Serial.println( F( "this text is not stored in RAM" ));

A logic probe is an external device. You clip it to power and ground and then touch the probe to a test point (TX in your case) and see if the RG led flashes to tell of activity at the test point. It could be off, red, green or amber (if AC, you will NOT see amber in your case). You might need one that has its own power for the led.

I don't think putting a logic probe is going to be power efficient. And I'm going to make this as a Kickstarter, so it's going to get expensive if I include it :confused: . Perhaps, I should ask, What makes the SoftwareSerial Library "tick"?

Maybe there is one line of code in the softwareSerial.cpp file that reads the tx line for any data. If I can get a simple function that reads a tx line and forget about what type of characters the Bluetooth module is sending I think I'll get my answer. Unfortunately, it's a little hard to understand whats going on in the file. Is there a way to phone in Nick gammon here? I assume he knows what's going on in the Software Serial library, cause he created it.

The logic probe is entirely to satisfy curiosity as to the state of the pin. It's a dev tool, not part of the product. Ya wanna know, that will tell ya.

SoftwareSerial uses an interrupt.

ATtiny85 has a less than UART serial port.

WHY bother with SS when all you want to do is watch a pin or two? Are there lines on your road that aren't on mine?

I've tried the millis() and updated every 1 ms, the issue is that I get consistent values of "627" and then I get 0 or 32, etc all of a sudden. How do I fix the irregular patterns?

That's funny, the code you presented only prints text messages without numbers.

http://snippets-r-us.com/

There are much smaller software serial libraries out there, including send-only libraries to help you debugging, specifically designed to not waste so much space in an ATtiny.

Getting rid of all digitalWrite and digitalRead calls and replacing them by direct register writes can also free up some 200-400 bytes of memory.

nathan_ramanathan: I have made a wireless automatic programmer for all esp8266 boards!!!! :) Everything was going great except I ran out of room on my atTiny85 as soon as I included the SoftwareSerial library.

So, don't use an ATtiny85, use an Atmega 328. Or, if physical space is at a premium use an ATtiny1634 which is nearly as capable as an Atmega328.

...R