[DFRobot Skylark Weather Meter Review] Arduino Wireless Intelligent Air Monitoring System Construction-02 Connect Arduino to Get Data
[Copy link]
This post was last edited by eew_TKwwQ7 on 2023-11-12 23:39
How to connect Arduino devices to obtain real-time data from the Skylark DFRobot Skylark weather instrument. The official website has introduced it in detail.
For reference: https://wiki.dfrobot.com.cn/_SKU_EDU0157_%E4%BA%91%E9%9B%80%E6%B0%94%E8%B1%A1%E4%BB%AA
I happen to have a few DFRobot Romeo V2 development boards. The operation of other development boards is similar. You can refer to the specific development boards. Basically, all mainstream development boards have supported
For detailed information of DFRobot Romeo V2, please refer to: https://wiki.dfrobot.com.cn/_SKU_DFR0225_RoMeo_V2
Let's start the preparation work:
1. Installation and download of DFRobot Skylark Weather Instrument Library on Arduino platform
1.1 Download DFRobot_LarkWeatherStation library
1.2 Library installation, add the zip library method as follows:
Adding the ZIP library to the Arduino IDE
1.3 Compile and report an error if the DFRobot_RTU library is missing
1.4 Add DFRobot_RTU library
1.5 Open the case program and compile it
1.6 Compiled and downloaded, the interface uses IIC interface
1.7 Physical connection photos
2. Obtaining DFRobot Skylark Weather Instrument Data via Arduino
2.1 Get the data and print it to the computer through the USB serial port. You can view the data in real time through the Arduino IDE
2.2 The program code is as follows
/*!
* @File getData.ino
* @brief This is a routine to get skylark data
* ---------------------------------------------------------------------------------------------------------------
* board | MCU | Leonardo/Mega2560/M0 | UNO | ESP8266 | ESP32 | microbit |
* VCC | 3.3V/5V | VCC | VCC | VCC | VCC | X |
* GND | GND | GND | GND | GND | GND | X |
* RX | TX | Serial1 TX1 | 5 | 5/D6 | D2 | X |
* TX | RX | Serial1 RX1 | 4 | 4/D7 | D3 | X |
* ---------------------------------------------------------------------------------------------------------------
*
* @copyright Copyright (c) 2010 DFRobot Co.Ltd (http://www.dfrobot.com)
* @license The MIT License (MIT)
* @author [TangJie](jie.tang@dfrobot.com)
* @version V1.0.0
* @date 2023-06-8
* @URL https://github.com/DFRobot/DFRobot_LarkWeatherStation
*/
#include "DFRobot_LarkWeatherStation.h"
#if defined(ARDUINO_AVR_UNO)||defined(ESP8266)
#include <SoftwareSerial.h>
#endif
#define DEVICE_ADDR 0x42
#define MODESWITCH /*UART:*/0 /*I2C: 0*/
#if MODESWITCH
#if defined(ARDUINO_AVR_UNO)||defined(ESP8266)
SoftwareSerial mySerial(/*rx =*/4, /*tx =*/5);
DFRobot_LarkWeatherStation_UART atm(&mySerial);
#else
DFRobot_LarkWeatherStation_UART atm(&Serial1);
#endif
#else
DFRobot_LarkWeatherStation_I2C atm(DEVICE_ADDR,&Wire);
#endif
void setup(void){
#if MODESWITCH
//Init MCU communication serial port
#if defined(ARDUINO_AVR_UNO)||defined(ESP8266)
mySerial.begin(115200);
#elif defined(ESP32)
Serial1.begin(115200, SERIAL_8N1, /*rx =*/D3, /*tx =*/D2);
#else
Serial1.begin(115200);
#endif
#endif
Serial.begin(115200);
while(atm.begin()!= 0){
Serial.println("init error");
delay(1000);
}
Serial.println("init success");
atm.setTime(2023,1,11,23,59,0);
}
void loop(void){
Serial.println("----------------------------");
Serial.print(atm.getValue("Temp"));
Serial.println(atm.getUnit("Temp"));
Serial.print(atm.getValue("Humi"));
Serial.println(atm.getUnit("Humi"));
Serial.print(atm.getValue("Speed"));
Serial.println(atm.getUnit("Speed"));
Serial.println(atm.getValue("Dir"));
Serial.print(atm.getValue("Altitude"));
Serial.println(atm.getUnit("Altitude"));
Serial.print(atm.getValue("Pressure"));
Serial.println(atm.getUnit("Pressure"));
Serial.println("----------------------------");
Serial.println(atm.getInformation(true));
delay(500);
}
Since then, the Arduino device has been used to obtain the data of the Skylark DFRobot Skylark weather instrument in real time. The data acquisition of other development boards is similar. Later, when there is time, other development boards will be used to obtain the data of the Skylark DFRobot Skylark weather instrument.
|