-
Notifications
You must be signed in to change notification settings - Fork 635
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support for MHZ19 #1063
Comments
@jsponz, looks like you are using a wrong library, please always check you libs first ;) and the message is clearly saying that: If you check the platformio.ini somewhere around line 76 you'll find the lib https://github.com/plerup/espsoftwareserial#3.4.1 intall it cause |
@Valcob Thanks for your answer. I am using Arduido IDE. Where should I make the change? |
@jsponz, https://stackoverflow.com/questions/16752806/how-do-i-remove-a-library-from-the-arduino-environment Also please check these: |
@Valcob Thanks for the hints. I have followed all of them and now the situation is as follows: Build options changed, rebuilding all Any further help? Thanks in advance. |
@jsponz
|
Some findings: Recommended ESPSoftwareSerial library (https://github.com/krosk93/espsoftwareserial) does not have 'enableIntTx'... If I change to https://github.com/plerup/espsoftwareserial It compiles, but I don't see the sensor on the web panel... |
Well congrats, finally you have the right lib. |
Info on the website should be updated :-) Anyway, I get it finally on the panel, but: [188610] [SENSOR] Error reading data from MHZ19 @ SwSerial(14,15) (error: 5) I have changed the pins, but with the same result. Any idea? |
//------------------------------------------------------------------------------ #ifndef MHZ19_TX_PIN |
I use pins 14 and 15. They are connected to the MHZ19. I have defined them in /config/hardware.h under my board:
|
Looks like you need to swap the pins )) from the line of code[... SwSerial(%u,%u)", _pin_rx, _pin_tx ...] we are printing the rx pin number first then tx pin number and from your error Check the device connection and pin configuration |
@Valcob I have changed the pins as well, and the same result :-( Is there any parameter, setting or anything to modify? I have tried with two devices. |
https://www.winsen-sensor.com/d/files/PDF/Infrared%20Gas%20Sensor/NDIR%20CO2%20SENSOR/MH-Z19%20CO2%20Ver1.0.pdf so the sensor TX pin 3 should be connected to the Lolin's RX 15 in your case and sensor RX pin 2 to the Lolin's TX 14 in your case |
@Valcob Thanks! Just from the hardware: MHZ19 I have configured the hardware file accordingly, but nothing... |
From your definitions you have RX on LOLIN set to pin 15 |
Yes, I know. But I have changed the definitions... without success... |
Sorry, I don't have an MHZ19 right now so I can't check the code is working for myself but I hope someone who has this sensor can help you or fix the code if something was broken... |
@Valcob Thanks for your help! I guess that there is something broken... |
In sensors.h no baudrate is set for this sensor. Sensor baudrate is 9600. I can't check on my tablet (no search in files option) but I think baudrate is set by default at 19k2. Hope this helps |
it is defined in: https://github.com/xoseperez/espurna/blob/dev/code/espurna/sensors/MHZ19Sensor.h line 80. |
Any further support? |
@jsponz I would like to help you but I don't have this sensor now.... though we can try one thing just to see what the result buffer contains then just post the results from log window in here |
@Valcob Thanks for your hint. I will test it on Thursday and I will get back to you. |
I have an MHZ19 I can test but I won't be able to do it until mid-August since I'm on holidays. |
@Valcob, please find below the results: 0 and if I switch the serial port: 0 Any help? :-) Thanks! |
@jsponz, that's bad we do not have data at all (( I'm waiting for my sensor so I can check the libs. We should have a response like: A response to command 0x86(MHZ19_GETPPM) typically looks like this:
Also GPIO15 is tight to GND with a 10k resistor usually, could please try other two pins that are free (not connected through resistors to ground nor vcc) for ex. I would start with GPIO 4 and 5 |
@Valcob, it works! I have connected Rx/Tx to GPIO 4 and 5 and it works! Now it returns: 255 What are other pins that I could use? IO4 and IO5 are being used for I2C. Thanks! |
I'm glad to hear that, basically the rule of thumb is to use any other pin that is free and has no other logic bound to it through software. Next you can try IO12, IO13, IO14, IO15, IO16(if it is not used as deep sleep awaker), IO02, IO0, you can try any combination of these (excluding 14 + 15 we know this one does not work) but i don't know what else you have connected to the board so basically you have to experiment. |
Final pinout:
Everything possible :) Thanks! |
You are very welcome! now you can close the issue ticket Thanks and enjoy |
Sure! |
When compiling for adding support for MHZ19 to the board NodeMCU Lolin, I get this error:
In file included from sketch/config/sensors.h:757:0,
from sketch/config/all.h:33,
from /Users/jorgesanchez/git/espurna/code/espurna/espurna.ino:22:
sketch/config/../sensors/MHZ19Sensor.h: In member function 'virtual void MHZ19Sensor::begin()':
sketch/config/../sensors/MHZ19Sensor.h:79:22: error: 'class SoftwareSerial' has no member named 'enableIntTx'
_serial->enableIntTx(false);
^
Multiple libraries were found for "SoftwareSerial.h"
Used: /Users/jorgesanchez/Library/Arduino15/packages/esp8266/hardware/esp8266/2.4.1/libraries/SoftwareSerial
Not used: /Users/jorgesanchez/Documents/Arduino/libraries/espsoftwareserial-master
exit status 1
Error compiling for board NodeMCU 1.0 (ESP-12E Module).
Hardware file:
Any idea?
The text was updated successfully, but these errors were encountered: