I am involved in a project where I am looking to gather numerical values from a movement sensor using the Arduino IDE and bringing said data into a program called Matlab to display through the use of Bluetooth. Initially, the plan was to use an Arduino MKR Wifi 1010, but due to a compatibility issue between the SAMD architecture and one of the libraries we tried to use <XSens.h> we have opted to attempt to use serial communication between an Arduino Uno and the MKR, where the MKR will behave as a makeshift Bluetooth module.
Unfortunately, we have had little luck with the serial communication between the two boards. We attempted to follow the tutorial on this page but no data was displayed on the Serial Monitor for our Arduino MKR.
Given the unsuccessful attempts thus far, is it even possible to engage in serial communication between an Arduino Uno and an Arduino MKR, and to delve further, to use the MKR as a sort of bluetooth module?
The ideal is to gather sensor data from the Uno -> transfer that data to the MKR -> use a laptop to gather the MKR data (wirelessly via Bluetooth) and display it using Matlab
You connect both boards to the PC and you monitor the activity with two separate serial monitors? Additionally, you have connected the Tx of board 1 to the Rx of board 2 and vice versa?
Currently I am testing the serial communication by running both Arduinos on a single computer. In the final version of the device, neither will be wired directly into the computer - only the MKR will be in communication with the laptop via Bluetooth
Yes, the TX of the MKR is connected to the RX of the Uno and the RX is connected to the TX.
What happens when you simply print to serial on both devices? Do you see any activity on the serial monitors and are the Tx LEDs flickering when you print something?
When I open the Serial Monitor on the Uno, I see "HelloHelloHello..." which is the desired output. The TX LED pin on the Uno flashes with each print of 'Hello.' When I open the SM on the MKR I don't see anything. There is only an 'L' LED onboard the MKR, but it does not flash, it remains off throughout the duration of the code running.
the Arduino MKR Wifi 1010 uses 3.3volt logic the Uno 5V logic - you must connect the devices (at least the UNO serial Tx) using level shifters or you will damage the MKR.
Post the programs (using code tags)
Ah, I wasn't aware of the difference, I will implement one.
Master Uno Code:
char Mymessage[5] = "Hello"; //String data
void setup() {
// Begin the Serial at 9600 Baud
Serial.begin(9600);
}
void loop() {
Serial.write(Mymessage,5); //Write the serial data
Serial.print(Mymessage);
delay(1000);
}
Slave MKR
char Mymessage[10]; //Initialized variable to store recieved data
void setup() {
// Begin the Serial at 9600 Baud
Serial1.begin(9600);
}
void loop() {
Serial1.readBytes(Mymessage,5); //Read the serial data and store in var
Serial1.println(Mymessage); //Print data on Serial Monitor
delay(1000);
}
the UNO is writing to the serial monitor
read up on software serial so you can add an addition serial IO line to send data to the MKR
have you considered using an ESP32 it has a powerful processor and plentry of memory (for a microcontroller) plus onboard WiFi, Bluetooth classic and BLE
In a previous attempt to use serial communication, I attempted to include the SoftwareSerial library, but the IDE was unable to locate it. I don't believe it is installed on this computer, how do I obtain it?
After some testing I was able to get SoftwareSerial working, but only on the Uno. This is the error I get when I attempt to include the library on the MKR - I believe this may be an architecture mismatch error.
Is it still possible to use SoftwareSerial on the MKR, or would i have to run code on the Master to get it to run on the MKR?
the Arduino MKR Wifi 101 has a hardware serial port on pins 13(RX) and 14(TX) - looking on my MKRFOX there are labled 14 < Tx and 13 > Rx
remember you require a level converter betwen the Uno and the MKR
I am still not sure why you need two microcontrollers?
the MKR is to provide Bluetooth and WiFi - what is the UNO for?
I am attempting to make use of a library XSens which is incompatible with the architecture of the MKR. As a result I am attempting to run the XSens library+code on the Uno and transfer the results to the MKR.
From there I would like to detect the device using Bluetooth.
In the final version of the code, yes. The sensor is constantly producing data (which is a good thing.)
However, for the purposes of solely establishing a connection between the two Arduino boards, I've 'dumbed down' the code to see if I could connect the Uno and MKR together.
you are probably running out of memory (flash and SRAM) on the UNO
would the code run on a Mega ?
what interface does the Uno use to communicate with the XSens