Our full technical support staff does not monitor this forum. If you need assistance from a member of our staff, please submit your question from the Ask a Question page.


Log in or register to post/reply in the forum.

Aosong AM2302 Programming


joe_sandia Jan 10, 2017 03:25 PM

Hi,


I am trying to program an Aosong AM2302 temp/RH sensor that will be connected to a CR1000.  The AM2302 manual is one of the first results when you google "aosong am2302". I am trying to get the incoming raw string first, and then I will try to figure out how to split it.  Thus far I have been unable to get the raw string.  Here is my attempt at the first part of the program:

Public PTemp, batt_volt
Public RawString As String, aosong(3) As String,

BeginProg
    Scan (5,Sec,0,0)

Battery (batt_volt)
PanelTemp (PTemp,250)

    SerialOpen (ComSDC8,9600,3,0,1000)
    SerialIn (RawString,ComSDC8,200,-1,40)
      
If RawString = "" Then
          RawString = "failed to get data"
        EndIf
       
 NextScan
 
EndProg

Thus far RawString shows as "failed to get data".  I have the black wired to ground, red to 5V, and yellow data cable to C8. This is my first attempt at programming a device for the CR1000, and would appreciate any suggestions.


Thanks!


JDavis Jan 10, 2017 03:26 PM

Com4 corresponds to C8. Try changing ComSDC8 in your program to Com4.


jarlu Jan 10, 2017 04:04 PM

Thanks for the quick reply! I am the initial poster. I accidentally posted under my collegues account initially.

Thus far I've attempted Com4, ComSDC7, and ComSDC8 with the data wire in both C7 and C8 at different times with no success.


JDavis Jan 10, 2017 04:32 PM

I looked up the sensor datasheet. It will not be possible to measure it with a CR1000.

That sensor does not have a normal serial interface. 


rlwoell Jan 11, 2017 08:52 AM

This low cost sensor has a non-standard communication protocol.  If this is a student or DIY project that has to operate on a shoe string budger and it is necessary to integrate it on a CR1000 installation you may consider using a separate microprocessor to read the sensor and then output a signal that the CR1000 can read (analog voltage or serial data stream).  There are a number of solutions suggested on the internet including one using a low cost Arduino as shown here:

http://www.electroschematics.com/11291/arduino-dht22-am2302-tutorial-library/

That said, if the data is important and long term accuracy is expected, I suggest you look at the sensors offered by Campbell.  The ability to connect and read them directly with supported software will save time and money.


jarlu Jan 12, 2017 07:41 AM

Thank you both for your replies.  I will look for another sensor.  The goal is to monitor the conditions interior to our enclosures and determine leaks/failed seals remotely. Given the application and high number of enclosures, we are simply looking for a cheap sensor.  Any suggested sensors would be appreciated. Thanks again.


rlwoell Jan 12, 2017 09:03 AM

If an accuracy of +/- 3% RH is acceptable to you, check out the CS210 enclosure sensor sold by Campbell.  It is intended to monitor the RH of a data logger enclosure, an application which sounds similar to your test.  It is considerably less expensive than the research grade sensors sold here but I have used them for years to let me know if there is a moisture leak in my installations.  It is more expensive than the sensor you are trying to use but it is pretty much a plug and play device with direct software support.  Also, if you are using many of them, you can wire them to some of the multiplexers and thereby increase you loggers channel count.

It is not listed with the other environmental sensors but can be found under an accessories section of the enclosure product section.

The following link will take you to the CS210 product where you can find a complete description as well as the user manual.

https://www.campbellsci.com/cs210


porlando Oct 26, 2017 07:46 AM

rlwoell,

Is there any way to translate the serial data from the AM2302's non-standard protocol into the CR1000's Modbus or DNP3 protocol? 


JDavis Oct 26, 2017 09:01 AM

The additional cost and time programming a device to read the signal of the sensor and convert it to Modbus is not worth it. You would be better served looking for an analog output sensor.

Log in or register to post/reply in the forum.