ANALOGUE INPUT ARDUINO UNO AND NODEMCU

HOW CAN I USE ANOTHER ANALOGUE INPUT ,FOR EXAMPLE A2 IN THIS SKETCH

#include <SoftwareSerial.h>
SoftwareSerial ArduinoSerial(3, 2); // RX, TX

void setup() {
Serial.begin(115200);
ArduinoSerial.begin(4800);

pinMode(13, OUTPUT);
}
void loop() {

while (ArduinoSerial.available() > 0) {

float val = ArduinoSerial.parseFloat();

if (ArduinoSerial.read() == ‘\n’) {
if (val == 0xA0) {
int A0 = analogRead(A0);
ArduinoSerial.print(A0);
ArduinoSerial.print("\n");
}
}
}
delay(100);
}

I DONT UNDERSTAND if (val == 0xA0)

float val = ArduinoSerial.parseFloat();

if (ArduinoSerial.read() == '\n') {
  if (val == 0xA0)

That's a pretty bizarre way of specifying what should be an integer.

What are you trying to do?

INTERFACING ARDUINO UNO AND NODEMCU TO USE ANLOGUE INPUT FROM ARDUINO THE SECOND SKETCH NODEMCU IS

#include <SoftwareSerial.h>
#include <ESP8266WiFi.h>
SoftwareSerial NodeSerial(D2, D3); // RX | TX

void setup() {
pinMode(D2, INPUT);
pinMode(D3, OUTPUT);
Serial.begin(115200);
NodeSerial.begin(4800);
}

void loop() {

NodeSerial.print(0xA0);
NodeSerial.print("\n");

while (NodeSerial.available() > 0) {
float val = NodeSerial.parseFloat();
if (NodeSerial.read() == ‘\n’) {
Serial.println(val);
}
}
delay(100);
}

  int A0 = analogRead(A0);Do you see a problem with this line?

What are you trying to do?

Please take off your caps lock key.

SOFTWARE SERIAL BETWEN UNO AND NODEMCU

So, if you want a reading from pin A0, you send 160.00, and that gets read and interpreted as 0xa0?

That's a little weird.

Can you please stop SHOUTING?

FOR A0 IS WORKING I WANT JUST ADD ANOTHER ANALOGUE INPUT LIKE A1

So, send and test for 161.00 (0xa1) as well as 160.00(0xa0)

And for God's sake stop SHOUTING.

WHY ARE YOU SHOUTING?!

Please read this: Serial input basics.

Pieter

if I want a reading from pin A1, what can i send?

Why two processors.

If the NodeMCU is the main one, then add an analogue multiplexer for the (four) joystick pots. Leo..

Edit. The NodeMCU has a 3.3volt processor, and it's pins are not 5volt tolerant.

thank you for your answer I will try to send 16 for 3.3 and 5v i used cd4050

my project is remote control robot using two nodemcu and two arduino

Why the CD4050 (hex buffer).

If you want to use the joysticks on the NodeMCU, then use a 74HC4051 or 74HC4067.

https://www.sparkfun.com/products/13906

https://www.sparkfun.com/products/9056

Leo..

Wawa: If the NodeMCU is the main one, then add an analogue multiplexer for the (four) joystick pots. Leo..

That might not be an optimal solution, since you don't have access to the voltage reference. An external ADC with built-in mux would solve that problem, though, and would be much easier to implement than involving a second microcontroller.

the nodemcu have just one analogue input i cant use 2 joysticks sorry for my bad english

romane19: my project is remote control robot using two nodemcu and two arduino

So you need the inputs/outputs on the Uno.

Then, why the NodeMCU. Wouldn't a simple NRF24L01 be easier. Leo..

PieterP:
That might not be an optimal solution, since you don’t have access to the voltage reference.

Yes, I know about ratiometric sensors, but sometimes there is no better solution.
Leo…

cd4050 tx arduino at 5v converting to 3.3v by cd4050

i using a nodemcu in place NRF24L01 i would like to visualize some data on a web page