Sending serial commands to sensors
-
I'm having trouble sending serial commands from openhab to my sensor nodes. The first thing I'm attempting is to change the units on the my sensors humidity sketch from Celsius to Fahrenheit. I wrote a crude rule that seemed to be successfully sent to the arduino, but I saw nothing on the serial monitor of the arduino sensor and saw no changes in the temperatures reported. How can I further troubleshoot this?
-
I'm making slow progress on this however I'm still running into a wall. I have the following rule setup:
rule "Test Rule" when Item Units received update then var String status if(Units.state == ON) status = "I" else status = "M" sendCommand(Arduino, "101;255;3;0;6;" + status + "\n") println("Updated Sensor Units to " + status +)
I'm attempting to tell the serial monitor to report the temperature in imperial units (Fahrenheit) as opposed to the default metric units (Celsius). The rule seems to be running successfully, but I'm getting the following error:
2015-05-12 16:57:52.733 [ERROR] [o.o.c.s.ScriptExecutionThread ] - Error during the execution of rule 'Test Rule': Index: 1, Size: 1
I can't seem to find any reference to this error. I don't see anything on the serial monitor of the arduino nano after flipping the switch on my sitemap when using the humidity sketch from the mysensors main site.
-
This post is deleted!
-
Did you figure this out? I am trying to do the same thing.
-
In the println part there is a string missing at the end after the +, isn't it?
-
@Jan-Gatzke I'm not sure that I understand what you mean. Maybe you're referring to the + after status? If so, I think you may be right, but I would assume that will only affect what is printed in the console, and not what is sent to the remote sensor. In the example above, I believe that 101;255;3;0;6;I\n would be sent if the switch was on, and 101;255;3;0;6;M\n would be sent if the switch was off.
I believe that most of my problem is trying to figure out what should be sent to the remote sensor to enable this. In the above case, my remote sensor is ID 101. Ideally, I'd like to send the message to all sensors, and not just a certain node ID. Would that be 255;255;3;0;6;I\n?
At one point, I thought I had this working, but it wasn't repeatable.
-
I don't think there is a broadcast function in mysensors. You have to call the nodes one by one. I probably found another mistake in your rule. The rule has to be ended with "end". Is this missing or just not copied? The rest looks good. I have similar rules working. Can't say much to the format of the command, because I've never switched the units for y temp sensors.
-
Also, something to remember with your test example, is that the isMetric function is only called in the setup portion of the standard code, in other words when the arduino is first started. So if you are going to swap the functions on the fly then you would need to modify the standard code.
If you have been restarting the arduino's to check then I apologise in advance! Just something that occurred to me on reading your issues.
-
@Chester good point, but I was restarting the arduino and still couldn't get this to work correctly. Also, the missing "end" was just missed out of the paste here, it was in my code.
Suggested Topics
-
Ethernet Gateway on Arduino Yún
Development • 15 Sept 2015, 14:13 • akbooer 11 Jan 2016, 21:03 -
Lua Startup Failure (*SOLVED*)
Vera • 30 Aug 2014, 03:16 • rafael.brasilia 19 Feb 2016, 08:36 -
Openhab Puzzle Rule Programmer
OpenHAB • 7 Dec 2014, 10:44 • C.r.a.z.y. 8 Dec 2014, 03:54 -
PIR motion sensor that sends cloud notifications via wifi
Development • 25 Nov 2014, 07:52 • vekraman76 25 Nov 2014, 09:27 -
Is MQTT Necessary? or, Use Case for MQTT?
Controllers • 28 Mar 2016, 01:12 • TRS-80 9 Jan 2020, 09:01 -
Send configuration (numbers) from HA to Arduino
Home Assistant • 13 Nov 2022, 01:15 • OldSurferDude 14 Nov 2022, 20:18 -
💬 MDMSNode "Lighting X2"
OpenHardware.io • 29 May 2017, 07:56 • openhardware.io 27 Apr 2019, 08:23 -
PN532 NFC RFID module V3 kits : Didn't find PN53x board
Troubleshooting • 20 Dec 2016, 14:31 • SebDominguez 12 Apr 2017, 19:15