Go Down

Topic: Arduino Cloud -> Write to Serial  (Read 168 times) previous topic - next topic

nrjbs87

Hi,

I am working on an application of integrating a BH1750 light sensor into a ROS topic of a mobile robot.

I have successfully been able to stream LUX readings from the BH1750 to my MKR WiFi 1010 and up to the Arduino IoT cloud.

When reading data into a ROS platform, I have only found ways to integrate it using serial UART. I have not found a way to take data streamed from a cloud service and stream it in ROS.

Is there a way to take the data from the Arduino Cloud service and write it to the serial port of my ROS workstation wirelessly?

Thanks

ubidefeo

hi @nrjbs87

you can simply use the "on change" callbacks which are called when properties change from the Cloud and use those to call your data-to-serial commands.

Assuming you have a property called "elbowAngle" which is ReadWrite, you'll end up with a callback
Code: [Select]

void onElbowAngleChange(){
    // put your code here, assuming you have a command for Elbow
    // Serial.write(COMMAND_FOR_ELBOW_ANGLE);
    // Serial.write(elbowAngle);
}


always remember that variables created using Arduino IoT Cloud and Create will not be 1 Byte, hence the ".write()" method will slice them and you'll lose data.

You need to work out the protocols and data packaging, but what you're asking for is if it's possible: it is :)

hope this helps you get on the right track.
Ubi

nrjbs87

@ubidefeo thanks for your response.

So when my Arduino is plugged into my laptop and I utilize the `Serial.write()` commands I have no issues. I can see the values streaming to my serial port.

My concern is that I need to have this ability wirelessly since my Arduino and light monitor is mounted on a mobile unit. When i disconnect my USB plug, the issues no longer stream to serial.

Any advice with this?

ubidefeo

My apologies, I hadn't understood the whole flow of operation :)

Because you cannot connect multiple boards to the same thing, you could use WebHooks to send data to a Google Sheet.
Web Hooks are pretty fast, and have already been documented by tutorials.
This is a good one and builds upon the work of a former colleague.

Check it out :)
https://create.arduino.cc/projecthub/wahltharvey/iot-pressure-sensor-mkr-gsm-arduino-cloud-google-sheets-9cdc62

Go Up