// LoRaWAN + Vision AI Face Detection + TFT LCD
#include <SoftwareSerial.h>
#include “Seeed_Arduino_GroveAI.h”
#include <Wire.h>
#include “TFT_eSPI.h”
#include “Seeed_FS.h” //Including SD card library
#include “RawImage.h” //Including image processing library
TFT_eSPI tft;
GroveAI ai(Wire);
uint8_t state = 0;
SoftwareSerial mySerial(A0, A1); // RX, TX
static char recv_buf[512];
static bool is_exist = false;
static bool is_join = false;
static int at_send_check_response(char *p_ack, int timeout_ms, char *p_cmd, ...)
{
int ch;
int num = 0;
int index = 0;
int startMillis = 0;
va_list args;
memset(recv_buf, 0, sizeof(recv_buf));
va_start(args, p_cmd);
mySerial.printf(p_cmd, args);
Serial.printf(p_cmd, args);
va_end(args);
delay(200);
startMillis = millis();
if (p_ack == NULL)
{
return 0;
}
do
{
while (mySerial.available() > 0)
{
ch = mySerial.read();
recv_buf[index++] = ch;
Serial.print((char)ch);
delay(2);
}
if (strstr(recv_buf, p_ack) != NULL)
{
return 1;
}
} while (millis() – startMillis < timeout_ms);
return 0;
}
static void recv_prase(char *p_msg)
{
if (p_msg == NULL)
{
return;
}
char *p_start = NULL;
int data = 0;
int rssi = 0;
int snr = 0;
p_start = strstr(p_msg, “RX”);
if (p_start && (1 == sscanf(p_start, “RX: ”%d”rn”, &data)))
{
Serial.println(data);
}
p_start = strstr(p_msg, “RSSI”);
if (p_start && (1 == sscanf(p_start, “RSSI %d,”, &rssi)))
{
Serial.println(rssi);
}
p_start = strstr(p_msg, “SNR”);
if (p_start && (1 == sscanf(p_start, “SNR %d”, &snr)))
{
Serial.println(snr);
}
}
void setup(void)
{
//Initialise SD card
if (!SD.begin(SDCARD_SS_PIN, SDCARD_SPI)) {
while (1);
}
tft.begin();
tft.setRotation(3);
drawImage<uint16_t>(“cnxsoftware.bmp”, 0, 0); //Display this 16-bit image in sd card
Wire.begin();
Serial.begin(115200);
mySerial.begin(9600);
delay(5000);
Serial.print(“E5 LORAWAN TESTrn”);
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());
state = 1;
}
else
{
Serial.println(“Algo begin failed.”);
}
if (at_send_check_response(“+AT: OK”, 100, “ATrn”))
{
is_exist = true;
at_send_check_response(“+ID: DevEui”, 1000, “AT+ID=DevEui,”2CF7xxxxxxxx034F”rn”);
at_send_check_response(“+ID: AppEui”, 1000, “AT+ID=AppEui,”8000xxxxxxxx0009”rn”);
at_send_check_response(“+MODE: LWOTAA”, 1000, “AT+MODE=LWOTAArn”);
at_send_check_response(“+DR: AS923”, 1000, “AT+DR=AS923rn”);
at_send_check_response(“+CH: NUM”, 1000, “AT+CH=NUM,0-2rn”);
at_send_check_response(“+KEY: APPKEY”, 1000, “AT+KEY=APPKEY,”8B91xxxxxxxxxxxxxxxxxxxxxxxx6545”rn”);
at_send_check_response(“+CLASS: A”, 1000, “AT+CLASS=Arn”);
at_send_check_response(“+PORT: 8”, 1000, “AT+PORT=8rn”);
delay(200);
is_join = true;
}
else
{
is_exist = false;
Serial.print(“No E5 module found.rn”);
}
}
void loop(void)
{
if (is_exist)
{
int ret = 0;
char cmd[128];
if (is_join)
{
ret = at_send_check_response(“+JOIN: Network joined”, 12000, “AT+JOINrn”);
if (ret)
{
is_join = false;
}
else
{
Serial.println(“”);
Serial.print(“JOIN failed!rnrn”);
delay(5000);
}
}
else
{
if (state == 1)
{
if (ai.invoke()) // begin invoke
{
while (1) // wait for invoking finished
{
CMD_STATE_T ret = ai.state();
if (ret == CMD_STATE_IDLE)
{
break;
}
delay(20);
}
uint8_t len = ai.get_result_len(); // receive how many people detect
if(len)
{
Serial.print(“Number of people: “);
Serial.println(len);
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();
sprintf(cmd, “AT+CMSGHEX=”%04X %04X”rn”, len, data.confidence);
ret = at_send_check_response(“Done”, 10000, cmd);
if(!ret){
break;
Serial.print(“Send failed!rnrn”);
}
else{
recv_prase(recv_buf);
}
}
}
else
{
Serial.println(“No identification”);
}
}
else
{
delay(1000);
Serial.println(“Invoke Failed.”);
}
}
}
}
else
{
delay(1000);
}
delay(500);
}
AI, computer vision meet LoRaWAN with SenseCAP K1100 sensor prototype kit & Latest News Update
AI, computer vision meet LoRaWAN with SenseCAP K1100 sensor prototype kit & More Live News
All this news that I have made and shared for you people, you will like it very much and in it we keep bringing topics for you people like every time so that you keep getting news information like trending topics and you It is our goal to be able to get
all kinds of news without going through us so that we can reach you the latest and best news for free so that you can move ahead further by getting the information of that news together with you. Later on, we will continue
to give information about more today world news update types of latest news through posts on our website so that you always keep moving forward in that news and whatever kind of information will be there, it will definitely be conveyed to you people.
AI, computer vision meet LoRaWAN with SenseCAP K1100 sensor prototype kit & More News Today
All this news that I have brought up to you or will be the most different and best news that you people are not going to get anywhere, along with the information Trending News, Breaking News, Health News, Science News, Sports News, Entertainment News, Technology News, Business News, World News of this made available to all of you so that you are always connected with the news, stay ahead in the matter and keep getting today news all types of news for free till today so that you can get the news by getting it. Always take two steps forward
Credit Goes To News Website – This Original Content Owner News Website . This Is Not My Content So If You Want To Read Original Content You Can Follow Below Links