Serial Monitor Issue

i got this serial monitor output with my code with lolin node mcu esp 8266 v3, i don't get it

#include <RBDdimmer.h>
#include <Stdio.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#include "CTBot.h"
#include "ESP8266WiFi.h"
CTBot myBot;


const int relay = 4; 
const int outputPin = 3;
const int zerocross = 7;
#define DELAY 1000
#define SCREEN_WIDTH 128 // OLED display width, in pixels
#define SCREEN_HEIGHT 32 // OLED display height, in pixels
#define OLED_RESET 13
#define LED_PIN 14
Adafruit_SSD1306 display(OLED_RESET);

String ssid = "xxx";   
String pass = "xxx"; 
String token = "xxx"; 

String data;
char c;

#define BH1750_POWER_DOWN 0x00  // No active state
#define BH1750_POWER_ON 0x01  // Waiting for measurement command
#define BH1750_RESET 0x07  

#define CONTINUOUS_HIGH_RES_MODE 0x10  // Measurement at 1 lux resolution. Measurement time is approx 120ms
#define CONTINUOUS_HIGH_RES_MODE_2 0x11  // Measurement at 0.5 lux resolution. Measurement time is approx 120ms
#define CONTINUOUS_LOW_RES_MODE 0x13  // Measurement at 4 lux resolution. Measurement time is approx 16ms
#define ONE_TIME_HIGH_RES_MODE 0x20  // Measurement at 1 lux resolution. Measurement time is approx 120ms
#define ONE_TIME_HIGH_RES_MODE_2 0x21  // Measurement at 0.5 lux resolution. Measurement time is approx 120ms
#define ONE_TIME_LOW_RES_MODE 0x23  // Measurement at 4 lux resolution. Measurement time is approx 16ms

#define BH1750_1_ADDRESS 0x23  // Sensor 1 connected to GND
#define BH1750_2_ADDRESS 0x5C  // Sensor 2 connected to VCC

int outVal = 0;
dimmerLamp dimmer(outputPin,zerocross);

int16_t s_en = 0;
int16_t s0 = 1;
int16_t s1 = 2;
int16_t s2 = 3;

int16_t RawData;
int16_t SensorValue[4];

void setup() {
  Wire.begin();
  dimmer.begin(NORMAL_MODE, ON);
  Serial.begin(115200); // Baud Rate
  display.begin(SSD1306_SWITCHCAPVCC, 0x3C);
  display.display();
  delay(1);
  display.clearDisplay();
	Serial.println("Starting TelegramBot...");
	myBot.wifiConnect(ssid, pass);
	myBot.setTelegramToken(token);

	if (myBot.testConnection())
		Serial.println("\ntestConnection OK");
	else
		Serial.println("\ntestConnection NOK");


  pinMode(s_en, OUTPUT);
  pinMode(s0, OUTPUT);
  pinMode(s1, OUTPUT);
  pinMode(s2, OUTPUT);

  digitalWrite(s_en, HIGH);
  digitalWrite(s0, HIGH);
  digitalWrite(s1, HIGH);
  digitalWrite(s2, HIGH);

  pinMode(LED_PIN, OUTPUT);
  digitalWrite(LED_PIN, HIGH);
}
void init_BH1750(int ADDRESS, int MODE){
  //BH1750 Initializing & Reset
  Wire.beginTransmission(ADDRESS);
  Wire.write(MODE);  // PWR_MGMT_1 register
  Wire.endTransmission(true);
}
void RawData_BH1750(uint8_t ADDRESS){
  Wire.beginTransmission(ADDRESS);
  Wire.requestFrom(ADDRESS,(size_t)2,(bool)true); // request a total of 2 registers
  RawData = Wire.read() << 8 | Wire.read();  // Read Raw Data of BH1750
  Wire.endTransmission(true);
}

int readMux(int channel){
  int controlPin[] = {s0, s1, s2}; 
  int muxChannel[8][3] = { 
    {0,0,0}, //channel 0 
    {1,0,0}, //channel 1 
    {0,1,0}, //channel 2 
    {1,1,0}, //channel 3 
    {0,0,1}, //channel 4 
    {1,0,1}, //channel 5 
    {0,1,1}, //channel 6 
    {1,1,1}, //channel 7  //loop through the 3 Signals 
  };
  for(int i = 0; i < 3; i++){ // Connecting MUX Channel
    digitalWrite(controlPin[i], muxChannel[channel][i]); 
  } 
  return channel;
}

void loop() {
  	TBMessage msg;

	if (myBot.getNewMessage(msg)) {

		if (msg.text.equalsIgnoreCase("RELAY ON")) {              
			myBot.sendMessage(msg.sender.id, "RELAY is now ON");  //kirim pesan ke bot telegram
		  Serial.print("RELAY ON");
		}
		else if (msg.text.equalsIgnoreCase("RELAY OFF")) {        
			myBot.sendMessage(msg.sender.id, "RELAY is now OFF"); 
		  Serial.print("RELAY OFF");        
		}
    delay(500);
	} 
	
  digitalWrite(s_en, LOW); // Enabling the Enable Switch

  for(int i = 0; i < 4; i++){ 
   readMux(i);

    init_BH1750(BH1750_1_ADDRESS, CONTINUOUS_HIGH_RES_MODE);
    delay(120);
    RawData_BH1750(BH1750_1_ADDRESS);
    SensorValue[i] = RawData / 1.2;  
    delay(20);
   }
  

   Serial.print("Sensor_1 = "); Serial.print(SensorValue[0]);
   Serial.print(" | Sensor_2 = "); Serial.print(SensorValue[1]);
   Serial.print(" | Sensor_3 = "); Serial.print(SensorValue[2]);
   Serial.print(" | Sensor_4 = "); Serial.println(SensorValue[3]);

   int x= SensorValue[0] + SensorValue[1] + SensorValue[2] + SensorValue[3];
   int y= 4;
   int z= x / y;

   Serial.print("Lux = ");Serial.println(z);
  
   if (z =500){
    outVal =0;
    }
    else {
     if (z<500)
       while (z<500){
        outVal -=1;
        delay(DELAY);
      }
    }
   if (z >500)
    while (z>500){
     outVal += 1;
     delay(DELAY);
    }
    
   dimmer.setPower(outVal);
   Serial.print("Dimmer = "); Serial.println(outVal);
   delay(DELAY);
}

this the result serial monitor output :

ets Jan 8 2013,rst cause:4, boot mode:(3,6)
wdt reset
load 0x4010f000, len 3424, room 16
tail 0
chksum 0x2e
load 0x3fff20b8, len 40, room 8
tail 0
chksum 0x2b

what is it

That looks like the reset/power on out put for a ESP
In the future please take some time to properly categorize your topics.
It will help us help you.
Thanks

I moved your topic to an appropriate forum category .

As already requested by v205, in the future, please take some time to pick the forum category that best suits the subject of your topic. There is an "About the _____ category" topic at the top of each category that explains its purpose.

This is an important part of responsible forum usage, as explained in the "How to get the best out of this forum" guide. The guide contains a lot of other useful information. Please read it.

Thanks in advance for your cooperation.

1 Like

ahh okey, i don't know about that categorize, sorry, thanks for your reply before, but "looks like the reset/power on out put for a ESP-32". that means ? lack of power ? or something ?

sorry before, and thanks your information

1 Like

how can i looked the v205 forum's?

I'm not sure I understood correctly what you mean by this. Please provide a more detailed description to help me to understand it.

Oops not ESP-32.
It’s a normal message.
Just how the ESP acts upon serial reset.
If every thing else is working it’s not a problem.
PS: I don’t no what serial baud ESP-8266 uses for those messages
Try going to 115200 baud in the monitor.

i'm using that code, to see result on the serial monitor, before i use arduino mega and result same as i spawned in print code, but i change it with esp 8266, and the result is cannot to see as arduino mega, and baud rate is 115200

yup i use this rate baud, but that the result, i'm cannot see the result as arduino mega, i'm so confused :sweat_smile:

Sorry, but I don’t understand your question.
Could you clarify?

i mean, i using arduino mega before, and serial monitor give me result clearly, like
"Lux : 200", but on esp8266 i want to serial monitor give me same result like mega. but i got that weird result, i don't know if that normal, but i can't see the result clearly

Try setting the baud rate in the code to 9600.
Then upload and select 9600 as the baud rate in the monitor.

okey i'll try

i tried many baud rate, haven't change, i use D1 D2 for SCL SDA, D5 D6 D8 for PWM pin, for more information, is that right ?

No idea, not an expert on ESP8266.
Photos of circuit?

That indicates a reset caused by the watchdog timer. (wdt)

https://arduino-esp8266.readthedocs.io/en/latest/faq/a02-my-esp-crashes.html#watchdog

As it says

to identify the place of lock up, you need to rely on debug messages like Serial.print distributed across the application.

Since you dont get a serial print the problem must be in your setup()

I'd suggest you move the serial begin and put a print after each of the following lines

1 Like

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.