dwilches / Ardity

Assets for integrating Arduino and Unity (or Unity and any hardware that communicates over a COM port)
330 stars 62 forks source link

Communication between Ardity and non-Arduino MCU? #19

Closed Andrea-Loriedo closed 5 years ago

Andrea-Loriedo commented 5 years ago

Hi there, I've been trying to get Ardity to communicate with devices other than my Arduino Uno, but have failed to so far... The Uno works flawlessly, however, for my application, I need to use this MCU: https://www.sparkfun.com/products/15025 (The Sparkfun Pro nRF52840 Mini). This board is supposed to be Arduino-enabled and I can upload the Ardity example code to it. It appears as a normal COM port, and knowing the baud rate, I can connect to it (Ardity confirms that connection is established). However, the serial messages that the script is supposed to send (separated by using the println() funtion) don't appear on the console, which is surprising. Any idea why it isn't working properly even though connection is successful? Thank you for your framework and hopefully there's a simple solution!

dwilches commented 5 years ago

Hello Andrea, To debug this issue, could you check if your device is sending the data by connecting to it with PuTTY? This allows to know if the device is sending the data in an unexpected format. Let me know how it goes.

Andrea-Loriedo commented 5 years ago

Hi there, yes I have done and the data appears to be sent as expected. However, there is no output in the Unity console. I spent the whole of yesterday reading through your documentation and trying to fix this but no luck... Any more suggestions?

dwilches commented 5 years ago

Which is the Arduino code you are running and which is the scene you are loading?

Could you try this program and tell me if you get anything in Unity with the scene DemoScene_AutoPoll?

unsigned long last_time = 0;

void setup()
{
    Serial.begin(9600);
}

void loop()
{
    if (millis() > last_time + 1000)
    {
        last_time = millis();
        Serial.println("Test message");
    }
}
Andrea-Loriedo commented 5 years ago

Been loading the autopoll scene with the right COM port and baud rate set up, and the code I've been sending was basically the equivalent of what you posted but using the mbed library instead (my board is mbed enabled, not Arduino). The same exact code will work with an Arduino Uno but not with my mbed enabled Nucleo F401RE.

dwilches commented 5 years ago

Can I take a look at your mbed code?