Hi Blynk team. Very very nice app. Looking forward for more updates and new widgets. Thanx guys.
At the moment I’m running blynk witch USB connection and I have some difficulties to make the connection stable.
After everything is connected I run blynk-ser.bat in numerous different ways : CMD.exe; run; and normal windows open. I set also set com port in server-sh. Everything is running but only for max 1 minute. Than server-sh output this:
Connecting device at COM6 to cloud.blynk.cc:8442…
OpenC0C("\.\COM6", baud=9600, data=8, parity=no, stop=1) - OK
Connect(“cloud.blynk.cc”, “8442”) - OK
InOut() START
DSR is OFF
Received EOF
EVENT_CLOSE
InOut() - STOP
Disconnect() - OK
Connect(“cloud.blynk.cc”, “8442”) - OK
InOut() START
DSR is OFF
Received EOF
EVENT_CLOSE
InOut() - STOP
Disconnect() - OK
Connect(“cloud.blynk.cc”, “8442”) - OK
InOut() START
DSR is OFF
The app shows arduino is offline.
I have tried holding reset button than lunching server-sh and realising after that. After some time it breaks the connection.
Please help as I’m still waiting for Ethernet shield to arrive.
I was trying to implement some of Blynk functionality in to my recently developed Aquarium Sunrise Control Light based on WS2812B. Basically I tried to send values for each color RGB as they change with time and it is working for short amounts of time
As the code for whole project is quite large I’m sending the code with involves Blynk part only. I tried to prevent flooding the server by using simple timer library.
Maybe the main code is the problem. I’m using two devices on i2c witch are : LCD 20x4 and DS3232RTC clock, plus PWM pin to drive WS2812B LEDs. So there is a bunch of library’s used in the project. So far I had no issues.
I have noticed that when it is actually working there are no issues witch time shown on LCD but when the connection is lost the clock do not display time every second instead it updates time every 10 seconds or so.
Maybe this will be a clue for you.
I’m still not have very good luck with this working, once in a blue moon I can get it working. Most of the time it starts then just repeats what I posted before. Very frustrating. Below is the code I tried to hook up. Can you look it over? I’m using Codebender if that matter. I wasn’t able to get Blynk to compile till I uploaded the lib.
Guess I’ll see if I can have better luck getting my spark core working. Hope that works…
/*
AM2302 Temperature / Humidity Sensor (DHT22)
Blynk
*/
#include <DHT.h>
//#include <SoftwareSerial.h>
//#include <Blynk.h>
//#include <BlynkSimpleSerial.h>
#include <SimpleTimer.h>
#include <SoftwareSerial.h>
SoftwareSerial SwSerial(10, 11);
#define BLYNK_PRINT SwSerial
#include <BlynkSimpleSerial.h>
#define DHTPIN 2
#define DHTTYPE DHT22
DHT dht(DHTPIN, DHTTYPE);
WidgetLED led1(1);
SimpleTimer timer;
char auth[] = "cbf156b989564f0eaccedf0f500f0f3d";
double temperatureSetPoint = 22;
float humidity = 0;
float temperatureC = 0;
float temperatureF = 0; // (1.8 * dht.readTemperature()) + 32; // Convert C to F
float heatIndex = 0;
bool DHT_PRESENT = true;
void setup()
{
//Serial.begin(9600);
SwSerial.begin(9600);
Blynk.begin(auth);
// Wait 3 seconds
//delay(3000);
SwSerial.println(F("DHT test with Blynk"));
SwSerial.println("Blynk connected: " + boolToString(Blynk.connect()));
//delay(5000);
dht.begin();
timer.setInterval(1000, blinkLedWidget);
}
void blinkLedWidget()
{
if (led1.getValue()) {
led1.off();
BLYNK_LOG("LED1: off");
} else {
led1.on();
BLYNK_LOG("LED1: on");
}
}
String boolToString(bool val){
if(val)
return "True";
else
return "False";
}
void loop()
{
Blynk.run();
// Reading temperature or humidity takes about 250 milliseconds!
// Sensor readings may also be up to 2 seconds 'old' (its a very slow sensor)
humidity = dht.readHumidity();
temperatureC = dht.readTemperature();
temperatureF = dht.readTemperature(true); // (1.8 * dht.readTemperature()) + 32; // Convert C to F
heatIndex = dht.computeHeatIndex(temperatureF, humidity);
// check if returns are valid, if they are NaN (not a number) then something went wrong!
if (isnan(temperatureC) || isnan(humidity))
{
SwSerial.println(F("Failed to read from DHT"));
}
else
{
}
//delay(3000);
}
// BLYNK functions
BLYNK_READ(0){
Blynk.virtualWrite(0, DHT_PRESENT);
}
// Temp SetPoint - Data from App
BLYNK_WRITE(1){
BLYNK_LOG("Got a value: %s", param.asStr());
// You can also use: asInt() and asDouble()
}
// Temp SetPoint - Data to App
BLYNK_READ(2){
Blynk.virtualWrite(2, temperatureSetPoint);
}
BLYNK_READ(3){
Blynk.virtualWrite(3, temperatureC);
}
BLYNK_READ(4){
Blynk.virtualWrite(4, temperatureF);
}
BLYNK_READ(12){
Blynk.virtualWrite(12, humidity);
}
BLYNK_WRITE(10) {
//if (param.asInt()) {
// Spark.connect();
//} else {
// Spark.disconnect();
//}
}
Yesterday I started using Ethernet shield therefore USB connection in no longer my concern. Arduino Mega + W5100 shield. So far it works very well. Great job I can now monitor my lights anywhere in the world. Next step is to implement some controll.
Great job Guys.
I think you on to something BIG.
You are going to be some sort of Facebook for “Intrnet of Things”
Good luck.
What program can i use to run the script? i have a mac…if that helps. Someone please help. I got the library up and running but what do i do with the script.
* 1. Optional, but recommended.
* Connect additional USB-serial adapter to see the prints.
*
* 2. Edit auth token and upload this sketch.
*
* 3. Run the script (script located in "scripts" folder of library root,
* e.g. 'blynk-library/scripts') for redirecting traffic to server:
*
* for Windows: blynk-ser.bat
* for Linux and OSX: ./blynk-ser.sh (may need to run with sudo)
*
* You can specify port, baud rate, and server endpoint like this:
* ./blynk-ser.sh -c <serial port> -b <baud rate> -s <server address> -p <server port>
*
* For instance :
* ./blynk-ser.sh -c /dev/ttyACM0 -b 9600 -s cloud.blynk.cc -p 8442
*
* Run blynk-ser.sh -h for more information
*
* Be sure to select the right serial port (there may be multiple).
*
* Attention!
* Arduino IDE may complain with "programmer is not responding".
* You need to terminate script before uploading new sketch.
*
* 4. Start blynking! :)
Yes, but im still confused. Do i change something in the script? im not sure how sudo works either. any other tips will help. i have been at this for several hours i really want to get this working