2 Boards connected via WiFi, both found, but only one can be controlled at once.
I have 2 Wemos D1 Mini, connected via WiFi.
Both boards have different ports and found by Uduino with no problems. But i can only control one board at a time. The Debuglog show me that both boards are found, but when i change values via script or slider, the values get send only to the first board which was discovered. When i plug off the first board while running, the second boards get the commands.
using UnityEngine;
using Uduino;
public class ArduinoController : MonoBehaviour
{
[Range(0, 180)]
public int servoValue;
UduinoDevice boardLeft;
UduinoDevice boardRight;
bool initialized = false;
void Update()
{
if (UduinoManager.Instance.hasBoardConnected() && !initialized)
{
boardLeft = UduinoManager.Instance.GetBoard("leftBoard");
boardRight = UduinoManager.Instance.GetBoard("rightBoard");
UduinoManager.Instance.pinMode(boardLeft, 2, PinMode.Servo);
UduinoManager.Instance.pinMode(boardRight, 2, PinMode.Servo);
initialized = true;
}
if (initialized)
{
UduinoManager.Instance.analogWrite(boardLeft, 2, servoValue);
UduinoManager.Instance.analogWrite(boardRight, 2, servoValue);
}
}
}
Looks like there is a issue with the stream?
As you can see, both boards are found. But only one get the pinSet command and all other commands. I also tried, to get the board and set the pin all the time in update, because i thought that its maybe a timing issue, but this also dont work.
Is there anything i can do?
Comments (4)
-
-
repo owner - changed status to resolved
This has been fixed in the last version of Uduino
-
This has been fixed in the last version of Uduino
Hi, I’ve updated to the new version (3.5.0), But I find this problem still exists.
I connected two ESP32 boards to Uduino and try to read analog inputs from two potentiometers. Two boards are both found and I can read both input numbers on the inspector.
But if I use pins of the same number, two numbers on the inspectors are the same and are actually controlled by only one potentiometer.
for example in my code below, I use pin D39 of each board, then the number I read from them is always the same.
if I use different pins, the problem will be solved.
I actually want to use 10 potentiometers in the future, while one board only have 6 pins which I can use. So I have to use pins of the same number.
Did I do anything wrong in my code?
Thanks in advance.
using UnityEngine; using Uduino; public class UduinoReceive : MonoBehaviour { private UduinoDevice uduinoBoardR; private UduinoDevice uduinoBoardL; void Start() { uduinoBoardL = UduinoManager.Instance.GetBoard("uduinoBoardR"); UduinoManager.Instance.pinMode(uduinoBoardR,39,PinMode.Input); uduinoBoardR = UduinoManager.Instance.GetBoard("uduinoBoardL"); UduinoManager.Instance.pinMode(uduinoBoardL,39,PinMode.Input); } void Update() { UduinoManager.Instance.analogRead(uduinoBoardR,39); UduinoManager.Instance.analogRead(uduinoBoardL,39); } }
-
repo owner Maybe there are issues that I need to investigate when multiple board are assigned in start() function. Indeed, on start the board are not yet discovered. I recommend you to switch your code with this one:
using UnityEngine; using Uduino; public class UduinoReceive : MonoBehaviour { private UduinoDevice uduinoBoardR; private UduinoDevice uduinoBoardL; //You need to drag and drop this script in the callback "OnBoardConnected Event" in the Uduino inspector panel. public void BoardConnected(Uduinodevice device) { Debug.Log("Event: Board " + device.name +" connected"); if(device.name == "uduinoBoardR") { uduinoBoardR = device; UduinoManager.Instance.pinMode(uduinoBoardR,39,PinMode.Input); } if(device.name == "uduinoBoardL") { uduinoBoardL = UduinoManager.Instance.GetBoard("uduinoBoardL"); UduinoManager.Instance.pinMode(uduinoBoardL,39,PinMode.Input); } } void Update() { if(uduinoBoardR!=null) UduinoManager.Instance.analogRead(uduinoBoardR,39); if(uduinoBoardL!=null) UduinoManager.Instance.analogRead(uduinoBoardL,39); } }
- Log in to comment
Have more or less the same problem. Im using digital inputs and in the inspector i can see that the diferent players get diferent inputs. If i have only one the code works, once i get to turn the second board nothing works.
public class GamePad2 : MonoBehaviour
{
float currentVelocity;
[SerializeField] float movespeed = 4f; //Velocidad de movimiento
private Rigidbody rb;
[SerializeField] int fwd;
[SerializeField] int bkw;
[SerializeField] int left;
[SerializeField] int right;
[SerializeField] int jump;