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
-
Send configuration (numbers) from HA to Arduino
Home Assistant • 13 Nov 2022, 01:15 • OldSurferDude 14 Nov 2022, 20:18 -
[SOLVED] Multiple devices demonstrating erratic behavior
Troubleshooting • 3 Jan 2015, 21:57 • thermistor1 4 Jan 2015, 20:52 -
OpenHAB MySensors binding 2.5: V_VAR1 and String values
OpenHAB • 3 Jun 2020, 19:09 • syntacrsc 7 Jun 2020, 18:01 -
💬 MySensors Watermeter
OpenHardware.io • 16 Oct 2019, 12:17 • openhardware.io 16 Oct 2019, 12:17 -
[Tutorial] Raspberry Pi NRF24l01 direct connection
Controllers • 24 Mar 2015, 22:32 • Vladut Grecu 24 Apr 2017, 20:39 -
💬 Extremely Simple Arduino Pro-Mini LoRa Water Leak Detector
OpenHardware.io • 26 Nov 2017, 01:53 • openhardware.io 4 Mar 2018, 16:24 -
💬 ESPboy: Games, IoT, STEM for education & fun (ESP8266 core)
OpenHardware.io • 9 Jun 2020, 18:29 • openhardware.io 14 May 2021, 03:04