Closed iskoch01 closed 4 years ago
Can you explain more? Are you running a Blynk or MQTT code on your micro controller? If you’re running Blynk code then are you using the same Auth code on your device as in Node-Red? What does your Node-Red flow and your device sketch look like? Maybe raising this as a topic on the Blynk community forum, along with the info requested above, would be the best approach.
Pete.
Are you running a Blynk or MQTT code on your micro controller?
Blynk. If you’re running Blynk code then are you using the same Auth code on your device as in Node-Red?
Yes. The message correctly toggles the button in the app, so it is getting through. What does your Node-Red flow and your device sketch look like? Maybe raising this as a topic on the Blynk community forum, along with the info requested above, would be the best approach.
I shall have to look at the debug output of the microcontroller when I have a chance.
I boiled it down to a basic sketch and basic flow.
Here's what happens.
Code (running on Wemos D1 Mini) (I'm not using a slider, but I just started with boilerplate code from the example library.)
/*************************************************************
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.
*************************************************************
This sketch shows how to read values from Virtual Pins
App project setup:
Slider widget (0...100) on Virtual Pin V1
*************************************************************/
/* Comment this out to disable prints and save space */
#define BLYNK_PRINT Serial
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "M...t";
// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "...";
char pass[] = "...";
// This function will be called every time Slider Widget
// in Blynk app writes values to the Virtual Pin V1
BLYNK_WRITE(V1)
{
Serial.println("Blynk Write V1");
int pinValue = param.asInt(); // assigning incoming value from pin V1 to a variable
Serial.println(String(pinValue));
// process received value
}
void setup()
{
Serial.println();
Serial.println("I'm a machine!");
// Debug console
Serial.begin(9600);
Blynk.begin(auth, ssid, pass);
// You can also specify server:
//Blynk.begin(auth, ssid, pass, "blynk-cloud.com", 80);
//Blynk.begin(auth, ssid, pass, IPAddress(192,168,1,100), 8080);
Serial.println("Setup finished.");
}
void loop()
{
Blynk.run();
}
Node-Red
[
{
"id": "591c3a35.6ec74c",
"type": "tab",
"label": "Blynk Test",
"disabled": false,
"info": ""
},
{
"id": "ec174547.a1436",
"type": "inject",
"z": "591c3a35.6ec74c",
"name": "",
"topic": "",
"payload": "1",
"payloadType": "str",
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"x": 110,
"y": 120,
"wires": [
[
"9f176979.26d2c8"
]
]
},
{
"id": "6f5f2860.a8041",
"type": "inject",
"z": "591c3a35.6ec74c",
"name": "",
"topic": "",
"payload": "0",
"payloadType": "str",
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"x": 110,
"y": 160,
"wires": [
[
"9f176979.26d2c8"
]
]
},
{
"id": "9f176979.26d2c8",
"type": "blynk-ws-out-write",
"z": "591c3a35.6ec74c",
"name": "Sump Pump - Northeast - V1",
"pin": "1",
"pinmode": 0,
"client": "18828803.811b1",
"x": 360,
"y": 160,
"wires": []
},
{
"id": "932d23a1.e5f3f",
"type": "blynk-ws-in-write",
"z": "591c3a35.6ec74c",
"name": "",
"pin": "1",
"pin_all": 0,
"client": "18828803.811b1",
"x": 310,
"y": 100,
"wires": [
[
"393f84f9.480164"
]
]
},
{
"id": "393f84f9.480164",
"type": "debug",
"z": "591c3a35.6ec74c",
"name": "",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "false",
"x": 480,
"y": 100,
"wires": []
},
{
"id": "18828803.811b1",
"type": "blynk-ws-client",
"z": "",
"name": "Sump Pump - Northeast",
"path": "ws://blynk-cloud.com/websockets",
"key": "M...t",
"dbg_all": false,
"dbg_read": false,
"dbg_write": true,
"dbg_notify": false,
"dbg_mail": false,
"dbg_prop": false,
"dbg_sync": false,
"dbg_bridge": false,
"dbg_low": false,
"dbg_pins": "",
"multi_cmd": false,
"proxy_type": "no",
"proxy_url": "",
"enabled": true
}
]
Pete, I don't feel that Blynk forums can help because I am able to control the device with the Blynk app.
Can anyone post a link to a sample flow to make sure my flow is not wrong?
Isaac
I've answered this issue on the Blynk forum: https://community.blynk.cc/t/app-gets-command-device-doesnt/46419/2?u=peteknight
@gablau I think this issue can be closed.
Pete.
Pete's correct. I was confused by the behavior of a competing library. The bridge node works as expected, although you must toggle "Bridge" log under the configuration node, else you get "NOT_ALLOWED" errors.
I am controlling a micro-controller with Node-Red via Blynk. When I send 0, it should turn it on. The button in the app responds correctly. Using a different library, the identical message works.
Turning on debug mode, I note the following writes:
29 May 09:05:30 - [info] [blynk-ws-client:Attic Fan] virtualWrite: -> ["vw","1","0"] 29 May 09:05:33 - [info] [blynk-ws-client:Attic Fan] writeEvent: -> cmd {"type":20,"typeString":"HW","msgId":111,"len":6,"msgLength":11,"body":"vw\u00001\u00000","operation":"vw","pin":"1","value":"0","array":["0"]}
Please close if not allowed.