I have two almost similar codes that I alternating to copy’n’paste in to Arduino IDE and run upload. One passes Blynk.begin and the other never passes it. I can see this with printing debug text to the serial monitor.
The codes are very, very similar. Everything that has with Blynk startup is similar, but I have some other part of the code that has added functionality, for example this below, but I guess the passing Blynk.begin has nothing to do with that?
Both codes can connect to my wifi router and blynk cloud reports them online.
void WiFisystemstart() {
digitalWrite(WiFi_enable, HIGH); //Turn off power to WiFi
delay(1000);
digitalWrite(WiFi_enable, LOW); //Turn on power to WiFi
delay(500);
Blynk.begin(BLYNK_AUTH_TOKEN, wifi, "ssid", "password");
Blynk.connect();
}
@Magnus Please edit your post, using the pencil icon at the bottom, and add triple backticks at the beginning and end of your code so that it displays correctly.
Triple backticks look like this:
```
Copy and paste these if you can’t find the correct symbol on your keyboard.
It would help if you posted your full code, correctly formatted of course.
It would also help if you explained exactly what hardware you are using, and what exactly the WiFi_Enable pin is all about.
Posting your serial monitor output, assuming your sketch includes #define BLYNK_PRINT Serial would also be useful. Your serial output also needs to have triple backticks at the beginning and end.
You would never normally use Blynk.begin() and Blynk.connect() in the same sketch. Why are you doing this?
I use ESP-01 with arduino mega 2560.
The wifi_enable controls esp-01 supply voltage on/off.
There is 900 rows of code, but I can try so remove what is not related to the startup, and post a shorter version. However, that part is the same for both codes.
Good to know that both blynk.begin and blynk.connect is not needed, however for one of the codes it never gets to the blynk.connect, as it stucks at blynk.begin.
The problem with using a non-IoT board and an ESP-01 to act as an AT modem is that it does t allow you to access the full WiFi functionality. So, you can’t do things like WiFi signal strength (RSSI) via the normal native commands, and you can’t do active WiFi provisioning, or OTA updates.
Sure, it still sort of works, but you’re missing lots of bells and whistles that come with an ESP8266 or ESP32 based board. Those boards are also much more compact than the Mega/ESP-01 combo.
The hardware work flawlessly. Not the software. I do not see a need to upgrade the hardware. The mega2560 also has a shield on top on it for my I/O’s and circuitry.
One difference between these two programs are that one has only the first line below (the program that works", and the other has both lines (and does not work).
The use of WidgetTerminal is a Legacy way of addressing a widget object, and although (as far as I know) it’s still supported in Blynk IoT it’s not the preferred way of writing data to a widget attached to a virtual datastream. You’re actually mixing the old and new ways writing data to a terminal widget in your sketch.
The new IoT way of doing it is like this…
But, without seeing more of your code it’s difficult to properly understand what the potential cause of this problem is.
Your suggestion to stop using widgetterminal and replace it with blynk.virtualwrite helps.
Do I need to make a terminal flush, and if so how?
Also, how do I do a carriage return/line feed? Right now each blynk.virtual.write just continues just right to the previous blynk.virtualwrite. Blynk.virtualWrite(V8, “\n”); does not seem to help.
You don’t need to use a flush command with Blynk.virtualWrite()
The "\n" command certainly used to work with terminal to create a new line. Maybe something has changed.
Have you tried "\r" instead?
Sharing info about whether you’re using the terminal widget in the web console, Android app or iOS app, and if you’re using an app which version this is, would help.
This is another example of where you’re providing minimal information an out hardware, code, app versions, library versions etc and expect definitive answers in return.