NodeMCU Blynk local server via 3G mobile router

My serial monitor is set to 115200. When I press Reset unreadable symbols appear.
I tried all baud rates and got something meaningful only at 74880:

01:48:50.754 ->  ets Jan  8 2013,rst cause:2, boot mode:(3,6)
01:48:50.754 -> 
01:48:50.754 -> load 0x4010f000, len 3584, room 16 
01:48:50.754 -> tail 0
01:48:50.754 -> chksum 0xb0
01:48:50.754 -> csum 0xb0
01:48:50.754 -> v2843a5ac
01:48:50.754 -> ~ld
01:48:50.856 -> ⸮

This is from my working wifi server version.
And this is from the 3G version (not connected to 3G):

01:52:45.526 -> 
01:52:45.526 ->  ets Jan  8 2013,rst cause:2, boot mode:(3,7)
01:52:45.526 -> 
01:52:45.526 -> load 0x4010f000, len 3584, room 16 
01:52:45.526 -> tail 0
01:52:45.526 -> chksum 0xb0
01:52:45.526 -> csum 0xb0
01:52:45.526 -> v2843a5ac
01:52:45.526 -> ~ld

Stick to 74880 and use the same baud rate in your sketch.
What do you see then?

Pete.

Nothing going on the serial monitor.

Disconnect everything from your board except the USB cable, open the serial monitor and press the reset button.
What happens?

Pete.

Same timestamp message as above.

Okay, in that case it appears that your sketch is not executing.
I’m guessing that maybe some of the pins (I guess in your stationDefines.h file) are illegal pins (in the GPIO 6-11 range) or you have something pulling GPIO0 LOW, or GPIO2 or 15 HIGH.

Pete.

The 3G sketch is absolutely the same local Blynk server sketch working perfectly on the local WiFi network except for:
1/ In this line:
Blynk.begin(auth, ssid, pass, IPAddress(192,168,1,2), 8080);

IPAddress(192,168,1,2) is replaced with my No-Ip “myhostname” like this:

Blynk.begin(auth, ssid, pass, “XXXX.XXXX.net”, 8080);

2/ Local WiFi credentials and auth token are replaced with 3G modem WiFi credentials and new project auth token.
When logging in Blynk connection type is Custom, IP 192,168,1,2.

And what do you see in the serial monitor when you run the “local server” version sketch on the same device?

If what you’ve posted is accurate, then the issue isn’t actually the Blynk.begin line of code.
Before that, in your void setup, you initialise the serial port then print 3 lines of text to the serial monitor. If these aren’t printing then the code execution isn’t getting as far as the Blynk.begin line of code, so something is preventing the code from executing.

Pete.

The odd thing is in both cases there’s nothing on the serial monitor but one of the sketches executes, connects to the server and starts updating the sensors’data. In the other case nothing is going on.
Good indication whether the code is working is if the OLED lights up which in the 3G code version doesn’t happen although the 3G modem service menu shows ESP01 is connected.
I’m catching several WiFi signals with my tablet. Is it possible that the WiFi signals are interfering and preventing sketch to execute?
According to the local router WiFi analyzer:
Signal(dBm) Signal(%)
1 0 100
2 -32 100
1 is local router
2 is 3G modem

You said you were using a NodeMCU, not an ESP-01

You need to share the contents of your stationDefines.h file.

Pete.

It’s NodeMCU but in the list of connected to the 3G modem devices it’s listed as ESP-01E541.

stationDefines.h:

/* Automatic Control Parameters Definition */
#define DRY_SOIL      66
#define WET_SOIL      85
#define COLD_TEMP     12
#define HOT_TEMP      25
#define TIME_PUMP_ON  15
#define TIME_LAMP_ON  15

/* TIMER */
#define READ_BUTTONS_TM   1L  // definitions in seconds
#define READ_SOIL_TEMP_TM 2L
#define READ_SOIL_HUM_TM  10L
#define READ_AIR_DATA_TM  2L
#define SEND_UP_DATA_TM   10L
#define AUTO_CTRL_TM      60L     

/* OLED */
boolean turnOffOLED = 1;
#define SHOW_SET_UP   30

/* DHT22*/
#define DHTPIN D3  
#define DHTTYPE DHT22 
float airHum = 0;
float airTemp = 0;

/* Soil Moister */
#define soilMoisterPin A0
#define soilMoisterVcc D8
int soilMoister = 0;

/* DS18B20 Temperature Sensor */
#define ONE_WIRE_BUS 14 // DS18B20 on NodeMCU pin D5 corresponds to GPIO 014 on Arduino
float soilTemp;

/* Relays */
#define PUMP_PIN D6              //PUMP (Red LED)
#define LAMP_PIN D7              //LAMP (Green LED)
boolean pumpStatus = 0;
boolean lampStatus = 0;

/* Buttons */
#define PUMP_ON_BUTTON D9        //push-button PUMP (Red) D9 Rx
#define LAMP_ON_BUTTON D10      //push-button LAMP (Green) D10 Tx
#define SENSORS_READ_BUTTON D4   //push-button SENSOR (yellow)

What changes will have to be made in the code if I remove the local WiFi router from the equation thus connectiing directly to the web?
What Custom IP should I input when signing into Blynk? My public IP or the No-Ip one?

Where is this function?

How would this connection direct to the web work, I don’t understand what you are suggesting.

The reason that your serial monitor isn’t working is because you’re using GPIO3 (Serial Rx, pin D9) and GPIO1 (Serial Tx, pin D10) for physical buttons in your sketch.
If you’re using this many pins then you should be thinking about an ESP32.

Pete.

Where is this function?

It’s located in generalFunctions.h:


/***************************************************
* Wait Button to be pressed a defined time in seconds
****************************************************/
void waitButtonPress (int waitTime)
{
  long startTiming = millis();
  while (debounce(SENSORS_READ_BUTTON)) 
  { 
    if ((millis()-startTiming) > (waitTime*1000)) break;
  }
}

/***************************************************
* Starting Timers
****************************************************/
void startTimers(void)
{
  timer.setInterval(READ_BUTTONS_TM*1000, readLocalCmd);
  timer.setInterval(READ_SOIL_TEMP_TM*1000, getSoilTempData);
  timer.setInterval(READ_AIR_DATA_TM*1000, getDhtData);
  timer.setInterval(READ_SOIL_HUM_TM*1000, getSoilMoisterData);
  timer.setInterval(SEND_UP_DATA_TM*1000, sendUptime);
  timer.setInterval(AUTO_CTRL_TM*1000, autoControlPlantation);
  //timer.setInterval(DISPLAY_DATA_TM*1000, displayData);
}

/***************************************************
* Debouncing a key
****************************************************/
boolean debounce(int pin)
{
  boolean state;
  boolean previousState;
  const int debounceDelay = 30;
  
  previousState = digitalRead(pin);
  for(int counter=0; counter< debounceDelay; counter++)
  {
    delay(1);
    state = digitalRead(pin);
    if(state != previousState)
    {
      counter = 0;
      previousState = state;
    } 
  }
  return state;
}

I assigned those buttons (which I don’t really need) to different pins and now I get this on the serial monitor:

Serial1

IP: 192.168.1.100 is the IP assigned to theNodeMCU by the 3G router.

I finally got it working by changing port 8080 in the sketch to 9443.
I could log into Blynk only when the Custom port was 9443 but not 8080 although I don’t understand why.

Serial2

Can I now clone my existing local WiFi server project with the inputs and auth token from the 3G server project (I used only one gauge for testing) or I’ll have to do everything manually one more time?

Probably the ISP of your mobile router’s SIM card is blocking Blynk traffic on that port.

Sorry, I don’t understand the question. What are you trying to achieve?

Pete.

Before I attempted 3G connection I had my Blynk server project running/connecting to my local WiFi router. My question is can I duplicate/clone this project but now make it 3G connected or I have to create a new blank project with new auth token and recreate step by step everything one more time?

Is it your intention to have two copies of the project running at the same time?
If not, then why can’t you use the existing project?

It is obviously possible to clone the project, but if you are having two devices - one in one location and the other in another - then it may be better to have one project with two devices and maybe use the Tabs widget.

I find switching between projects a little cumbersome.

Pete.

Is it your intention to have two copies of the project running at the same time?
If not, then why can’t you use the existing project?

I sorted this out already.

I’m sorry for all these questions but I’m new to this and still learning how the things work.

The other thing I would like to implement to my greenhouse project is video streaming or at least taking stills. I was able to complete a project where ESP32-CAM was taking pictures and sending them to Blynk local server (local WiFi). This is the code I used:

//Viral Science www.youtube.com/c/viralscience  www.viralsciencecreativity.com
//Blynk ESP32 CAM Simple Monitor System
//While Uploading Code on ESP32 Board 1, comment the lines number: 17,36 and Uncomment lines: 16,35
//While Uploading Code on ESP32 Board 2, comment the lines number: 16,35 and Uncomment lines: 17,36

#include "esp_camera.h"
#include <WiFi.h>
#include <WiFiClient.h>
#include <BlynkSimpleEsp32.h>

// Select camera model
#define CAMERA_MODEL_AI_THINKER // Has PSRAM

#include "camera_pins.h"

#define PHOTO 14      //ESP32 CAM 1
//#define PHOTO 15      //ESP32 CAM 2
#define LED 4


const char* ssid = "";       //wifi name
const char* password = "";       //password
char auth[] = "";          //Auth Code sent by Blynk

String local_IP;
int count = 0;
void startCameraServer();

void takePhoto()
{
  digitalWrite(LED, HIGH);
  delay(200);
  uint32_t randomNum = random(50000);
  Serial.println("http://"+local_IP+"/capture?_cb="+ (String)randomNum);
  Blynk.setProperty(V1, "urls", "http://"+local_IP+"/capture?_cb="+(String)randomNum); //ESP32 CAM 1
//Blynk.setProperty(V2, "urls", "http://"+local_IP+"/capture?_cb="+(String)randomNum); //ESP32 CAM 2
  digitalWrite(LED, LOW);
  delay(1000);
}

void setup() {
  Serial.begin(115200);
  pinMode(LED,OUTPUT);
  Serial.setDebugOutput(true);
  Serial.println();
  
  camera_config_t config;
  config.ledc_channel = LEDC_CHANNEL_0;
  config.ledc_timer = LEDC_TIMER_0;
  config.pin_d0 = Y2_GPIO_NUM;
  config.pin_d1 = Y3_GPIO_NUM;
  config.pin_d2 = Y4_GPIO_NUM;
  config.pin_d3 = Y5_GPIO_NUM;
  config.pin_d4 = Y6_GPIO_NUM;
  config.pin_d5 = Y7_GPIO_NUM;
  config.pin_d6 = Y8_GPIO_NUM;
  config.pin_d7 = Y9_GPIO_NUM;
  config.pin_xclk = XCLK_GPIO_NUM;
  config.pin_pclk = PCLK_GPIO_NUM;
  config.pin_vsync = VSYNC_GPIO_NUM;
  config.pin_href = HREF_GPIO_NUM;
  config.pin_sscb_sda = SIOD_GPIO_NUM;
  config.pin_sscb_scl = SIOC_GPIO_NUM;
  config.pin_pwdn = PWDN_GPIO_NUM;
  config.pin_reset = RESET_GPIO_NUM;
  config.xclk_freq_hz = 20000000;
  config.pixel_format = PIXFORMAT_JPEG;
  
  // if PSRAM IC present, init with UXGA resolution and higher JPEG quality
  //                      for larger pre-allocated frame buffer.
  if(psramFound()){
    config.frame_size = FRAMESIZE_UXGA;
    config.jpeg_quality = 10;
    config.fb_count = 2;
  } else {
    config.frame_size = FRAMESIZE_SVGA;
    config.jpeg_quality = 12;
    config.fb_count = 1;
  }

  // camera init
  esp_err_t err = esp_camera_init(&config);
  if (err != ESP_OK) {
    Serial.printf("Camera init failed with error 0x%x", err);
    return;
  }

  sensor_t * s = esp_camera_sensor_get();
  // initial sensors are flipped vertically and colors are a bit saturated
  if (s->id.PID == OV3660_PID) {
    s->set_vflip(s, 1); // flip it back
    s->set_brightness(s, 1); // up the brightness just a bit
    s->set_saturation(s, -2); // lower the saturation
  }
  // drop down frame size for higher initial frame rate
  s->set_framesize(s, FRAMESIZE_QVGA);

  WiFi.begin(ssid, password);

  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(".");
  }
  Serial.println("");
  Serial.println("WiFi connected");

  startCameraServer();

  Serial.print("Camera Ready! Use 'http://");
  Serial.print(WiFi.localIP());
  local_IP = WiFi.localIP().toString();
  Serial.println("' to connect");
  Blynk.begin(auth, ssid, password, IPAddress(192,168,1,2), 8080);
}

void loop() {
  // put your main code here, to run repeatedly:
  Blynk.run();
  if(digitalRead(PHOTO) == HIGH){
    takePhoto();
    }
  
}

Original link and full code here:

What should I change in order to make it work with my 3G router? I tried to replace like this

Blynk.begin(auth, ssid, password, IPAddress(192,168,1,2), 8080);
with 
Blynk.begin(auth, ssid, pass, "myhostname", 9443);

Only the button worked (LED lights up) but no pictures are taken.
Please advise if I need to start a new topic on this.

Well, you have a…

and a…

You shouldn’t have both.

Pete.

The sketch is working as it is. If I remove WiFi.begin(ssid, password); the sketch doesn’t work.
For 3G if I replace as mentioned above I get only the button working which I assume means camera connects to the server. Serial monitor says camera is connected and appears in the 3G router connected devices list.

Image2