Hello,
I have very little experience using the Portenta Machine Control and I am currently just trying in to communicate with Nextion Display. I was using a nano before with the code provide below and was able to change the display but since I switched to the portenta I haven't been able to change anything. I have been looking at the forums and saw that a rs485 to ttl converter would fix that but after trying to set it up I am still unable to solve the problem
/*
The following sketch is an example of how to send data to the Nextion display without any library.
The data can be text, numbers, or any other atribute of an object.
You can also send System Variables to change settings on the display like: brightness, serial baud rate, etc.
Connection with Arduino Uno/Nano:
* +5V = 5V
* TX = none
* RX = pin 1 (TX)
* GND = GND
This sketch was made for my 1st video tutorial shown here: https://www.youtube.com/watch?v=wIWxSLVAAQE
Made by InterlinkKnight
Last update: 02/04/2018
*/
#include <Arduino_MachineControl.h>
using namespace machinecontrol;
int variable1 = 0; // This is a simple variable to keep increasing a number to have something dynamic to show on the display.
void setup() { // Put your setup code here, to run once:
// Start serial comunication at baud=9600. For Arduino mega you would have to add a
// number (example: "Serial1.begin(9600);").
comm_protocols.init();
// RS485/RS232 default config is:
// - RS485/RS232 system disabled
// - RS485 mode
// - Half Duplex
// - No A/B and Y/Z 120 Ohm termination enabled
// Enable the RS485/RS232 system
comm_protocols.rs485Enable(true);
comm_protocols.enableCAN();
// Enable the RS232 mode
comm_protocols.rs485ModeRS232(true);
// Specify baudrate for RS232 communication
comm_protocols.rs485.begin(9600);
Serial1.begin(9600);
// Start in receive mode
comm_protocols.rs485.receive();
} // End of setup
void loop() { // Put your main code here, to run repeatedly:
// We are going to send the variable value to the object called n0:
// After the name of the object you need to put the dot val because val is the atribute we want to change on that object.
Serial1.print("n0.val=");
// This is sent to the nextion display to set what object name (before the dot) and what atribute (after the dot) are you going to change.
Serial1.print(5); // This is the value you want to send to that object and atribute mention before.
Serial1.write(0xff); // We always have to send this three lines after each command sent to the nextion display.
Serial1.write(0xff);
Serial1.write(0xff);
} // End of loop