Maybe somebody can help me out here.
I am using a GSM 1400 with Arduino IoT Cloud. I am using it to communicate with a raspberry pi (that is running my automatic cow feeder). My goal is to relay messages from the pi to the MKR which then tells the MKR what int to send to my IoT Cloud Dashboard.
I can get one to work. Which is sending int variable values from MKR to arduino cloud. But I cannot get communication between the pi and the arduino to work in the same sketch. Just when I request from pi nothing comes back.
I've narrowed it down to the function the IoT Cloud requires to update the Arduino Cloud (ArduinoCloud.update();). When this is set in the loop() the communication between pi and arduino won't work. However, when I comment it out, the communication between the pi and arduino works fine. I even tried putting it into a function I can call at will, it stops communication from working.
Anybody idea what this could be?
Thanks.
#include "thingProperties.h"
String nom = "Arduino";
String msg;
void setup() {
// Initialize serial and wait for port to open:
Serial.begin(9600);
// Defined in thingProperties.h
initProperties();
// Connect to Arduino IoT Cloud
ArduinoCloud.begin(ArduinoIoTPreferredConnection);
/*
The following function allows you to obtain more information
related to the state of network and IoT Cloud connection and errors
the higher number the more granular information you’ll get.
The default is 0 (only errors).
Maximum is 4
*/
setDebugMessageLevel(2);
ArduinoCloud.printDebugInfo();
}
void loop() {
readSerialPort();
ArduinoCloud.update();
Serial.println("Welcome to Arduino");
if (msg == "open") {
sendOpen();
} else if (msg == "closed") {
sendClosed();
} else if (msg == "siren") {
sendSiren();
delay(3000);
}
void readSerialPort() {
msg = "";
if (Serial.available()) {
delay(10);
while (Serial.available() > 0) {
msg += (char)Serial.read();
}
Serial.flush();
}
}
void sendOpen() {
Serial.print("Heard - open");
}
void sendClosed() {
Serial.print("Heard - Closed");
}
void sendSiren() {
Serial.print("Heard - Siren");
}
void onCommandWriteChange() {
}