Chat here about code rewrites, mods, etc... with respect to the github project https://github.com/esp8266/Arduino

Moderator: igrr

User avatar
By plzhelp
#80939 So i have this code for my arduino mega 2560 (which is working perfectly fine i think):

Code: Select all#include <dht.h>
dht DHT;
int temp,humi;
#define DHT11_PIN A0
String str;
void setup(){
 Serial.begin(115200);
 Serial1.begin(115200);
 Serial.print(char(169)); // Copyright Symbol
 Serial.println(" Myengineeringstuffs.com");
 delay(2000);
}
void loop()
{
  DHT.read11(DHT11_PIN);
  humi=DHT.humidity;
  temp=DHT.temperature;
  Serial.print("H: ");
  Serial.print(humi);
  Serial.print("% ");
  Serial.print(" T: ");
  Serial.print(temp);
  Serial.print(char(176));
  Serial.println("C");
  str =String('H')+String(humi)+String('T')+String(temp);
  Serial1.print(str);
  delay(5000);
}


And this is my ESP8266-12 code (which i dont know why its not!):

Code: Select allvoid setup() {
  Serial.begin(115200);
  while (!Serial) {
    Serial.write("pls work!"); // wait for serial port to connect. Needed for native USB port only
  }
}

void loop() { 
  if (Serial.available()) {
    Serial.write(Serial.read());
  }
}


The arduino should be sending the temp and humidity data through Serial1 using the String str which i think it is, but the esp module is not printing it on its own serial. i have each device connected to a different port just as this video is telling me to do: [youtube]https://www.youtube.com/watch?v=-6Nb5kL43GY&list=LLbZB7cnQl5E4S6bYraYptww&index=3&t=485s[/youtube]

but i am not getting the same result as he is, i only get a blank screen for my esp serial monitor!

Any help is very much appreciated!!
User avatar
By RichardS
#81013 The serial port on the ESP8266 is connected normally to a USB to serial chip like CH340 etc... If this is still connected I might expect this not to work....

RichardS
User avatar
By mrburnette
#81052 I have found it invaluable to have something like this on my bench:
https://www.hackster.io/rayburne/the-qbf-signal-generator

You can also use a USB-serial converter and your PC with the Arduino IDE monitor or a communication program. These can be had for a couple of dollars on Aliexpres or a very nice one from Adafruit:
https://www.adafruit.com/product/954