daniel-jong / esp8266_p1meter

DSMR5 P1 meter to mqtt using esp8266
GNU General Public License v3.0
145 stars 54 forks source link

TX Pin not defined with nodemcuv3 #3

Closed Dutchone closed 3 years ago

Dutchone commented 3 years ago

Hi,

im running in the issue of TX not being defined with a Nodemcu,

i cant seem to find the problem in the code?

Im using a nodemcu v3

In file included from esp8266_p1meter-master\esp8266_p1meter\esp8266_p1meter.ino:14:0:
esp8266_p1meter-master\esp8266_p1meter\esp8266_p1meter.ino: In function 'void setup()':
settings.h:14:19: error: 'TX' was not declared in this scope
 #define SERIAL_TX TX
                   ^
esp8266_p1meter-master\esp8266_p1meter\esp8266_p1meter.ino:564:54: note: in expansion of macro 'SERIAL_TX'
     Serial.begin(BAUD_RATE, SERIAL_8N1, SERIAL_FULL, SERIAL_TX TX, false);
Dutchone commented 3 years ago

I Fixed my own problem,

I have set SERIAL_TX to D2 and it will compile now

daniel-jong commented 3 years ago

Hi,

Its good to hear that you found your issue, let me know if run into anything else.

Could you double check that you had selected the correct board in your IDE? The TX parameter is usually set by a specific board version, but (as far as I know) is not set for the generic ESp8266 module board.

A month ago i got a similar question, so I'm kinda thinking of either adding a troubleshooting section to the readme, or just adding a comment to settings.h to help out anyone running into this issues.

Knowing if this was a board selection issue or something else will help me in what to write down so please let me know.

Dutchone commented 3 years ago

He,

I'm using a chinese knock off with a ch340 driver those mostly knockoff a (lolin) Wemo R2

I have tried wemo r1, Nodemcu 0,9 Nodemcu 1.0 and the generic, those do not compile, only when you change TX to one of the D pins

I still have the compile in arduino so i can click trough all the board and look at it.

Edit: NodeMCU 0.9: Error NodeMCU 1.0: Error Generic 8266: Error Wemos D1 R1: Error Lolin (WEMOS) D1 R2 and mini: Succes

So i looks like if you have a chinese knockoff its a lolin one, not a NodeMCU V3 what they all say.

daniel-jong commented 3 years ago

Thanks for checking :+1:

I incorrectly assumed that most board definitions would have a TX variable. But looking at your results and the ESP Arduino sourcecode this was incorrect. I've only been able to find this TX variable in the Lolin D1 R2 board specification (that I'm have been using myself), like you have experienced in your test. This is the reason you can't compile whilst targeting anything other than the Lolin D1 R2, even tough your board is a NodeMcu.

I've been able to just remove the SERIAL_TX value from the project altogether, this is due to Serial.begin() using the correct port by default anyhow. This way you should be free to use any board definition without issues. But I would recommend to stay close to what it's trying to copy, your mileage may vary of course.