电子发烧友App

硬声App

0
  • 聊天消息
  • 系统消息
  • 评论与回复
登录后你可以
  • 下载海量资料
  • 学习在线课程
  • 观看技术视频
  • 写文章/发帖/加入社区
创作中心

完善资料让更多小伙伴认识你,还能领取20积分哦,立即完善>

3天内不再提示
电子发烧友网>电子资料下载>电子资料>步道保护NFT开源分享

步道保护NFT开源分享

2023-06-13 | zip | 0.00 MB | 次下载 | 免费

资料介绍

描述

0. 结果

远足真的很有趣,但有时远足径的使用过于频繁,以至于当地的生态系统可能会面临风险。例如,偏离轨道并造成损坏。此外,非法狩猎也会使该物种处于危险之中。

目标:奖励徒步旅行者报告活动和步道状况,以及使用部署在各个远足地点的 Wio 终端收集有关步道的传感器信息

 

 

poYBAGSAiaSAA4YLAABPAMkmEts167.png
 
 
pYYBAGSAiaeAPlYMAAC0tEo7uD0451.png
NFT 索赔
 
poYBAGSAia2AG0PzAADQQXyPf9Q308.png
NFT奖励
 
pYYBAGSAibCARJmqAADOKs3kpJI188.png
社区活动
 

1.建造

1.a 硬件

Seeed Studio LoRaWAN 开发套件使这对用户非常友好,无需真正的硬件技能。

该套件配备了所需的所有基本传感器。在本指南中,我们将使用套件中包含的 LoRa-E5 和 AI 视觉传感器。

将 AI 摄像头连接到左侧端口,将 LoRa 连接到右侧端口。

pYYBAGSAibaAckoJAAnEsxmqgUA903.jpg
 

使用以下 Arduino 代码并上传到 Wio 终端。

#include 
#include "disk91_LoRaE5.h"
#include "Seeed_Arduino_GroveAI.h"
#include 
#include "TFT_eSPI.h"
#define FF17 &FreeSans9pt7b

// keys
uint8_t deveui[] = {0x...};
uint8_t appeui[] = {0x...};
uint8_t appkey[] = {0x...};

GroveAI ai(Wire);
TFT_eSPI tft;
Disk91_LoRaE5 lorae5(false); // true, false whatever

void setup()
{

  Wire.begin();
  Serial.begin(115200);
  randomSeed(analogRead(0));

  tft.begin();
  tft.setRotation(3);
  tft.fillScreen(TFT_BLACK);
  tft.setFreeFont(FF17);
  tft.fillScreen(TFT_BLACK);
  tft.setCursor(0, 20);

  Serial.println("begin");
  tft.println("begin");

  uint32_t start = millis();

  tft.println("LoRa E5 Init");

  // init the library, search the LORAE5 over the different WIO port available
  if (!lorae5.begin(DSKLORAE5_SEARCH_WIO))
  {
    Serial.println("LoRa E5 Init Failed");
    tft.println("LoRa E5 Init Failed");
    while (1)
      ;
  }

  tft.println("LoRa E5 Setup");
  // Setup the LoRaWan Credentials
  if (!lorae5.setup(
        DSKLORAE5_ZONE_US915, // LoRaWan Radio Zone EU868 here
        deveui,
        appeui,
        appkey))
  {
    Serial.println("LoRa E5 Setup Failed");
    tft.println("LoRa E5 Setup Failed");
    while (1);
  }

  if (ai.begin(ALGO_OBJECT_DETECTION, MODEL_EXT_INDEX_1)) // Object detection and pre-trained model 1
  {
    Serial.print("Version: ");
    Serial.println(ai.version());
    Serial.print("ID: ");
    Serial.println(ai.id());
    Serial.print("Algo: ");
    Serial.println(ai.algo());
    Serial.print("Model: ");
    Serial.println(ai.model());
    Serial.print("Confidence: ");
    Serial.println(ai.confidence());
    tft.print("AI version ");
    tft.println(ai.version());
  }
  else
  {
    Serial.println("Algo begin failed. Program halting here.");
    tft.println("Algo begin failed. Program halting here.");
    while (1)
      ;
  }
}

void loop()
{
  uint32_t tick = millis();
  tft.fillScreen(TFT_BLACK);
  tft.setCursor(0, 20);
  tft.println("Begin ai invoke");
  //  tft.println(ai.state());
  if (ai.invoke()) // begin invoke
  {
    tft.println("wait for ai invoke");
    while (1) // wait for invoking finished
    {
      CMD_STATE_T ret = ai.state();
      if (ret == CMD_STATE_IDLE)
      {
        break;
      }
      delay(20);
    }
    tft.println("AI state ready");
    uint8_t len = ai.get_result_len(); // receive how many people detect
    if (len)
    {
      int time1 = millis() - tick;
      Serial.print("Time consuming: ");
      Serial.println(time1);
      Serial.print("Number of people: ");
      Serial.println(len);
      tft.println("Ident success");
      object_detection_t data; //get data

      for (int i = 0; i < len; i++)
      {
        Serial.println("result:detected");
        Serial.print("Detecting and calculating: ");
        Serial.println(i + 1);
        ai.get_result(i, (uint8_t *)&data, sizeof(object_detection_t)); //get result

        Serial.print("confidence:");
        Serial.print(data.confidence);
        Serial.println();

        uint8_t data[] = { random() };


        tft.fillScreen(TFT_BLACK);
        tft.setFreeFont(FF17);
        tft.setCursor(0, 20);
        Serial.print("Unique code: ");
        tft.print("Unique code: ");
        for (int i = 0; i < 4; i++)
        {
          Serial.print(data[i]);
          tft.print(data[i]);
        }

        Serial.println();
        tft.println();

        tft.println("sending to Helium");
        // Send an uplink message. The Join is automatically performed
        if (lorae5.send_sync(
              1,            // LoRaWan Port
              data,         // data array
              sizeof(data), // size of the data
              false,        // we are not expecting a ack
              7,            // Spread Factor
              14            // Tx Power in dBm
            ))
        {
          Serial.println("Uplink done");
          if (lorae5.isDownlinkReceived())
          {
            Serial.println("A downlink has been received");
            if (lorae5.isDownlinkPending())
            {
              Serial.println("More downlink are pending");
            }
          }
        } else {
          Serial.println("uplink failed");
        }
        delay(30000);
      }
    }
    else
    {
      //      Serial.println("No identification");
      delay(1000);
    }
  }
  else
  {
    delay(1000);
    Serial.println("Invoke Failed.");
    tft.println("Invoke Failed.");
  }
}

LoRa 代码基于https://github.com/disk91/Disk91_LoRaE5并且有许多示例可以在完全提交上述代码之前测试设备。

该代码将检测到一个人,然后显示一个随机数,然后可以在前端兑换该随机数以领取 NFT。终端应显示以下内容:

 

1.b 软件

1.ba 氦气

这部分将是工作的主体。应设置 Helium 控制台,使集成流程如下所示

poYBAGSAibiALZP7AAAeyNZP_aA263.png
 

uniq_code_decoder 定义为:

function Decoder(bytes, port, uplink_info) {
  var decoded = {};
  
  if (port == 1) {
    decoded.unique_code = bytes;
  }

  return decoded;
}

对于 webhook 阶段,我选择使用 RequestBin:

poYBAGSAibuACXyeAACHvG-69RA694.png
 

对于“节点”阶段,代码是:

import { FormData, Blob } from "formdata-node";
import { FormDataEncoder } from "form-data-encoder";
import {Readable} from "stream"
import fetch from "node-fetch"

// To use previous step data, pass the `steps` object to the run() function
export default defineComponent({
  async run({ steps, $ }) {
    // Return data to use it in future steps
    const url = "https://api.web3.storage/upload";

    let sensorData = {
        "device_pinValue": steps.trigger.event.body.decoded.payload.unique_code
    };
    console.log(sensorData);
    let form = new FormData();
    let blob = new Blob([new TextEncoder().encode(JSON.stringify(sensorData))], { type: "application/json;charset=utf-8" });
    console.log(blob);
    
    form.append('file', blob, steps.trigger.event.body.uuid + ".json");
    console.log(form);
    const encoder = new FormDataEncoder(form)

    const key = "web3APIKEY"
    const options = {
      method: "post",
      headers: Object.assign({}, encoder.headers, {"Authorization": "Bearer "+ key}),
      body: Readable.from(encoder)
    }


    const resp = await fetch(url, options);
    const text = await resp.text()
    console.log(text);
    return resp;
  },
})

“web3APIKEY”需要替换为来自web3.storage (免费)的 API 密钥。

这部分也可以由后端代码提供服务。

1.bb web3传送门

前端代码位于: https: //github.com/exp0nge/trail-conservation/tree/master/trail-ui它是使用 ReactJS 构建的,因此应该非常易读。有几个集成:

  • NFTPort:使用来自终端的唯一代码铸造 Trail Completionist NFT
  • Pexels:NFT 图像
  • web3.storage:NFT镜像备份的去中心化存储

可在此处查看演示:https://trail-conservation-6e76un.spheron.app/


下载该资料的人也在下载 下载该资料的人还在阅读
更多 >

评论

查看更多

下载排行

本周

  1. 1山景DSP芯片AP8248A2数据手册
  2. 1.06 MB  |  532次下载  |  免费
  3. 2RK3399完整板原理图(支持平板,盒子VR)
  4. 3.28 MB  |  339次下载  |  免费
  5. 3TC358743XBG评估板参考手册
  6. 1.36 MB  |  330次下载  |  免费
  7. 4DFM软件使用教程
  8. 0.84 MB  |  295次下载  |  免费
  9. 5元宇宙深度解析—未来的未来-风口还是泡沫
  10. 6.40 MB  |  227次下载  |  免费
  11. 6迪文DGUS开发指南
  12. 31.67 MB  |  194次下载  |  免费
  13. 7元宇宙底层硬件系列报告
  14. 13.42 MB  |  182次下载  |  免费
  15. 8FP5207XR-G1中文应用手册
  16. 1.09 MB  |  178次下载  |  免费

本月

  1. 1OrCAD10.5下载OrCAD10.5中文版软件
  2. 0.00 MB  |  234315次下载  |  免费
  3. 2555集成电路应用800例(新编版)
  4. 0.00 MB  |  33566次下载  |  免费
  5. 3接口电路图大全
  6. 未知  |  30323次下载  |  免费
  7. 4开关电源设计实例指南
  8. 未知  |  21549次下载  |  免费
  9. 5电气工程师手册免费下载(新编第二版pdf电子书)
  10. 0.00 MB  |  15349次下载  |  免费
  11. 6数字电路基础pdf(下载)
  12. 未知  |  13750次下载  |  免费
  13. 7电子制作实例集锦 下载
  14. 未知  |  8113次下载  |  免费
  15. 8《LED驱动电路设计》 温德尔著
  16. 0.00 MB  |  6656次下载  |  免费

总榜

  1. 1matlab软件下载入口
  2. 未知  |  935054次下载  |  免费
  3. 2protel99se软件下载(可英文版转中文版)
  4. 78.1 MB  |  537798次下载  |  免费
  5. 3MATLAB 7.1 下载 (含软件介绍)
  6. 未知  |  420027次下载  |  免费
  7. 4OrCAD10.5下载OrCAD10.5中文版软件
  8. 0.00 MB  |  234315次下载  |  免费
  9. 5Altium DXP2002下载入口
  10. 未知  |  233046次下载  |  免费
  11. 6电路仿真软件multisim 10.0免费下载
  12. 340992  |  191187次下载  |  免费
  13. 7十天学会AVR单片机与C语言视频教程 下载
  14. 158M  |  183279次下载  |  免费
  15. 8proe5.0野火版下载(中文版免费下载)
  16. 未知  |  138040次下载  |  免费