【TinkerNode】智能农业大棚温湿度云端监控——第一部分
我的好朋友阿峰是农大的一名学生,他最近在做的项目是测算温湿度对水稻产量的影响。所以,每天他都要背着电脑到试验田边好几次。这样非常的麻烦,身为热爱创造的小伙伴。我决定挺身而出帮他解决这个重复工作的问题,让他在寝室就能够采集实验数据。
这个系列会有四个部分组成,最终打造出一套完整的基于TinkerNode物联网主板的检测装置。
第一部分咱们主要来完成如何将太阳能电池板和温湿度传感器搭配起来。
一、实物展示:
因为我们最终的使用场景是在户外,所以我们后面需要对装置进行一个外壳的封装。方式多种多样,可以采用亚克力板进行裁剪。也可以使用3D打印机进行外壳的打印。
二、所需硬件:
1, TinkerNode NB-Iot物联网开发板x12,SHT31数字温湿度传感器 x13,单晶硅太阳能板(5V 1A)x14,3.7V电池 x15,TinkerNode Gravity IO扩展板 x1
这次选择TinkerNode作主板是因为相较于NB模块其强大的性能和更小的体积,这让整个监测装置的功能性和灵敏度都得到了很大的升级。
三、连线方式:
[*]3.7V的电池接到对应的供电接口。
[*]太阳能电池板直接通过usb口连接。
[*]将温湿度传感器按照接口字符接到对应位置。
注意事项:
[*]太阳能电池板对环境光照强度要求比较高,如果没有光照或者光照强度过低会导致太阳能电池板无法输出相应功率。
[*]配置电池的原因是因为,在白天光照强度充足的时候,能够给电池进行充电。而到了夜晚光照强度不足的时候,电池就能够反过来为我们的主板进行供电了。这样就可以延长我们检测装置的一个检测周期。
好的,到这里我们的准备工作基本就差不多了。
四、烧录程序:这一步的工作很简单,就是将我们编写好的程序烧录到TinkerNode中去。但是在开始烧录之前,我们必须要配置好所需要的开发依赖。1,配置环境:配置TinkerNode的相关依赖,这个在TinkerNode的wiki中已经有了详细介绍,在此不在赘述。链接在此:TinkerNode wiki下载温湿度传感器的驱动库文件,并将此驱动库文件放置到你arduino ide的libraries文件夹下。
2,编写程序:#include <DFRobot_SHT3x.h>
//DFRobot_SHT3x sht3x(&Wire,/*address=*/0x45,/*RST=*/4);
DFRobot_SHT3x sht3x;
void setup() {
Serial.begin(9600);
while (sht3x.begin() != 0) {
Serial.println("Failed to Initialize the chip, please confirm the wire connection");
delay(1000);
}
Serial.print("Chip serial number");
Serial.println(sht3x.readSerialNumber());
/**
* softReset Send command resets via IIC, enter the chip's default mode single-measure mode,
* turn off the heater, and clear the alert of the ALERT pin.
* @return Read the register status to determine whether the command was executed successfully,
* and return true indicates success.
*/
if(!sht3x.softReset()){
Serial.println("Failed to Initialize the chip....");
}
/**
* heaterEnable(): Turn on the heater inside the chip to enable the sensor get correct humidity value in wet environments.
* @return Read the status of the register to determine whether the command was executed successfully,
* and return true indicates success.
* @note Heaters should be used in wet environments, and other cases of use will result in incorrect readings
*/
Serial.println("------------------Read adta in single measurement mode-----------------------");
}
void loop() {
Serial.print("Ambient Temperature(°C/F):");
/**
* getTemperatureC Get the meansured temperature(℃).
* @return Return float temperature data.
*/
Serial.print(sht3x.getTemperatureC());
Serial.println(" C/");
Serial.print("Relative Humidity(%RH):");
/**
* getHumidityRH: Get the meansured humidity (%RH)
* @return Return float humidity data
*/
Serial.print(sht3x.getHumidityRH());
Serial.println(" %RH");
Serial.println();
Serial.println();
delay(1000);
}
3,编译上传:
程序编写好了以后,我们就可以通过usb线连接板子上传程序了(这里先不插太阳能电池板)。烧录程序的时候需要注意的是,我们的开发板和端口号是否选择好了。
如图所示,开始上传程序。打开串口,看是否正常检测。(大家在这里可以使用家中的温度计进行对比测试,将温度计得到的数据与打印出的结果进行对比。查看传感器检测到的温度结果是否正常)
五、供电检测
最后,我们将太阳能电池板接上拿到户外观察是否能够正常供电可以看到,红色充电指示灯CHG正常亮起。说明有电流存在。
未完待续......
能不能指导一下帖主
页:
[1]