Homemade Environment Sensor + Arduino Shield

Stay safe. Don't worry about this for now.

Thanks
Iman

So, I managed to spend some time today trying to get this working. Right now, it appears that the "Environment Sensor + Shield' board can receive a Zigbee message and then send it to the Arduino board. However, it is not receiving data from the Arduino and sending it to the Hubitat Hub.

I connected a UART to USB adapter to my computer (Rx pin and Gnd only), and used PUTTY to monitor pin 4 when sending data from the Hub to the Arduino (using the 'Transmit IRTest' command button on the IR child device). I was able to 'sniff' some data each time I clicked the command button. I then moved the Rx wire over to Pin 5, and then toggled pin 7 to have the Arduino send data to the Hub. As you can see below, the Arduino sketch is trying to send the data, however the shield never appears to send anything to the Hubitat hub. The Parent's parse() routine never gets called.

I am wondering if I have a board with a loose solder connection somewhere? Is there any way to test the board? I have verified continuity between pins 4 and 5 to their respective pins on what I believe to be the voltage level shifter on the bottom of the board.

I have performed a factory reset on the board, using the button while powering it on. I have re-downloaded the Parent and both Child drivers. I have downloaded you latest sketch and slip library. I have tried two Arduino UNO R3 boards.

I have even tried using an Arduino MEGA 2560 with Software Serial using pins 10 and 11 (since 4 and 5 don't support interrupts for SoftwareSerial.) I was able to receive data at the Arduino, but not transmit it. I then switched to using Hardware Serial on the MEGA, using 'Serial1' on pins 18 and 19. I modified the sketch to use the new HardwareSlip feature of the SLIP library. Onec again, I can receive data, but I cannot seem to transmit data from the Arduino to the Hub.

Here are some pictures of the hardware.




I am basically out of ideas at this point. Any tips you have would be very helpful.

Since I know that you will be using the serial, I tested the board with the IR Example before I shipped it to you.

Are you using my EnvironmentEX DTH as the parent?

Thanks
Iman

Yes, your latest version from yesterday.

In the parent DTH code, do you mind checking whether you have the following in the code. The code is in private def updateSerialDevicesSetting()

Yes, I have that section of code.

UPDATE: By powering off the Environment Sensor Shield, waiting a few seconds, and then powering it back on...I sometimes can get 1 or 2 messages back from the Arduino, by toggling the digital input pin. But then it stops and will never send another one. If I cycle power to the shield, it may or may not work again.

Feels like some sort of timing issue, or something... :thinking:

So you do see some data comes in?

The example I gave you, do not have debounce logic. I wonder whether It send too many data during the toggle due to the pin bounce.

The way I test mine is to touch the pin 7 to the steel shield on the Zigbee radio really quickly. That typically does not cause too much bounce on the pin.

If sending too much data at once is a problem, this is something that I would like to replicate on my end. It should drop the packets instead of stop sending packet.

It look like I can get the shield to send data once or twice immediately after the shield is powered on.

I added debounce logic to make sure the Arduino cannot send data faster than once every 2 seconds.

void ExampleToSendAscii()
{
  if((digitalRead(7) == LOW) && (prevPinStatus == HIGH) && (millis() > prevMillis + 2000))
  { 
    prevMillis = millis();
    prevPinStatus = LOW;
    Serial.println ("Pin 7 is Low");
    char* Test[] = {"Low","High"};
    ASCIIReceiverData data(0u,1u,UNUSED,Test[0]);

    slip.sendpacket((uint8_t*)&data,sizeof(data));
    
  }
  
  if((digitalRead(7) == HIGH) && (prevPinStatus == LOW) && (millis() > prevMillis + 2000))
  { 
    prevMillis = millis();
    prevPinStatus = HIGH;
    Serial.println ("Pin 7 is High");
    char* Test[] = {"Low","High"};
    ASCIIReceiverData data(0u,1u,UNUSED,Test[1]);

    slip.sendpacket((uint8_t*)&data,sizeof(data));
    
  }
  
}

This kind of rate is I am sure that the radio is capable of delivering. I tested with a rate much faster than this.

In the parent logs, do you still see any data coming in from the other sensors? You can press refresh and see if the log are still coming in after the first 2 packets from the arduino.

Yes, the other sensors seem fine (lux, temp, pressure, humidity), even after the serial data from the Arduino sketch stops flowing. And, I can still send serial data using the IRButton Child Device commands. Those cause a Serial.println() to occur in the Arduino IDE Serial Monitor Window.

Do you see any hubitat logs coming in after the first 2?

Thanks
Iman

Not for the Child 'ExampleSerial' device. I do see data in the logs for the normal sensors.

The log should be on the parent not on the child as I am not logging any thing on the ExampleSerial.

If you see activity as you toggle (I know it is hard to read as it require some parsing), there could be a logic error on my ExampleSerial. But, this mean the data is received. If you see log activity corresponding approximately to the toggle, that is a good sign.

Data from serial port would look like below on the log

0104 1001 08 01 0040 00 B017 01 00 0000 00 01 XXXXXXXXXXX

I added some simple logging to the Child Driver.

There is no Live Log activity for any device when I toggle the digital input pin, once it stops working (after 1 or 2 transmits immediately after a power on of the shield.)

It's late here so I am going to stop troubleshooting for the night. Thanks for you assistance. If you figure anything out, I'll be happy to test tomorrow. I can also ship the board back to you if you'd like to troubleshoot it locally.

Ok. thanks. Have a good night.

Here's some of the Live Log data for you to review. This is an example where I was able to get it to work twice (once Low and once High) before it stopped transmitting data. I toggled the inputs multiple times afterwards, but no serial data was received by the hub.

Good night to you, too! :slight_smile:

Hi Dan,

I have been thinking about it. I think the issue may not be wiring (connection). I think you are good. I tested the module with my Arduino before I sent it to you.

It could be something else. If possible, can you test with dedicated USB charger. They can supply power better. This is just a try. I do not know whether you have some sort of power issue. But, if this can be done easily, why not?

I took your Arduino code on the ExampleToSendAscii. I have very good result with it.

Thanks
Iman

I have already tried that. I was using a genuine Apple iPhone charger originally (5V @ 1A = 5W). Last night I tried a genuine Apple iPad charger (5V @2A = 10W). There was no difference.

I'll try to find another USB extension cable to see if the one I have has a problem.

At this point, we can rule out a serial port connection issue. I think the packet is dropped on Zigbee side. At one point, I have arduino sketch that send packet every 2 seconds with a counter to test the serial port. I delete it since. It is easy to modify the ASCII example to do this You can run it a while and confirm whether the packet stop sending after the second one. If it not too much problem, you can try to move the module around and re-pair so that the module will be on different route.

If you like to send it back to me, I will be happy to try that module in my home setup and see if I can see your issue. If the issue is on the Zigbee side, this can confirm it as well.

Thanks
Iman