Thanks man. sorry if i ask this, iām new with this stuff,
this is my UNOās sketch
// UNO Sketch Part Of ESP-01
#define ledPin 13
#define fanPin 12
#define serialbufferSize 15
// End of Constants
// Now the real varibles
#define debug 0
char inputBuffer[serialbufferSize] ;
int serialIndex = 0; // keep track of where we are in the buffer
// End of real variables
#include <SoftwareSerial.h>
SoftwareSerial ESPserial(7, 4); // RX | TX ESP-01 Connection
#include <IRremote.h>
IRsend irsend;
const unsigned int AC_irSignalONOFF[] PROGMEM = {9172, 4516, 600, 1684, 596, 1688, 596, 556, 592, 560, 592, 564, 592, 568, 592, 572, 592, 1692, 596, 548, 596, 1688, 596, 1692, 592, 560, 592, 564, 592, 568, 592, 568, 596, 560, 592, 548, 592, 552, 592, 1688, 596, 560, 596, 560, 592, 568, 592, 568, 592, 560, 592, 548, 592, 1688, 596, 556, 592, 560, 592, 1700, 596, 1700, 596, 568, 596, 1692, 596, 548, 596, 552, 592, 556, 592, 560, 596, 564, 592, 564, 596, 568, 592, 560, 592, 548, 596, 552, 592, 556, 596, 556, 596, 560, 596, 564, 596, 568, 592, 544, 592, 8064, 596, 1684, 596, 552, 592, 556, 592, 560, 592, 564, 592, 564, 596, 568, 596, 1692, 596, 1684, 592, 552, 596, 556, 592, 1696, 592, 1704, 592, 564, 596, 568, 592, 560, 592, 552, 592, 552, 592, 556, 596, 556, 596, 560, 596, 564, 592, 572, 592, 560, 596, 548, 592, 552, 592, 556, 592, 560, 592, 564, 592, 568, 592, 568, 596, 556, 596, 548, 592, 552, 592, 556, 596, 556, 596, 560, 596, 564, 596, 568, 596, 560, 592, 548, 596, 552, 592, 556, 592, 560, 592, 564, 592, 568, 592, 572, 596, 556, 596, 548, 596, 548, 596, 556, 592, 560, 592, 564, 592, 564, 596, 568, 592, 560, 592, 552, 592, 1688, 596, 1692, 596, 1692, 596, 564, 592, 1704, 596, 568, 592, 540, 596, 8064, 596, 552, 592, 552, 592, 556, 592, 560, 592, 564, 592, 568, 592, 568, 596, 556, 596, 1684, 596, 552, 592, 556, 592, 560, 592, 564, 592, 568, 592, 568, 596, 560, 596, 544, 596, 552, 592, 556, 592, 556, 596, 560, 592, 568, 592, 568, 596, 556, 596, 548, 592, 552, 592, 556, 592, 560, 592, 564, 592, 564, 596, 568, 592, 560, 592, 548, 596, 552, 592, 556, 592, 1696, 592, 564, 596, 564, 592, 572, 592, 560, 592, 548, 592, 552, 596, 552, 596, 556, 592, 564, 592, 568, 592, 568, 596, 556, 596, 1684, 596, 552, 592, 556, 592, 1696, 596, 564, 592, 568, 592, 568, 592, 544, 624}; //AnalysIR Batch Export (IRremote) - RAW
int khz = 38;
#include "DHT.h"
#define DHTTYPE DHT11
#define DHTPIN 10
DHT dht(DHTPIN, DHTTYPE);
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
ESPserial.begin(9600);
pinMode(ledPin,OUTPUT);
pinMode(fanPin,OUTPUT);
dht.begin();
}
void loop() {
// Notice how the main loop is very simple and the functions
// seperate the logic into easily manageable parts
if (CheckSerial()) DoCommand(inputBuffer);
readTemp ();
delay(1000);
// Do other stuff
}
boolean DoCommand(char * commandBuffer)
{
// Standard way to handle commands
if (strcmp(commandBuffer , "V0 1")==0) // ACPOWER ON OFF
{
digitalWrite(ledPin,HIGH);
sendRAW_Flash(AC_irSignalONOFF, sizeof(AC_irSignalONOFF)/sizeof(int),khz); //send AC signal #1 @ 33kHz
delay(5000); //a good idea to have gaps between signals
digitalWrite(ledPin,LOW);
}
else if (strcmp(commandBuffer , "V4 1")==0) // FAN Relay
{
//fanOn= !fanOn;
digitalWrite(fanPin,1);
}
else if (strcmp(commandBuffer , "V4 0")==0) // FAN Relay
{
//fanOn= !fanOn;
digitalWrite(fanPin,0);
}
else {
Serial.print("I dont understand you \nYou said: ");
Serial.println(commandBuffer);
// Do some other work here
// and here
// and here
}
// debug code after here
#if debug
Serial.print("Free Ram = "); Serial.println(freeRam(), DEC);
#endif
return true;
}
/*
Checks the serial input for a string, returns true once a '\n' is seen
users can always look at the global variable "serialIndex" to see if characters have been received already
*/
boolean CheckSerial()
{
boolean lineFound = false;
// if there's any serial available, read it:
while (ESPserial.available() > 0) {
//Read a character as it comes in:
//currently this will throw away anything after the buffer is full or the \n is detected
char charBuffer = ESPserial.read();
if (charBuffer == '\n') {
inputBuffer[serialIndex] = 0; // terminate the string
lineFound = (serialIndex > 0); // only good if we sent more than an empty line
serialIndex=0; // reset for next line of data
}
else if(charBuffer == '\r') {
// Just ignore the Carrage return, were only interested in new line
}
else if(serialIndex < serialbufferSize && lineFound == false) {
/*Place the character in the string buffer:*/
inputBuffer[serialIndex++] = charBuffer; // auto increment index
}
}// End of While
return lineFound;
}// End of CheckSerial()
#if debug
// check free ram
int freeRam ()
{
extern int __heap_start, *__brkval;
int v;
return (int) &v - (__brkval == 0 ? (int) &__heap_start : (int) __brkval);
}
#endif
void sendRAW_Flash(const unsigned int * signalArray, unsigned int signalLength, unsigned char carrierFreq) {
irsend.enableIROut(carrierFreq); //initialise the carrier frequency for each signal to be sent
for (unsigned int i=0;i<signalLength;i++){
//tmp=pgm_read_word_near(&signalArray[i]);
// tmp=cleanPanasonic(tmp); //not needed
if (i & 1) irsend.space(pgm_read_word_near(&signalArray[i]));
else irsend.mark(pgm_read_word_near(&signalArray[i]));
}
irsend.space(1);//make sure IR is turned off at end of signal
}
void readTemp (){
float t = dht.readTemperature();
if (isnan(t) ) {
Serial.println("Failed to read from DHT sensor!");
return;
}
Serial.print("Temperature: ");
Serial.print(t);
Serial.println(" *C ");
ESPserial.println(t);
}
And this is my ESP-01 Sketch (that run Blynk)
#define BLYNK_PRINT Serial
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "authTOKEN";
// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "MYSSID";
char pass[] = "MYSSIDPASSWD";
BlynkTimer timer;
void setup()
{
// Debug console
Serial.begin(9600);
Blynk.begin(auth, ssid, pass, "local ip xxx.xxx.xxx.xxx");
}
BLYNK_WRITE(V0){ //AC-POWER//
int pinValue = param.asInt();
if (pinValue==1) {
Serial.print("V0 ");
Serial.println(pinValue);
}
}
BLYNK_WRITE(V4){ //FAN//
int pinValue = param.asInt();
if (pinValue==1) {
Serial.print("V4 ");
Serial.println(pinValue);
}
else{
Serial.print("V4 ");
Serial.println(pinValue);
}
}
//////////////////////////terminal////////////////
void loop()
{
Blynk.run();
timer.run();
}
Blockquote
every thing is fine, i press button V0 on my phone and UNO can process it and turn my AC ON or OFF, if i Press V4 button on my phone UNO turn ON/OFF the Fan relay.
I just neeed grab ātā (temperatur) value from uno and send it to ESP-01 as data, but Serial Monitor on ESP cannot showing it.( iām stuck here). if i just use normal sketch i mean without Blynk Stuff, yes i can read it on ESPās Serial Monitor, but if i run with Blynk library ESPās Serial Monitor never Print/Showing incoming data from UNO.
sorry if this make you all get confused, English is not my primary languange, i hope you get what i mean to. tks