I am having a conflict issue with the ‘newping.h’ library and the command Hologram.getNetworkTime(dt).
The sensor is a HC-SR04 and works perfectly if I do not execute getNetworkTime(dt)
If getNetworkTime() is called, during the setup, the resulting calls to the sensor returns 0 continuously.
If I do not sync to the networktime, it works perfectly.
I have tried several other hologram commands and they have no effect on the ultrasonic sensor whatsoever. Only the getnetworktime causes the issue. I can work around this but is potentially an internal issue that may affect other similar sensors.
I have ample power to the sensors and have researched for several days on what might be causing this. The fact that it works correctly, 100%, without the call for network time and only fails when it is called is beyond anything I can fix.
Thank you in advance for any ideas on this issue.
Gary Rylander
Billings Montana
The following is the code.
// THIS ROUTINE USES AN ULTRASONIC HC-SR04 SENSOR
// IT WORKS PERFECTLY WITH EVERY HologramCloud COMMAND THAT
// I HAVE ISSUED TO THE DASH CARD WITH ONE ‘MAJOR’ EXCEPTION
// IF I ISSUE HologramCloud.getNetworkTime(dt) THE READINGS
// FROM THE SENSOR ALWAYS RETURN ‘0’.
// I ASSUME THAT THERE IS AN INTERUPT ISSUE GOING ON BUT
// IT IS BEYOND MY CAPABILITY TO FIX.
// I REALLY NEED TO SYNC THE DASH CARD TO CELL NETWORK TIME
// I REALLY DON’T WANT TO HAVE TO ADD A GPS TO JUST GET THE
// CURRENT TIME
// ANY HELP WOULD BE GREATLY APPRECIATED.
#include <NewPing.h>
#define POWER_PIN R06
#define TRIGGER_PIN R16
#define ECHO_PIN R17
#define MAX_DISTANCE 200
rtc_datetime_t dt; // internal date format
NewPing sonar(TRIGGER_PIN, ECHO_PIN, MAX_DISTANCE);
void setup (){
Serial.begin(115200);
pinMode(TRIGGER_PIN,OUTPUT);
pinMode(ECHO_PIN,INPUT);
// no effect to sensor readings
// HologramCloud.getSignalStrength();
// HologramCloud.sendMessage(“Hello, World!”, “greeting”);
// bool success = HologramCloud.getLocation(500,300);
// fails completely when this routine is called
// HologramCloud.getNetworkTime(dt);
}
void loop () {
int levl; // ping the sensor - store reading in height variable
do
{
delay(50);
levl = sonar.ping_in();
Serial.print(“height :”);
Serial.println(levl);
Dash.snooze(1000);
} while (levl == 0);
Dash.snooze(5000);
}