Hi
Do anyone khow how to read data from SRF08 in arduino?
Thanks for your help, but I want a ready and correct code that I see the srf result in serial monitor
(sorry for my English)
hello. I found a library for SRF08 in arduino. but it didn't work. I have no eror but when I see the serial monitor, i don't see anything.
this is the code:
//
// SonarSRF08
// Arduino Library for controlling SRF sonar sensors
// http://www.arduino.cc/playground/Main/SonarSrf08
//
// MIT License
// Copyright(c) 2009 Zach Foresta
// Copyright(c) 2012 Philipp A. Mohrenweiser
// Copyright(c) 2012-2016 Leo Colombaro
//
#include <Wire.h>
#include <SonarSRF08.h>
#define MAIN_08_ADDRESS (0xF8 >> 1)
// Setup Analogue Gain
// http://www.robot-electronics.co.uk/htm/srf08tech.html section "Analogue Gain"
#define GAIN_REGISTER 0x09
// Setup Range Location
// http://www.robot-electronics.co.uk/htm/srf08tech.html section "Changing the Range"
#define LOCATION_REGISTER 0x8C
SonarSRF08 MainSonar(MAIN_08_ADDRESS, GAIN_REGISTER, LOCATION_REGISTER);
char unit = 'c'; // 'i' for inches, 'c' for centimeters, 'm' for micro-seconds
void setup()
{
Serial.begin(9600);
MainSonar.begin();
isConnected("SRF08", MainSonar.readVersion());
}
void loop()
{
distance("SRF08", MainSonar.readRange(unit));
delay(500);
}
// Print out distance
void distance(String reference, int sensorReading)
{
Serial.print("Distance from " + reference + ": ");
Serial.print(sensorReading);
Serial.println(unit);
}
// Print out distance
void isConnected(String reference, int sensorSoft)
{
if (sensorSoft >= 0)
{
Serial.print("Sensor " + reference + " connected (");
Serial.print(sensorSoft);
Serial.println(")");
}
else
{
Serial.println("Sensor " + reference + " not detected...");
}
}
Did you try to run an example from the library first?
Let’s see if the serial port. is working…
Maybe a Serial.print(“Hello”); in setup().
Then you’ll know where to start looking.
it is the example
no. I test this. it has no problem
no
I am talking about example from the library repository:
Did you try it?
hello. do you khow how I can fix this Error?
#include <Wire.h>
#include <SonarSRF08.h>
#define leftAddress ( 0xF2 >> 1) // I2C-BUS-Adresse des SRF02. Da der Arduino eine 7-Bit Adresse erwartet, muss ein Bit nach rechts geschoben werden.
#define rightAddress ( 0xE0 >> 1) // I2C-BUS-Adresse des SRF02. Da der Arduino eine 7-Bit Adresse erwartet, muss ein Bit nach rechts geschoben werden.
#define mainAddress ( 0xF8 >> 1) // I2C-BUS-Adresse des SRF02. Da der Arduino eine 7-Bit Adresse erwartet, muss ein Bit nach rechts geschoben werden.
SonarSRF08 MainSonar;
char unit = 'c'; // 'i' for inches, 'c' for centimeters, 'm' for micro-seconds
void setup()
{
Serial.begin(115200);
MainSonar.connect(mainAddress);
Serial.println("Main SRF08 US-Sensor ");
Serial.println(MainSonar.getSoft());
}
void loop ()
{
float sensorReading = 0;
sensorReading = MainSonar.getRange(unit);
// print out distance
Serial.print("Distance from main: ");
Serial.print(sensorReading);
Serial.print(" ");
Serial.print(unit);
Serial.println();
}
I got this error:
no matching function for call to 'SonarSRF08::SonarSRF08()'
Do you know how to post code properly using Code Tags?
Please do not insert screenshots instead of code and error messages.
Sorry
Error is :
no matching function for call to 'SonarSRF08::SonarSRF08()'
You're right. sorry about that
Hi,
You didn't say which "arduino" you are using in your project.
Did you install the "SonarSRF08.h" library correctly?
What is your IDE version?
I downloaded the library, installed it and compiled its code.
It compiled without errors.
I have merged your cross-posts @User263 .
Cross-posting is against the Arduino forum rules. The reason is that duplicate posts can waste the time of the people trying to help. Someone might spend a lot of time investigating and writing a detailed answer on one topic, without knowing that someone else already did the same in the other topic.
Repeated cross-posting can result in a suspension from the forum.
In the future, please only create one topic for each distinct subject matter. This is basic forum etiquette, as explained in the "How to get the best out of this forum" guide. It contains a lot of other useful information. Please read it.
Thanks in advance for your cooperation.
It seems like the library is unfinished.
The both classes - base SonarSRF and derived SonarSRF08 - has not an explicitly declared constructors.
I have not seen such option before, it seems to me that modern C++ does not allow the absence of a constructor at two levels of inheritance.
Though more experienced people will correct me if I'm wrong.
I am using Arduino mega 2560
yes
2.0.2
that is weird. I don't know where the problem is