Code Monkey home page Code Monkey logo

Comments (3)

budryerson avatar budryerson commented on August 27, 2024

from tfmini-plus.

TrombiA avatar TrombiA commented on August 27, 2024

Hello

I use default frame data rate 100hz and default serial baud rate 115200

I tried to change delay to 3ms and those wrong measurement values comes more rarely, something like once in a two minutes. So it looks like that buffer was overrunning like you guessed. Maybe my Node MCU board can't handle that speed either.

I read TFMPlus library text and noticed that there is commands which can be used for change default frame data rate. So can I just put that "define FRAME_1" to my code beginning when I want to change that frame data rate to 1Hz? Or do I have to put some send command definition to code?

Like this (my code which I use for testing):


#include <SoftwareSerial.h>
#include "TFMini.h"
#define FRAME_1 //new line for change default frame rate to 1Hz??

// Setup software serial port
SoftwareSerial mySerial(D2, D1); // Node MCU RX (TFMINI TX), Node MCU TX (TFMINI RX)
TFMini tfmini;

void setup() {
// Step 1: Initialize hardware serial port (serial debug port)
Serial.begin(115200);
// wait for serial port to connect. Needed for native USB port only
while (!Serial);

Serial.println ("Initializing...");

// Step 2: Initialize the data rate for the SoftwareSerial port
mySerial.begin(TFMINI_BAUDRATE);

// Step 3: Initialize the TF Mini sensor
tfmini.begin(&mySerial);
}

void loop() {
// Take one TF Mini distance measurement
uint16_t dist = tfmini.getDistance();
uint16_t strength = tfmini.getRecentSignalStrength();

// Display the measurement
Serial.print(dist);
Serial.print(" cm sigstr: ");
Serial.println(strength);

// Wait some short time before taking the next measurement
delay(200);
}


I use Node MCU board (Lolin 0.1) and here is picture from my setup:

NodeMCU_Setup

I also tryed this setup to use it with blynk app. Here is code for that:


#define BLYNK_PRINT Serial // Comment this out to disable prints and save space
#include <SPI.h>
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include <SimpleTimer.h>
#include <SoftwareSerial.h> //Lisatty.22.2.-20
#include "TFMini.h" //Lisattu.22.2.-20

// Setup software serial port alla olevat lisatty 22.2.-20
SoftwareSerial mySerial(D2, D1); // Node MCU RX (TFMINI TX), Node MCU TX (TFMINI RX)
TFMini tfmini;

// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "____________"; //Enter the Auth code which was send by Blink

// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "_"; //Enter your WIFI Name
char pass[] = "
"; //Enter your WIFI Password

//DHT dht(DHTPIN, DHTTYPE);
SimpleTimer timer;

// This function sends Arduino's up time every second to Virtual Pin (5).
// In the app, Widget's reading frequency should be set to PUSH. This means
// that you define how often to send data to Blynk App.
void sendSensor()

{
float D = ((2.92.9((900-(tfmini.getDistance()))/100))*0.55); //D as distance
float D2 = tfmini.getDistance();
float S = tfmini.getRecentSignalStrength();
Blynk.virtualWrite(V5, D ); //V5 is for Distance
Blynk.virtualWrite(V6,D2 );
Blynk.virtualWrite(V7,S );
}
void setup()
{
Serial.begin(115200);
while (!Serial);
Blynk.begin(auth, ssid, pass);

// Step 1: Initialize hardware serial port (serial debug port)tama lisatty 22.2.-20

// wait for serial port to connect. Needed for native USB port only

// Step 2: Initialize the data rate for the SoftwareSerial port
mySerial.begin(TFMINI_BAUDRATE);

// Step 3: Initialize the TF Mini sensor
tfmini.begin(&mySerial);

//dht.begin(); Poistettu kenoviioivlla 22.2.-20

// Setup a function to be called every second
timer.setInterval(10000L, sendSensor);
}

void loop()
{
Blynk.run(); // Initiates Blynk
timer.run(); // Initiates SimpleTimer
}


It works fine with this code and I get values to blynk app. I were wondering that I can measure volume at storage with this TFmini lidar and blynk app. Thats why there are calculations with measurement results on blynk "D" value.

Br.
Tomi
Finland

from tfmini-plus.

budryerson avatar budryerson commented on August 27, 2024

Tomi,

It appears that you are calling the TFMini library header file ('TFMini.h'). You are NOT using the TFMini-Plus library. There is no getDistance() function in the TFMini-Plus library.

Can that be part of the problem? Please let me know.

Thanks,
Bud

from tfmini-plus.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.