Hi
I am trying to get working this code.
I am using Photon .
I am new at Blynk and Arduino style of programming, I use to program in C.
This code is for sending from external microcontroller the same string periodically to Blynk app just for test.
The The photon and the external Mcu are hooked up through RX-TX pins respectively
The string is “<126.78>”.
Same code snippet has been adapted from Arduino tutorials:
http://forum.arduino.cc/index.php?topic=288234.0
The point is that the code compile well and also flash successful but nothing happens on Label Display
I set it up on Blynk app hooked up to virtual pin V5.
Hope for some help.
Here it is the code.
Thank you.
/*************************************************************
Download latest Blynk library here:
https://github.com/blynkkk/blynk-library/releases/latest
Blynk is a platform with iOS and Android apps to control
Arduino, Raspberry Pi and the likes over the Internet.
You can easily build graphic interfaces for all your
projects by simply dragging and dropping widgets.
Downloads, docs, tutorials: http://www.blynk.cc
Sketch generator: http://examples.blynk.cc
Blynk community: http://community.blynk.cc
Follow us: http://www.fb.com/blynkapp
http://twitter.com/blynk_app
Blynk library is licensed under MIT license
This example code is in public domain.
/* Comment this out to disable prints and save space */
#define BLYNK_PRINT Serial1
#include <blynk.h>
// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "xxxxxxxxxxxx41089e112c6f5b2xxxxx";
BlynkTimer timer;
const byte numChars = 8;
char receivedChars[numChars];
boolean newData = false;
void setup()
{
// Debug console
Serial1.begin(56700);
delay(5000); // Allow board to settle
Blynk.begin(auth);
// Setup a function to be called every second
timer.setInterval(2000L, sendAmp);
}
void loop()
{
sendAmp();
Blynk.run();
timer.run();
}
void sendAmp(){
recvWithStartEndMarkers();
// Send it to the server
Blynk.virtualWrite(V5, receivedChars);
}
void recvWithStartEndMarkers() {
static boolean recvInProgress = false;
static byte ndx = 0;
char startMarker = '<';
char endMarker = '>';
char rc;
while (Serial.available() > 0 && newData == false) {
rc = Serial.read();
if (recvInProgress == true) {
if (rc != endMarker) {
receivedChars[ndx] = rc;
ndx++;
if (ndx >= numChars) {
ndx = numChars - 1;
}
}
else {
receivedChars[ndx] = '\0'; // terminate the string
recvInProgress = false;
ndx = 0;
newData = true;
}
}
else if (rc == startMarker) {
recvInProgress = true;
}
}
}