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.

Arduino and DHT21 to CR1000


ASant Oct 13, 2013 07:59 AM

Hello! I have been trying to set up a serial connection via the rx/tx ports of an arduino and a cr1000 but I haven't been able to make the message understandable by the Cr1000. Basically I just need to make the arduino send 2 numerical values (air temperature and relative humidity) to the CR1000 and then add them to a table with values from other sensors connected directly to the CR1000. I searched in the forum but only found this thread: https://www.campbellsci.com/forum/messages.cfm?threadid=00210E65-48D6-43C5-8082656A2BA0071C . In there is a little explanation for the CR1000 side, but I have no clue of how it's the arduino supposed to format the serial message it sends. I really don't care if the value it's sent as a number or a string, as long as the CR1000 can understand it and transform it into a numerical value. Can anyone help me with this?


Also, I would like to know if it's possible to connect a cheap AM2301 sensor (which is actually just a DHT21 in a enclosure) directly to a CR1000 (now it's connected to an arduino). I have read the data sheet (http://mon.dubna.tk/files/AM2301.pdf) but I really don't understand how can I make the CR1000 communicate with the sensor.


Thanks a lot for your help!
Best regards from Chile,
Andrés


ASant Oct 15, 2013 10:20 AM

Well, it was pretty simple really. If anyone is interested in doing this here is how:

Hardware:
Arduino TX to CR1000 RX
Arduino RX to CR1000 TX
Arduino GND to CR1000 GND

Te baudrate should be the same in both.

Code:

Arduino:
You can use Serial.print() and send the data as a string. If no USB cable is connected, the data will automatically be sent through the Arduino's TX port.

CR1000:
a little example

BeginProg
SerialOpen (Com4,115200,19,0,1024) 'Initialize the COMPORT
SerialFlush(Com4)
Scan(2,sec,1,0)
SerialIn(variable,Com4,200,-1,25)
NextScan
EndProg

You can use SplitStr() to split the data received ("variable" in this case) into multiple table outputs.It's really easy and well explained in the help file.

Hope it helps someone!

Greetings.


Adi Oct 22, 2015 04:18 AM

Dear ASant,
I have similar problem. Because Vaisala WAV151, wind direction sensor, is 6-bit GRAY-code and is not possible to connect to CR800 I connected it to Arduino by my primitive code and it is working. Although to Adruino I connected Vaisala WAA151, wind speed sensor, and it is working too. My problem in this step is how to send both readings from Arduino to CR800 COM1. Next problem will be how to implement that readings in CR800 in code for RSR2. I will be very grateful to you if you can help me by private message.
Thanks in advance.

Best regards,

* Last updated by: Adi on 11/13/2015 @ 3:02 AM *


maurixio Oct 22, 2015 08:36 AM

ASant

You know something about grab weather parameters to other webserver (not rtmc) to show up the info?

Thanks!


Adi Oct 23, 2015 03:21 AM

Maurixio
PLX-DAQ


porlando Nov 7, 2017 03:59 PM

Asant,

Thank you for the example code! This worked beautifully for me! The biggest challenge was determining the correct buffer size and timeout length to use. Once I increased my timeout from 200 msec  to 500 msec, and allocated 2n + 1 bytes for a buffer, where n = the number of bytes being sent from the arduino to the CR1000 Rx line, the output string within PC400 matched the Arduino IDE serial monitor perfectly.

Thanks again,

Philip 

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