I just have multiple OutputPorts and they individually post to cosm. From my pool controller, I post 5 things to cosm (water temp, air temp, pump speed, salt levels, heater on/off).
I got all the capture stuff working. But I use the array method and its connected to 1 COSM node. It has a status of 200 and it was posting data before ok.
I tired using the array to post but its not posting the data to COSM
`function pollUart()
{
imp.wakeup(0.00001, pollUart.bindenv(this)); // schedule the next poll in 10us
local byte = hardware.uart57.read(); // read the UART buffer
local tempValue = "";
local tempValue2 = "";
local strLen = 0;
// This will return -1 if there is no data to be read.
while (byte != -1) // otherwise, we keep reading until there is no data to be read.
{
server.log(format("%c", byte)); // send the character out to the server log. Optional, great for debugging
//if (byte < 50) //only display if 1 or 0
//{
tempValue += format("%c", byte);
// server.show(format("%c", byte)); //show value for degubbing [old code]
//impeeOutput.set(format("%c", byte)); // send the valid character out the impee's outputPort [old code]
//}
byte = hardware.uart57.read(); // read from the UART buffer again (not sure if it's a valid character yet
}
if (byte == -1) {
if (tempValue != "") {
tempValue2 = format("%c", tempValue[1]); //skip carrage return and read in values
strLen = tempValue.len(); //get value for slice
if (strLen > 1) { //only do if valid data
//check for values before posting
if (tempValue2 == "w") {
if (strLen > 5) { //only post if valid data
impeeOutput[1].set(tempValue.slice(5,strLen)); //moisture level
if (tempValue[3] == "0") {
server.show("Water is off");
impeeOutput.set(format("%c", tempValue[3]));
}
else if (tempValue[3] == "1") {
server.show("Water is on");
impeeOutput.set(format("%c", tempValue[3]));
}
server.show("Water valve: " + format("%c", tempValue[3]));
server.show("Moisture level: " + tempValue.slice(5,strLen));
}
}
else if (tempValue2 == "t") {
impeeOutput[2].set(tempValue.slice(3,strLen));
server.show("Temperature: " + tempValue.slice(3,strLen));
}
else if (tempValue2 == "c") {
impeeOutput[3].set(tempValue.slice(3,strLen));
server.show("Battery charge status: " + tempValue.slice(3,strLen));
}
else {
server.show("Did not match: " + tempValue2);
}
}
tempValue = "";
tempValue2 = "";
}
}
}`
I’m I missing something? Do I have do something on the planner view?
local impeeInput = impeeIn(); // assign impeeIn class to the impeeInput
local impeeOutput = [ OutputPort(“UART In”, “string”), OutputPort(“Moisture”, “string”), OutputPort(“Temperature”, “string”), OutputPort(“BatteryStatus”, “string”)]; // set impeeOutput as a string
function initUart()
{
hardware.configure(UART_57); // Using UART on pins 5 and 7
hardware.uart57.configure(19200, 8, PARITY_NONE, 1, NO_CTSRTS); // 19200 baud worked well, no parity, 1 stop bit, 8 data bits
}
Hi murkh. I’m trying to do the same thing with a weather station, and having trouble figuring out formatting the string going out from the Arduino, and in turn, in from the Imp. I am a real newbie.