如何利用Helium构建土壤湿度探头

你是否需要一种快速的方法来监测您最喜欢的蕨类植物的土壤水分含量?正巧,这篇文章里就有答案。
本文涵盖的内容
以下是我们将要讨论的内容:
使用df robot重力电容式土壤湿度传感器、氦原子原型模块、氦 arduino 适配器和 arduino 板构建完整的土壤湿度探头;
在氦仪表板中注册您的氦元素和氦原子原型模块;建立自己的低功耗广域无线网络;
通过 arduino ide 对土壤湿度探头进行编程;
近乎实时地测量土壤水分数据并将其发送到氦仪表板;并将其通过管道传输到 helium http 通道。
让我们开始吧。
构建土壤湿度探头
首先,我们需要构建传感单元。这是快速和容易的。完成后,您的完整探测应如下所示:
要构建这个,首先,将您的 helium atom 原型模块固定到 helium arduino 适配器中,然后将此组合单元连接到您选择的 arduino 板。确保根据您使用的板相应地配置和跳线。
接下来,我们需要使用 df robot soil moisture probe 随附的三线跨接电缆将实际的土壤湿度探头连接到 helium arduino 适配器。三种电线颜色是黑色、红色和蓝色。在 helium arduino 适配器上,黑线连接到gnd; 红线连接到5v;蓝线连接到接头。正确接线后,我们的电路板如下所示:
最后将跨接电缆上的白色接头连接到 df 机器人土壤湿度探头。
部署 helium 网络
现在是时候建立您自己的 helium 网络了。这大约需要 30 秒。
要部署element并为基于 atom 的传感器创建网络覆盖范围,只需使用提供的电源线将其插入电源和带电以太网端口即可。
注意:如果您有支持蜂窝网络的元素,则使用以太网连接是可选的,但建议作为备份。
一旦插入,您将看到一些 led 活动。当前置 led 变为绿色(表示以太网连接)或蓝绿色(表示蜂窝连接)时,您的 element 将被连接。
在 helium dashboard 中注册
现在我们的传感单元已经构建并且您的 helium 网络已经部署,是时候在helium dashboard 中注册您的硬件了。dashboard 是 helium 的托管用户界面,用于监控和管理连接的硬件部署。helium 发布的所有硬件都已在我们的系统中注册,但我们需要知道是谁在部署它。
首先,创建一个 helium dashboard 帐户。
要注册您的 atom,首先选择new atom 。在 ui 中,添加一个名称(例如fern saver ),然后输入其最后四个mac address及其四个 digit hvv code。点击保存,你就完成了。
元素注册的完成方式完全相同。选择新元素,然后提供名称、其最后四个mac address及其四位数字hvv code。还要确保为您的元素输入一个位置,以便仪表板可以在地图上显示它。
您可以通过查看仪表板中的状态和信号来验证您的元素是否在线:
部署 helium http 通道
helium 平台的一个主要特点是通道。这些是 web 服务(如 aws iot、google cloud iot 和 azure iot)和协议(如mqtt和http)的预构建连接器。借助 channels,helium 为您完成了与这些 web 服务或协议之一集成的所有繁重工作。对于 fern saver,我们的土壤水分探测器,让我们启动一个http 通道。这将使我们能够通过管道将数据传送到任何通过 http 接受数据的 web 服务。例如,您可以使用 http 通道将此数据发送到ifttt ,然后在每次 fern saver 报告湿度低于特定水平时接收文本。
在此示例中,我们将设置一个 http 通道,将数据发送到requestb.in,这是一个方便、免费的 web 服务,用于测试 http 服务。请注意,在下面,当我们将 sketch 上传到 arduino 时,我们将http在代码中引用此通道名称 , 以便我们知道将数据发送到哪里。
配置您的 arduino ide 并上传 sketch
我们现在可以继续配置您的 arduino ide 并导入所需的库。开始:
确保您已下载最新的 arduino ide。
然后我们需要添加两个库:helium和arduinojson. 您可以通过转到sketch include library manage libraries 从 ide 中添加库。搜索“helium”,选择它,然后点击install 。为“arduinojson”库遵循相同的安装过程。(我们需要这个库,因为我们将记录的土壤水分日期格式为 json。)-》-》
一旦完成,就该进行一些实际的 arduino 编程了。以下是完整的soil_humidity.ino 草图。
/*  
* copyright 2017, helium systems, inc.  
* all rights reserved. see licence.txt for license information  
*  
* taking humidity readings using the sen0192 capacitive humidity  
* sensor.  wiring instructions:  
* https://www.dfrobot.com/wiki/index.php/capacitive_soil_moisture_sensor_sku:sen0193  
*  
* install the following libraries through sketch->manage libraries: 
*     - arduinojson  
*     - helium  
*/   
#include board.h 
#include  
#include  
#include  
#include   
// this channel name should correspond the channel you've deployed in helium
// dashboard to ingest this data. 
#define channel_name http 
// delay for one second #define channel_delay 5000 
// send very 60 cycles (seconds) 
#define channel_send_cycle 12  
helium  helium(&atom_serial); 
channel channel(&helium); 
int     channel_counter;
void report_status(int status, int result = 0) 
{     
    if (helium_status_ok == status)     
    {         
        if (result == 0)         
        {             
            serial.println(f(succeeded));
        }         
        else         
        {             
            serial.print(f(failed - ));             
            serial.println(result);
        }     
     }         
     else     
     {
          serial.println(f(failed));
     } 
}  
void 
connect() 
{     
    while (!helium.connected())
     {         
        serial.print(f(connecting - ));
        int status = helium.connect();
        report_status(status); 
        if (helium_status_ok != status)         
        {             
            delay(1000);
        }     
    } 
}  
void 
channel_create(const char * channel_name)
{     
    int8_t result;
    int    status;     
    do     
    {         
        // ensure we're connected         
        connect();
        serial.print(f(creating channel - ));
        status = channel.begin(channel_name, &result);         
        // print status and result         
        report_status(status, result);         
        if (helium_status_ok != status)         
        {             
            delay(1000);
        }     
    } while (helium_status_ok != status || result != 0); 
}  
void 
channel_send(const char * channel_name, void const * data, size_t len) 
{     
    int    status;     
    int8_t result;      
    do     
    {         
        // try to send         
        serial.print(f(sending - ));
        status = channel.send(data, len, &result);
        report_status(status, result);         
        // create the channel if any service errors are returned         
        if (status == helium_status_ok && result != 0)         
        {             
            channel_create(channel_name);         
        }         
        else if (status != helium_status_ok)         
        {             
             delay(1000);
        }     
    } while (helium_status_ok != status || result != 0); 
}   
void 
setup() 
{     
    serial.begin(9600);     
    serial.println(f(starting));
helium.begin(helium_baud_rate);
    channel_create(channel_name);     
    channel_counter = 0; }   
#define dry_value 536 // taken in air 
#define wet_value 303 // taken in water  
#define hum_range (dry_value - wet_value)  
void 
loop() 
{     
    serial.print(f(reading - ));
    float reading = analogread(a0);
    float percent = 100 * (1 - (reading - wet_value) / hum_range);
    serial.print(reading);
    serial.print( - );
    serial.println(percent);      
    if (--channel_counter manage libraries:
 *     - arduinojson
 *     - helium
 */
#include board.h
#include
#include
#include
#include
#define channel_name helium mqtt
// delay for one second
#define channel_delay 5000
// send very 60 cycles (seconds)
#define channel_send_cycle 12
helium  helium(&atom_serial);
channel channel(&helium);
int     channel_counter;
void
report_status(int status, int result = 0)
{
    if (helium_status_ok == status)
    {
        if (result == 0)
        {
            serial.println(f(succeeded));
        }
        else
        {
            serial.print(f(failed - ));
            serial.println(result);
        }
    }
    else
    {
        serial.println(f(failed));
    }
}
void
connect()
{
    while (!helium.connected())
    {
        serial.print(f(connecting - ));
        int status = helium.connect();
        report_status(status);
        if (helium_status_ok != status)
        {
            delay(1000);
        }
    }
}
void
channel_create(const char * channel_name)
{
    int8_t result;
    int    status;
    do
    {
        // ensure we're connected
        connect();
        serial.print(f(creating channel - ));
        status = channel.begin(channel_name, &result);
        // print status and result
        report_status(status, result);
        if (helium_status_ok != status)
        {
            delay(1000);
        }
    } while (helium_status_ok != status || result != 0);
}
void
channel_send(const char * channel_name, void const * data, size_t len)
{
    int    status;
    int8_t result;
    do
    {
        // try to send
        serial.print(f(sending - ));
        status = channel.send(data, len, &result);
        report_status(status, result);
        // create the channel if any service errors are returned
        if (status == helium_status_ok && result != 0)
        {
            channel_create(channel_name);
        }
        else if (status != helium_status_ok)
        {
            delay(1000);
        }
    } while (helium_status_ok != status || result != 0);
}
void
setup()
{
    serial.begin(9600);
    serial.println(f(starting));
    helium.begin(helium_baud_rate);
    channel_create(channel_name);
    channel_counter = 0;
}
#define dry_value 536 // taken in air
#define wet_value 303 // taken in water
#define hum_range (dry_value - wet_value)
void
loop()
{
    serial.print(f(reading - ));
    float reading = analogread(a0);
    float percent = 100 * (1 - (reading - wet_value) / hum_range);
    serial.print(reading);
    serial.print( - );
    serial.println(percent);
    if (--channel_counter <= 0)
    {
        staticjsonbuffer jsonbuffer;
        jsonobject & root = jsonbuffer.createobject();
        root[f(value)]    = reading;
        root[f(percent)] = percent;
        char   buffer[helium_max_data_size];
        size_t used = root.printto(buffer, helium_max_data_size);
        channel_send(channel_name, buffer, used);
        channel_counter = channel_send_cycle;
    }
    delay(channel_delay);
}

IEPE数据采集卡的作用说明
荧光免疫层析检测仪的产品特点
华米Amazfit GTS 2 mini评测:专为小而美、轻量化设计而生
土壤速测仪的功能特点及技术参数
零售商如何利用成熟的无线技术,提供创新且吸引人的客户体验
如何利用Helium构建土壤湿度探头
温湿度采集开关量控制远程4G网关
华为将对FCC禁止美国电信运营商利用补贴购买华为设备的决定提起诉讼
如何选用兆欧表
重庆邮电大学研发第三代半导体功率芯片成功 已进入试用阶段
物联网智能家居助力智慧养老事业发展
旷视科技落户呼和浩特,推进人工智能产业项目建设
安捷伦科技公司SystemVue仿真软件为射频、DSP 和 FPGA/ASIC 的设计人员提供独特的价值
555双稳态触发电路
日本利用机器人进行了“太空电梯”实验
E资讯:红魔7s系列发布,屏下摄像的游戏手机售价5199起
单片机hex文件和bin文件有什么不同
超声波清洗设备的实验室应用
比克动力电池与美国一新能源公司签约 将共同研发及生产超级锂电池
MAX732电池供电+12V快速存储器编程电源电路