Comments (3)
from tfmini-plus.
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:
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.
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)
- How to change 100Hz measurement frame rate to 1000HZ? HOT 1
- printf.h: No such file or directory HOT 3
- How to use TFmini plus distance reading as a threshold? HOT 2
- Failure rate HOT 5
- "Status: Checksum" Galore HOT 4
- Wrong constant in TFMPlus.h HOT 2
- sendCommand() not working with Arduino MKR GSM 1400 HOT 5
- Signal saturation Data - Error HOT 5
- Setting precision to mm HOT 2
- TFMini-Plus Neuf HOT 5
- What is this library called in the Arduino examples HOT 7
- 2x (or more) devices on one board? HOT 19
- Any working code in arduino uno? HOT 1
- How to use multiple TFMini Plus and TF02 Pro sensors on AT Mega 2560? HOT 5
- got message - Status: HEADER Data: 20 09 68 FF 20 09 68 FF 20 HOT 1
- Need some help with TF-Luna and Seeeduino XIAO HOT 3
- PIN_WIRE_SDA' was not declared in this scope
- RPi Pico CRC check error (memcpy)
- Licence ? HOT 3
- Temperature HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from tfmini-plus.