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

Moderator: igrr

User avatar
By martinayotte
#22520
ofer221 wrote:it works grate but I can't restart the module without pulling out the IR transmitter first


@AntonKa, if you are facing the same issue as ofer211, I've answered earlier ont his thread that connecting a LED or a IRLED to ground is acting as pull-down on GPIO2, so it prevent booting properly. The polarity need to be reversed and connected to VCC, of course in the software doing a digitalWrite(LED, LOW) will turn on the LED, so polarity need to be reversed there too.
User avatar
By dmpotter
#25505 Awesome, got my working right away with a ESP8266 12E.

I cobbled some code from another thread -> viewtopic.php?f=29&t=3787

Code: Select all#include <ESP8266WiFi.h>
#include <WiFiClient.h>
#include <ESP8266WebServer.h>
#include <ESP8266mDNS.h>
#include <IRremoteESP8266.h>

const char* ssid = "......................................";
const char* password = ".............................";

IRsend irsend(13); //an IR led is connected to GPIO pin 13

MDNSResponder mdns;
ESP8266WebServer server(80);

void handleRoot() {
  server.send(200, "text/plain", "hello from esp8266!");
}

void handleNotFound(){
  String message = "File Not Found\n\n";
  message += "URI: ";
  message += server.uri();
  message += "\nMethod: ";
  message += (server.method() == HTTP_GET)?"GET":"POST";
  message += "\nArguments: ";
  message += server.args();
  message += "\n";
  for (uint8_t i=0; i<server.args(); i++){
    message += " " + server.argName(i) + ": " + server.arg(i) + "\n";
  }
  server.send(404, "text/plain", message);
}
 
void setup(void){
  pinMode(13,OUTPUT);
  Serial.begin(9600);
  WiFi.begin(ssid, password);
  Serial.println("");

  // Wait for connection
  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(".");
  }
  Serial.println("");
  Serial.print("Connected to ");
  Serial.println(ssid);
  Serial.print("IP address: ");
  Serial.println(WiFi.localIP());
 
  if (mdns.begin("esp8266", WiFi.localIP())) {
    Serial.println("MDNS responder started");
  }
 
  server.on("/", handleRoot);
 
  server.on("/IRSignal", [](){
  server.send(200, "text/plain", "Sent Signal");
  irsend.sendNEC(0xFF40BF,36);
  Serial.println("Signal Sent, doing delay");
  delay(3000);
  Serial.println("Delay Over");
  });
 
  server.onNotFound(handleNotFound);
 
  server.begin();
  Serial.println("HTTP server started");
}
 
void loop(void){
  server.handleClient();
}


So, to just access the webserver which in my run showed up as 192.168.1.16

.....
Connected to PRETTYFLYFORAWIFI
IP address: 192.168.1.16
MDNS responder started
HTTP server started
Signal Sent, doing delay
Delay Over


Then I was able to just add the extension
http://192.168.1.16/IRSignal

The important part was adding pinMode without that I guess it didn't know it was an output.

Just to make sure it worked without all the webserver stuff this is the basic code.

Code: Select all/*
 * IRremoteESP8266: IRsendDemo - demonstrates sending IR codes with IRsend
 * An IR LED must be connected to ESP8266 pin 0.
 * Version 0.1 June, 2015
 * Based on Ken Shirriff's IrsendDemo Version 0.1 July, 2009, Copyright 2009 Ken Shirriff, http://arcfn.com
 */

#include <IRremoteESP8266.h>

IRsend irsend(13); //an IR led is connected to GPIO pin 0

void setup()
{
  irsend.begin();
  Serial.begin(9600);
}

void loop() {
  Serial.println("NEC");
  irsend.sendNEC(0xFF40BF, 36);
  delay(10000);
}


What I really want to be able to do is use the maker channel on IFTTT and send power on, power off signals. I have been able to send to IFTTT just haven't worked out a running monitor for the trigger part. Separate topic though I'm sure. But hypothetically, "if (THIS LIGHT GETS TURNED ON) then (USE IR via 8322 to turn this ON)".
User avatar
By aegiacometti
#38883 Hi there...

I have a code wich is working on ArduinoUno, but does not work with ESP.

My remote is not recognized so I need to use sendRaw, i get that raw code/timmings with Arduino.

unsigned int IR_AA_ON[] = {4300,4400, 500,1650, 500,600, 500,1650, 500,1650, 550,550, 500,550, 550,1600, 550,550, 550,550, 500,1650, 500,600, 500,600, 500,1650, 500,1650, 500,550, 550,1650, 500,600, 500,600, 500,550, 500,1700, 500,1600, 550,1600, 550,1650, 500,1650, 500,1700, 450,1650, 550,1600, 550,600, 500,550, 500,600, 500,550, 500,600, 500,1650, 550,550, 500,1650, 500,1700, 500,1600, 500,600, 550,550, 500,550, 550,600, 500,1600, 550,550, 500,600, 500,550, 550,1650, 500,1650, 500,1650, 500};

int khz = 38; // 38kHz carrier frequency
for (int i = 0; i < 3; i++) {
irsend.sendRaw(IR_AA_ON, sizeof(IR_AA_ON) / sizeof(IR_AA_ON[0]), khz);
delay(5);
}

I can see the IRled blinking, but something must be different because does not work with ESP.

Any advice?

thks
User avatar
By gggggggg
#63440
aegiacometti wrote:Hi there...

unsigned int IR_AA_ON[] = {4300,4400, 500,1650, 500,600, 500,1650, 500,1650, 550,550, 500,550, 550,1600, 550,550, 550,550, 500,1650, 500,600, 500,600, 500,1650, 500,1650, 500,550, 550,1650, 500,600, 500,600, 500,550, 500,1700, 500,1600, 550,1600, 550,1650, 500,1650, 500,1700, 450,1650, 550,1600, 550,600, 500,550, 500,600, 500,550, 500,600, 500,1650, 550,550, 500,1650, 500,1700, 500,1600, 500,600, 550,550, 500,550, 550,600, 500,1600, 550,550, 500,600, 500,550, 550,1650, 500,1650, 500,1650, 500};

int khz = 38; // 38kHz carrier frequency


Hi @aegiacometti did you get this working?