Hello,
I am unsuccessfully trying to send specific data (temperature), from an ESP8266 ESP-01S WLAN WiFi Modul to an Arduino Nano using Rx/Tx pins on both ends. The ESP is separately supplied with 3.3V. Connection is the folloing;
Rx/Tx Tx/Rx
Here is the code I use for the sender (= ESP8266 ESP01):
#include <ESP8266WiFi.h>
#include <ESP8266HTTPClient.h> // http web access library
#include <ArduinoJson.h> // JSON decoding library
#include <SoftwareSerial.h>
#include <TimeLib.h>
SoftwareSerial toUno(3, 1); //Rx, Tx partie NEW
byte pinState = 0;
const char *ssid = "xxx";
const char *password = "xxx-xxxx";
void setup() {
toUno.begin(9600); //partie NEW
Serial.begin(115200);
delay(500);
Serial.print("Connecting.");
WiFi.begin(ssid, password); // access Wi-FI point
while ( WiFi.status() != WL_CONNECTED ) {
delay(500);
Serial.print(".");
}
Serial.println("connected\r\n");
internet();
toUno.print("From the ESP8266 OLAA"); //partie NEW
}
void loop()
{
internet();
}
void internet()
{
if (WiFi.status() == WL_CONNECTED) { //Check WiFi connection status
HTTPClient http; //Declare an object of class HTTPClient
// specify request destination
http.begin("http://api.openweathermap.org/data/2.5/weather?q=Bt,pt&APPID=8b996a0dd66af5a4ada85678e81b013");
int httpCode = http.GET(); // send the request
if (httpCode > 0) { // check the returning code
String payload = http.getString(); //Get the request response payload
DynamicJsonBuffer jsonBuffer(512);
// Parse JSON object
JsonObject& root = jsonBuffer.parseObject(payload);
if (!root.success()) {
Serial.println(F("Parsing failed!"));
return;
}
float temp = (float)(root["main"]["temp"]) - 273.15; // get temperature
int humidity = root["main"]["humidity"]; // get humidity
float pressure = (float)(root["main"]["pressure"]) / 1000; // get pressure
float wind_speed = root["wind"]["speed"]; // get wind speed
int wind_degree = root["wind"]["deg"]; // get wind degree
// print data
Serial.printf("Temperature = %.2f°C\r\n", temp);
Serial.printf("Humidity = %d %%\r\n", humidity);
Serial.printf("Pressure = %.3f bar\r\n", pressure);
Serial.printf("Wind speed = %.1f m/s\r\n", wind_speed);
Serial.printf("Wind degree = %d°\r\n\r\n", wind_degree);
toUno.write(toUno.read()); //partie NEW
delay(2000); //partie NEW
http.end(); //Close connection
} }
delay(60000); // wait 1 minute
}
My questions:
-
How do I tell ESP01 to send the data through the TX pin (Pin 1) to the Arduino? I use SoftwareSerial toUno(3, 1);
but it seems not to work. -
How do I specify what data is to send, I only want to send temperature.
-
Now, on the Arduino Nano, how do I tell Arduino to read the data on its Rx port coming from ESP and to print it ( here the temperature) in a Led matrix?
Thanks in advance for all information