try uploading the receive example of RCswitch into your nodemcu and see if it work first.
ok⌠i tested the receive example skatch of Rcswitch into my nodecmu
and change (gpio)
void setup() {
Serial.begin(9600);
mySwitch.enableReceive(2); // Receiver on interrupt 0 => that is pin #2
to
mySwitch.enableReceive(5); //PIN OF RECEIVER NODEMCU RIGHT???
and when i pressed door bellâŚnot happens anything.
after that i did another test⌠and i tried with my Arduino and the results:
Received 10340193 / 24bit Protocol: 1
Received 10340193 / 24bit Protocol: 1
ok it is not an issue with the gateway
On which pin is your receiver connected on NODEMCU?
i have it connected on D1
ok in this case this is correct.
Do you power your receiver with 5V?
No.
VCC receiver ---------- VIN nodemcu
GND receiver ---------- G nodemcu
Vin of the nodemcu has 5V voltage should be ok, to be sure you could measure it with a multimeter.
You could recheck your wire (connect them as directly as you can) and remove the emitter.
GRRRRRRRR the problem was the powerâŚ
vin of my nodemcu are 1.89 volts GRRRRRRR chinesesssssses
ok now its working with your code⌠i connect vcc and gnd directly on 5v and gnd arduino.
on your code are the results:
Receiving 433Mhz signal
isAduplicate
Sending 433Mhz signal to MQTT
10340193
sending
10340193
to
home/433toMQTT
Minimum index: 0
send this code :10340193/5275
Col: value/timestamp
0:10340193/5275
1:0/0
2:0/0
3:0/0
4:0/0
5:0/0
6:0/0
7:0/0
8:0/0
9:0/0
but on the putty terminal shows ok:
pi@hassbian:~ $ mosquitto_sub -t home/433toMQTT -v
home/433toMQTT 10340193
@1technophile
We were both wrong. On board nodemcu v3 the VIN pin does not provide 5v.
I went to read on the board, and read that the VU pin provides 5 volts.
you can update your tutorial with this information about the pin vu only on the boards nodemcu V3.
Another question.
It would be interesting to get more out of the board pins.
Do you think you can modify your tutorial, and add a DHT22 with this code?
#include <ESP8266WiFi.h>
#include <PubSubClient.h>
#include âDHT.hâ
#define DHTPIN D4 // what pin weâre connected to
#define wifi_ssid âomgwifiâ
#define wifi_password âmoowoofmeowâ
#define mqtt_server âyourMqttServerâ
#define humidity_topic âtopicName/humidityâ
#define temperature_topic âtopicName/temperatureâ
// Uncomment whatever type youâre using!
#define DHTTYPE DHT11 // DHT 11
//#define DHTTYPE DHT22 // DHT 22 (AM2302)
//#define DHTTYPE DHT21 // DHT 21 (AM2301)
WiFiClient espClient;
PubSubClient client(espClient);
DHT dht(DHTPIN, DHTTYPE);
void setup() {
Serial.begin(115200);
Serial.println(âDHTxx test!â);
setup_wifi();
client.setServer(mqtt_server, 1883);
dht.begin();
}
void setup_wifi() {
delay(10);
// We start by connecting to a WiFi network
Serial.println();
Serial.print("Connecting to ");
Serial.println(wifi_ssid);
WiFi.begin(wifi_ssid, wifi_password);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(â.â);
}
Serial.println(ââ);
Serial.println(âWiFi connectedâ);
Serial.println("IP address: ");
Serial.println(WiFi.localIP());
}
void reconnect() {
// Loop until weâre reconnected
while (!client.connected()) {
Serial.print(âAttempting MQTT connectionâŚâ);
// Attempt to connect
// If you do not want to use a username and password, change next line to
// if (client.connect(âESP8266Clientâ)) {
if (client.connect(âchangeMeâ)) {
Serial.println(âconnectedâ);
} else {
Serial.print(âfailed, rc=â);
Serial.print(client.state());
Serial.println(" try again in 5 seconds");
// Wait 5 seconds before retrying
delay(5000);
}
}
}
bool checkBound(float newValue, float prevValue, float maxDiff) {
return newValue < prevValue - maxDiff || newValue > prevValue + maxDiff;
}
long lastMsg = 0;
float temp = 0.0;
float hum = 0.0;
float diff = 1.0;
void loop() {
// Wait a few seconds between measurements.
// delay(10000);
if (!client.connected()) {
reconnect();
}
client.loop();
long now = millis();
if (now - lastMsg > 60000) {
lastMsg = now;// Reading temperature or humidity takes about 250 milliseconds!
// Sensor readings may also be up to 2 seconds âoldâ (its a very slow sensor)
float newHum = dht.readHumidity();
// Read temperature as Fahrenheit (isFahrenheit = true)
float newTemp = dht.readTemperature(true);
if (checkBound(newTemp, temp, diff)) { temp = newTemp; Serial.print("New temperature:"); Serial.println(String(temp).c_str()); client.publish(temperature_topic, String(temp).c_str(), true); }
if (checkBound(newHum, hum, diff)) { hum = newHum; Serial.print("New humidity:"); Serial.println(String(hum).c_str()); client.publish(humidity_topic, String(hum).c_str(), true);
}
}
}
It would be a much more interesting hub.
We could add some led, uv sensor, temperature sensor, humidity sensor, light sensor, a push button, a speaker, a microphone, ⌠but that would be more about writing a book on the esp possibilities and way out of topic I think.
You might want to open a separate topic if you want to add a temperature/humidity sensor and need help.
I have issues with the MQTTto433 part of the script. It seems to be sending it out based on what the terminal says but my switches donât ever turn. Anybody have any ideas on this. I am gonna just phase my switches out i think for sonoff units but will probably keep the controls around for the wife and others to use. But any help on the transmit side of things would be great.
Hello,
Here is some check to do:
-verify that your transmitter is correctly connected and powered (at least with 5V supply), idealy a multimeter will help you to do that (voltage measurement and wire connection).
-for a first test put your switch close to the gateway transmitter
-if not working and if you have an arduino put into it the received advanced example, connect a receiver and see if the arduino see the gateway signal, if it is seeing it try to command with your arduino the switch.
A major change for the gateway:
I have merged the code of arduino Uno and esp8266 into one code and added improvements. I renamed the program to OpenMQTTGateway.
Please note that this version is for test, the previous one is still available here
The documentation is now on the github wiki
I will try setting up another receiver. Will your code run on an ESP-01. All my nodemcu boards are used up on other projects.
Not tested, this is the last message of a test on ESP-01, I donât know if he succeeded or not:
Great work⌠* * * * * stars
Hi @1technophile, it seems that the infrared version is not available anymore on your blog , I know there is the new version but I seem unable to find the IR led connection schematic.
Use to be available at this address:
Hi @touliloup, you are right i need to remake the link into the github wiki, the img is there:
https://github.com/1technophile/OpenMQTTGateway/blob/master/img/OpenMQTTGateway_ESP8266.jpg
The wiki is now up to date with the schematic, thanks for pointing this:
Hi, great idea and information sharing. Iâve just ordered a RF receiver and transmitter to get this going (http://www.ebay.com.au/itm/280937260307), already have a IR transmitter and Receiver kicking around from a previous project.
One question i have, i currently own a few ESP8266 Node MCU v0.9 boards, you mentioned that there were issues with this hardware? Is there anyway to overcome it and get the solution working on ESP8266 NodeMCU V0.9?
My stack is:
- Raspberrpyi 3.0 Controller with HA and Mosquitto
- ESP 8266 NodeMCU V0.9
- Arduino IDE 1.6.9 with ESP8266 Board Manager 2.6.0
Cheers