Closed w00dwind closed 4 years ago
Hi, no problem.
It looks like the error message is due to passing UART pins to begin function which is expecting a serialmode definition instead. It seems you can set the pins with another function in setup the phase. Unfortunately, I haven't used an esp8266 before so I can't test it.
Have you been able to receive any data from the sensor since it stopped working? You could try and restart or use the reset command for the sensor (it reads out data on reboot), and read the serial to see if it is transmitting. For example, if your loop:
while(Serial.available() > 0) { byte incomingByte = Serial.read(); Serial.print("I received: "); Serial.println(incomingByte, DEC); }
"Serial." here would be whatever your serial name was defined as between the sensor, for example, Serial2.
Closing this now as it seems resolved.
I am getting the same problem, can you tell me the resolving method to solve this problem and why it is happening
Are using the ESP8266?
If so it's due to the hardware limitations of the esp8266 rather than this library. My understanding is the ESP8266 has only one free hardware port which is used by Serial.print.
Software Serial should work however, but if it's not, can you post your begin function code.
/ Comment this out to disable prints and save space /
// Select your modem:
//#define TINY_GSM_MODEM_SIM900 //#define TINY_GSM_MODEM_M590 //#define TINY_GSM_MODEM_A6 //#define TINY_GSM_MODEM_A7 //#define TINY_GSM_MODEM_BG96 //#define TINY_GSM_MODEM_XBEE
// Default heartbeat interval for GSM is 60 // If you want override this value, uncomment and set this option: //#define BLYNK_HEARTBEAT 30
// You should get Auth Token in the Blynk App. // Go to the Project Settings (nut icon). char auth[] = "";
// Your GPRS credentials // Leave empty, if missing user or pass char apn[] = "airtelgprs.com"; char user[] = ""; char pass[] = "";
//sender phone number with country code. //not gsm module phone number //const String PHONE = "Enter_Your_Phone_Number";
//GSM Module Settings //GSM Module RX pin to ESP8266 1 (ESP32 2) //GSM Module TX pin to ESP8266 3 (ESP32 4)
HardwareSerial sim800(1); TinyGsm modem(sim800);
//GPS Module Settings //GPS Module RX pin to ESP8266 5(ESP32 17) //GPS Module TX pin to ESP8266 4(ESP32 16)
HardwareSerial neogps(2); TinyGPSPlus gps;
WidgetMap myMap(V0); BlynkTimer timer; int pointIndex = 1;
void setup() {
//Set Serial monitor baud rate Serial.begin(115200); Serial.println("esp32 serial initialize"); delay(10);
//Set GPS module baud rate neogps.begin(9600, SERIAL_8N1, RXD2, TXD2); Serial.println("neogps serial initialize"); delay(10);
//Set GSM module baud rate sim800.begin(9600, SERIAL_8N1, rxPin , txPin); Serial.println("SIM800L serial initialize"); delay(3000);
// Restart takes quite some time // To skip it, call init() instead of restart() Serial.println("Initializing modem..."); modem.restart();
// Unlock your SIM card with a PIN //modem.simUnlock("1234");
Blynk.begin(auth, modem, apn, user, pass); //timer.setInterval(5000L, sendToBlynk); }
void loop() {
while(neogps.available()) { if (gps.encode(neogps.read())) { sendToBlynk(); } }
Blynk.run(); //timer.run();
} //main loop ends
void sendToBlynk() {
if (gps.location.isValid() ) { //get latitude and longitude float latitude = (gps.location.lat()); float longitude = (gps.location.lng()); //get float speed = gps.speed.kmph(); //get number of satellites float satellites = gps.satellites.value();
Serial.print("Latitude: ");
Serial.println(latitude, 6);
Serial.print("Longitude: ");
Serial.println(longitude, 6);
//Serial.print("Speed: ");
//Serial.println(speed, 6);
Blynk.virtualWrite(V1, String(latitude, 6));
Blynk.virtualWrite(V2, String(longitude, 6));
myMap.location(pointIndex, latitude, longitude, "GPS_Location");
Blynk.virtualWrite(V3, speed);
Blynk.virtualWrite(V4, satellites);
// float bearing = TinyGPSPlus::cardinal(gps.course.value()); // get the direction
// Blynk.virtualWrite(V5, bearing);
} }
This My code, I am Getting error while compiling it in ESP8266 only, but ESP32 DEV board use to compile it shows no error. What I can do for this to compile in ESP8266.
I'm not familiar with the ESP8266, so really can't help much.. however, it has only one free Serial port.
I take it "HardwareSerial neogps(2);" is producing the same errors ? If you can post the error messages, I'll have a look... but I would try using SoftwareSerial instead.
D:\Dinesh\Works\gps\gps_sim\gps_sim.ino: In function 'void setup()': gps_sim:47:14: error: invalid conversion from 'int' to 'SerialMode' [-fpermissive] 47 | #define RXD2 4 | ^ |
---|---|---|
int |
D:\Dinesh\Works\gps\gps_sim\gps_sim.ino:64:34: note: in expansion of macro 'RXD2' 64 | neogps.begin(9600, SERIAL_8N1, RXD2, TXD2); | ^~~~ In file included from C:\Users\pondi\OneDrive\Documents\ArduinoData\packages\esp8266\hardware\esp8266\3.0.0\cores\esp8266/Arduino.h:288, from sketch\gps_sim.ino.cpp:1: C:\Users\pondi\OneDrive\Documents\ArduinoData\packages\esp8266\hardware\esp8266\3.0.0\cores\esp8266/HardwareSerial.h:87:68: note: initializing argument 3 of 'void HardwareSerial::begin(long unsigned int, SerialConfig, SerialMode, uint8_t)' 87 | void begin(unsigned long baud, SerialConfig config, SerialMode mode, uint8_t tx_pin) | #define rxPin 3 | ^ | |
---|---|---|---|---|---|---|
int |
D:\Dinesh\Works\gps\gps_sim\gps_sim.ino:69:34: note: in expansion of macro 'rxPin'
69 | sim800.begin(9600, SERIAL_8N1, rxPin , txPin);
| ^~~~~
In file included from C:\Users\pondi\OneDrive\Documents\ArduinoData\packages\esp8266\hardware\esp8266\3.0.0\cores\esp8266/Arduino.h:288,
from sketch\gps_sim.ino.cpp:1:
C:\Users\pondi\OneDrive\Documents\ArduinoData\packages\esp8266\hardware\esp8266\3.0.0\cores\esp8266/HardwareSerial.h:87:68: note: initializing argument 3 of 'void HardwareSerial::begin(long unsigned int, SerialConfig, SerialMode, uint8_t)'
87 | void begin(unsigned long baud, SerialConfig config, SerialMode mode, uint8_t tx_pin)
| ~~~^~~~
exit status 1
invalid conversion from 'int' to 'SerialMode' [-fpermissive]
This show error like this only.
See here: https://tttapa.github.io/ESP8266/Chap04%20-%20Microcontroller.html
The esp8266 Serial port is used by USB serial for Serial. print. Arduino is not the same on different microcontrollers. Here, the Serial. begin does not accommodate pin Rx and Tx definitions because it's used by Serial. print (USB UART). The only pin argument it takes is for Tx (pin 1 or 2) because the other Rx pin is attached to the flash.
So it looks like you could turn off Serial. prints over USB and use that hardware serial port, but not both or more.
Update your code here:
HardwareSerial sim800(1); HardwareSerial neogps(2);
To:
SoftwareSerial sim800; SoftwareSerial neogps;
Unfortunately, I can't help anymore because it's not an issue with this library and I don't own one to test. It's due to the differences between Arduino firmware. You could try asking here: https://www.reddit.com/r/esp8266/.
Okk, Thank you..
See here: https://tttapa.github.io/ESP8266/Chap04%20-%20Microcontroller.html
The esp8266 Serial port is used by USB serial for Serial. print. Arduino is not the same on different microcontrollers. Here, the Serial. begin does not accommodate pin Rx and Tx definitions because it's used by Serial. print (USB UART). The only pin argument it takes is for Tx (pin 1 or 2) because the other Rx pin is attached to the flash.
So it looks like you could turn off Serial. prints over USB and use that hardware serial port, but not both or more.
Update your code here:
HardwareSerial sim800(1); HardwareSerial neogps(2);
To:
SoftwareSerial sim800; SoftwareSerial neogps;
Unfortunately, I can't help anymore because it's not an issue with this library and I don't own one to test. It's due to the differences between Arduino firmware. You could try asking here: https://www.reddit.com/r/esp8266/.
Even if i use software serial i'm getting same error. I want to use both GSM and GPS module. I also tried doing one hardware and other serial but same error
Also the void begin is asking for software mode.. thats what i think from looking at the errors|
`void begin(unsigned long baud, SerialConfig config, SerialMode mode, uni8_t tx_pin)
error: invalid conversion from 'int' to 'SerialMode' [-fpermissive]
initializing argument 3 of 'void HardwareSerial::begin(long unsigned int, SerialConfig, SerialMode)'
Error takes place while calling this and specifically it is because in my code im calling it like
sim800.begin(9600, SERIAL_8N1, rxGSM, txGSM);
Thank you for your response
On Thu, 17 Nov, 2022, 4:10 pm Kuldeep Aher, @.***> wrote:
Also the void begin is asking for software mode.. thats what i think from looking at the errors| `void begin(unsigned long baud, SerialConfig config, SerialMode mode, uni8_t tx_pin)
error: invalid conversion from 'int' to 'SerialMode' [-fpermissive]
initializing argument 3 of 'void HardwareSerial::begin(long unsigned int, SerialConfig, SerialMode)'
Error takes place while calling this and specifically it is because in my code im calling it like sim800.begin(9600, SERIAL_8N1, rxGSM, txGSM);`
— Reply to this email directly, view it on GitHub https://github.com/WifWaf/MH-Z19/issues/15#issuecomment-1318435838, or unsubscribe https://github.com/notifications/unsubscribe-auth/AONCY3XR6GTZLGFZWS74VN3WIYDQDANCNFSM4LRIDKCQ . You are receiving this because you commented.Message ID: @.***>
yep, just change the 'serial.being( 9600, SERIAL_8N1, 16,17)to
Serial.begin(9600, SERIAL_8N1);`
On the NODEMCU these are connected to TX and RX (gpio1 and 3)
Thanks, I'll check them out.
And let you know.
On Wed, 28 Dec, 2022, 8:19 am Jens Timmerman, @.***> wrote:
yep, just change the 'serial.being( 9600, SERIAL_8N1, 16,17)toSerial.begin(9600, SERIAL_8N1);` On the NODEMCU these are connected to TX and RX (gpio1 and 3)
— Reply to this email directly, view it on GitHub https://github.com/WifWaf/MH-Z19/issues/15#issuecomment-1366327751, or unsubscribe https://github.com/notifications/unsubscribe-auth/AONCY3VSVMUDMNT2GVYFGHLWPOTDVANCNFSM4LRIDKCQ . You are receiving this because you commented.Message ID: @.***>
Hello, thank for your library, it's very useful, especially Recovery and Calibrating part. When i use SoftwareSerial, everything work great, but 3 hours later i don't receive any data from the sensor (i tested it several times). So i read, that using HardwareSerial on ESP gives more stability, and i tried to connect via HardwareSerial, but don't received any data. Maybe something wrong with my sketch, but i tried to minimum change it from original example sketch. I just change strings
and also
Cause if i try to compile it with original code, i have error:
Connections: MHZ19 TX -> GPIO13 (D7) (RXD2) MHZ19 RX -> GPIO15 (D8) (TXD2)