Agora que temos a biblioteca Tensorflow Lite e o projeto básico, é hora de testar um projeto básico.

No livro TinyML de Warden e Situnayake exite um passo-a-passo do que é necessário para criar uma rede neural usando o TensorFlow Lite.

Os dados utilizados nesse post estão disponíveis no link abaixo:

O diagrama abaixo representa a conexão utilizada para o projeto:

Os dados coletados do sensor ultrassônico foram feitos utilizando o seguinte código, condido no arquivo main.cpp do projeto criado anteriormente:

#include <Arduino.h>
const int trigPin = 4; //D4
const int echoPin = 2; //D3

long duration;

void gen_data();
int get_duration();

void setup()
{
  Serial.begin(9600);
  pinMode(trigPin, OUTPUT);
  pinMode(echoPin, INPUT);
}

void loop()
{
  gen_data();
}

int get_duration()
{
  digitalWrite(trigPin, LOW);
  delayMicroseconds(2);

  digitalWrite(trigPin, HIGH);
  delayMicroseconds(10);
  digitalWrite(trigPin, LOW);

  duration = pulseIn(echoPin, HIGH);
  return duration;
}

void gen_data()
{
  Serial.println(get_duration());
  delay(500);
}

Code language: PHP (php)

No notebook abaixo é descrito todo o procedimento para a criação da rede neural.

[git-github-jupyter url=”https://github.com/duducosmos/neuroesp32/blob/main/netHCSR04.ipynb”]

No próximo post iremos adicionar a rede neural ao ESP32.

Referências:

TinyML: Machine Learning with TensorFlow Lite on Arduino and Ultra-Low-Power Microcontrollers de Pete Warden, Daniel Situnayake

,


Deixe um comentário

O seu endereço de e-mail não será publicado. Campos obrigatórios são marcados com *

Search

About

Lorem Ipsum has been the industrys standard dummy text ever since the 1500s, when an unknown prmontserrat took a galley of type and scrambled it to make a type specimen book.

Lorem Ipsum has been the industrys standard dummy text ever since the 1500s, when an unknown prmontserrat took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged.

Gallery